{
"event": "PreToolUse",
"tool_name": "Edit",
"tool_input": {
"file_path": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Framework\/Middleware\/CorrelationMiddleware.php",
"old_string": "<?php\n\nnamespace Framework\\Middleware;\n\n\/**\n * Middleware to ensure every request has a correlation ID.\n *\n * The correlation ID is used to trace all log entries for a single request.\n * It can be passed in via X-Correlation-ID header or generated automatically.\n *\/\nfinal class CorrelationMiddleware",
"new_string": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Framework\\Middleware;\n\n\/\/ @responsibility: Middleware für Request-Correlation-ID (Tracing)\n\nfinal class CorrelationMiddleware"
}
}
{
"tool_response": {
"filePath": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Framework\/Middleware\/CorrelationMiddleware.php",
"oldString": "<?php\n\nnamespace Framework\\Middleware;\n\n\/**\n * Middleware to ensure every request has a correlation ID.\n *\n * The correlation ID is used to trace all log entries for a single request.\n * It can be passed in via X-Correlation-ID header or generated automatically.\n *\/\nfinal class CorrelationMiddleware",
"newString": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Framework\\Middleware;\n\n\/\/ @responsibility: Middleware für Request-Correlation-ID (Tracing)\n\nfinal class CorrelationMiddleware",
"originalFile": "<?php\n\nnamespace Framework\\Middleware;\n\n\/**\n * Middleware to ensure every request has a correlation ID.\n *\n * The correlation ID is used to trace all log entries for a single request.\n * It can be passed in via X-Correlation-ID header or generated automatically.\n *\/\nfinal class CorrelationMiddleware\n{\n \/**\n * Handle the request and set correlation ID.\n *\n * @param callable $next The next handler in the chain\n *\/\n public function handle(callable $next): void\n {\n $correlationId = $this->getOrCreateCorrelationId();\n\n \/\/ Make globally available\n $_SERVER['CORRELATION_ID'] = $correlationId;\n\n \/\/ Set response header for tracing\n if (!headers_sent()) {\n header(\"X-Correlation-ID: {$correlationId}\");\n }\n\n $next();\n }\n\n \/**\n * Get existing correlation ID from header or generate new one.\n *\/\n private function getOrCreateCorrelationId(): string\n {\n \/\/ Check for existing correlation ID in headers\n if (isset($_SERVER['HTTP_X_CORRELATION_ID']) && $_SERVER['HTTP_X_CORRELATION_ID'] !== '') {\n return $_SERVER['HTTP_X_CORRELATION_ID'];\n }\n\n \/\/ Generate new correlation ID\n return bin2hex(random_bytes(8));\n }\n\n \/**\n * Get the current correlation ID.\n *\/\n public static function getCorrelationId(): string\n {\n return $_SERVER['CORRELATION_ID'] ?? bin2hex(random_bytes(8));\n }\n}\n",
"structuredPatch": [
{
"oldStart": 1,
"oldLines": 13,
"newStart": 1,
"newLines": 11,
"lines": [
" <?php",
" ",
"+declare(strict_types=1);",
"+",
" namespace Framework\\Middleware;",
" ",
"-\/**",
"- * Middleware to ensure every request has a correlation ID.",
"- *",
"- * The correlation ID is used to trace all log entries for a single request.",
"- * It can be passed in via X-Correlation-ID header or generated automatically.",
"- *\/",
"+\/\/ @responsibility: Middleware für Request-Correlation-ID (Tracing)",
"+",
" final class CorrelationMiddleware",
" {",
" \/**"
]
}
],
"userModified": false,
"replaceAll": false
}
}