{
"event": "PreToolUse",
"tool_name": "Write",
"tool_input": {
"file_path": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Infrastructure\/CodeAnalysis\/TokenNavigatorTrait.php",
"content": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Infrastructure\\CodeAnalysis;\n\n\/\/ @responsibility: Token-Navigation für PHP-Tokenizer\n\n\/**\n * Trait for navigating PHP token arrays.\n *\n * Provides helper methods to find and extract tokens from\n * token arrays generated by token_get_all().\n *\/\ntrait TokenNavigatorTrait\n{\n \/**\n * Extract a type name starting from a position.\n *\n * @param array<mixed> $tokens\n *\/\n private function extractTypeName(array $tokens, int $startIndex): ?string\n {\n $count = count($tokens);\n\n for ($i = $startIndex; $i < $count; $i++) {\n $token = $tokens[$i];\n\n if (!is_array($token)) {\n continue;\n }\n\n if ($token[0] === T_WHITESPACE) {\n continue;\n }\n\n if (in_array($token[0], [T_STRING, T_NAME_QUALIFIED, T_NAME_FULLY_QUALIFIED], true)) {\n return $token[1];\n }\n\n \/\/ Stop at unexpected token\n break;\n }\n\n return null;\n }\n\n \/**\n * Find next T_STRING token and return its value.\n *\n * @param array<mixed> $tokens\n *\/\n private function findNextString(array $tokens, int $startIndex): ?string\n {\n $count = count($tokens);\n\n for ($i = $startIndex + 1; $i < $count; $i++) {\n if (!is_array($tokens[$i])) {\n if ($tokens[$i] === '(') {\n return null; \/\/ Anonymous function\n }\n\n continue;\n }\n\n if ($tokens[$i][0] === T_STRING) {\n return $tokens[$i][1];\n }\n\n if ($tokens[$i][0] !== T_WHITESPACE) {\n break;\n }\n }\n\n return null;\n }\n\n \/**\n * Find previous non-whitespace token index.\n *\n * @param array<mixed> $tokens\n *\/\n private function findPrevNonWhitespace(array $tokens, int $index): ?int\n {\n for ($i = $index - 1; $i >= 0; $i--) {\n if (!is_array($tokens[$i]) || $tokens[$i][0] !== T_WHITESPACE) {\n return $i;\n }\n }\n\n return null;\n }\n\n \/**\n * Find next non-whitespace token index.\n *\n * @param array<mixed> $tokens\n *\/\n private function findNextNonWhitespace(array $tokens, int $index): ?int\n {\n $count = count($tokens);\n\n for ($i = $index + 1; $i < $count; $i++) {\n if (!is_array($tokens[$i]) || $tokens[$i][0] !== T_WHITESPACE) {\n return $i;\n }\n }\n\n return null;\n }\n}\n"
}
}
{
"tool_response": {
"type": "create",
"filePath": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Infrastructure\/CodeAnalysis\/TokenNavigatorTrait.php",
"content": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Infrastructure\\CodeAnalysis;\n\n\/\/ @responsibility: Token-Navigation für PHP-Tokenizer\n\n\/**\n * Trait for navigating PHP token arrays.\n *\n * Provides helper methods to find and extract tokens from\n * token arrays generated by token_get_all().\n *\/\ntrait TokenNavigatorTrait\n{\n \/**\n * Extract a type name starting from a position.\n *\n * @param array<mixed> $tokens\n *\/\n private function extractTypeName(array $tokens, int $startIndex): ?string\n {\n $count = count($tokens);\n\n for ($i = $startIndex; $i < $count; $i++) {\n $token = $tokens[$i];\n\n if (!is_array($token)) {\n continue;\n }\n\n if ($token[0] === T_WHITESPACE) {\n continue;\n }\n\n if (in_array($token[0], [T_STRING, T_NAME_QUALIFIED, T_NAME_FULLY_QUALIFIED], true)) {\n return $token[1];\n }\n\n \/\/ Stop at unexpected token\n break;\n }\n\n return null;\n }\n\n \/**\n * Find next T_STRING token and return its value.\n *\n * @param array<mixed> $tokens\n *\/\n private function findNextString(array $tokens, int $startIndex): ?string\n {\n $count = count($tokens);\n\n for ($i = $startIndex + 1; $i < $count; $i++) {\n if (!is_array($tokens[$i])) {\n if ($tokens[$i] === '(') {\n return null; \/\/ Anonymous function\n }\n\n continue;\n }\n\n if ($tokens[$i][0] === T_STRING) {\n return $tokens[$i][1];\n }\n\n if ($tokens[$i][0] !== T_WHITESPACE) {\n break;\n }\n }\n\n return null;\n }\n\n \/**\n * Find previous non-whitespace token index.\n *\n * @param array<mixed> $tokens\n *\/\n private function findPrevNonWhitespace(array $tokens, int $index): ?int\n {\n for ($i = $index - 1; $i >= 0; $i--) {\n if (!is_array($tokens[$i]) || $tokens[$i][0] !== T_WHITESPACE) {\n return $i;\n }\n }\n\n return null;\n }\n\n \/**\n * Find next non-whitespace token index.\n *\n * @param array<mixed> $tokens\n *\/\n private function findNextNonWhitespace(array $tokens, int $index): ?int\n {\n $count = count($tokens);\n\n for ($i = $index + 1; $i < $count; $i++) {\n if (!is_array($tokens[$i]) || $tokens[$i][0] !== T_WHITESPACE) {\n return $i;\n }\n }\n\n return null;\n }\n}\n",
"structuredPatch": [],
"originalFile": null
}
}