{
"event": "PreToolUse",
"tool_name": "Read",
"tool_input": {
"file_path": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Infrastructure\/CodeAnalysis\/PhpFileParser.php",
"offset": 128,
"limit": 140
}
}
{
"tool_response": {
"type": "text",
"file": {
"filePath": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Infrastructure\/CodeAnalysis\/PhpFileParser.php",
"content": " \/**\n * Extracts use statements (top-level imports only).\n *\n * @param array<mixed> $tokens\n * @return array<string>\n *\/\n private function extractUseStatements(array $tokens): array\n {\n $uses = [];\n $count = count($tokens);\n $braceDepth = 0;\n\n for ($i = 0; $i < $count; $i++) {\n $token = $tokens[$i];\n\n \/\/ Track brace depth to distinguish top-level use from trait use\n if (!is_array($token)) {\n if ($token === '{') {\n $braceDepth++;\n } elseif ($token === '}') {\n $braceDepth--;\n }\n\n continue;\n }\n\n \/\/ Only process top-level use statements\n if ($token[0] !== T_USE || $braceDepth > 0) {\n continue;\n }\n\n \/\/ Skip function\/const imports\n $nextToken = $this->findNextNonWhitespace($tokens, $i);\n if ($nextToken !== null && is_array($tokens[$nextToken])) {\n if ($tokens[$nextToken][0] === T_FUNCTION || $tokens[$nextToken][0] === T_CONST) {\n continue;\n }\n }\n\n \/\/ Extract the use statement(s)\n $useResult = $this->parseUseStatement($tokens, $i);\n foreach ($useResult['fqcns'] as $fqcn) {\n $uses[] = $fqcn;\n }\n }\n\n return array_unique($uses);\n }\n\n \/**\n * Parse a single use statement, handling grouped imports.\n *\n * @param array<mixed> $tokens\n * @return array{fqcns: array<string>, endIndex: int}\n *\/\n private function parseUseStatement(array $tokens, int $startIndex): array\n {\n $fqcns = [];\n $count = count($tokens);\n $baseNamespace = '';\n $currentName = '';\n $inGroup = false;\n\n for ($i = $startIndex + 1; $i < $count; $i++) {\n $token = $tokens[$i];\n\n if ($token === ';') {\n if ($currentName !== '') {\n $fqcns[] = $inGroup ? $baseNamespace . $currentName : $currentName;\n }\n\n break;\n }\n\n if ($token === '{') {\n $baseNamespace = $currentName;\n $currentName = '';\n $inGroup = true;\n\n continue;\n }\n\n if ($token === '}') {\n if ($currentName !== '') {\n $fqcns[] = $baseNamespace . $currentName;\n }\n\n continue;\n }\n\n if ($token === ',') {\n if ($currentName !== '') {\n $fqcns[] = $inGroup ? $baseNamespace . $currentName : $currentName;\n }\n $currentName = '';\n\n continue;\n }\n\n if (!is_array($token)) {\n continue;\n }\n\n \/\/ Skip 'as' aliases - we only care about the original FQCN\n if ($token[0] === T_AS) {\n \/\/ Skip until comma or semicolon\n for ($j = $i + 1; $j < $count; $j++) {\n if ($tokens[$j] === ',' || $tokens[$j] === ';' || $tokens[$j] === '}') {\n $i = $j - 1;\n\n break;\n }\n }\n\n continue;\n }\n\n if ($token[0] === T_NAME_QUALIFIED || $token[0] === T_NAME_FULLY_QUALIFIED) {\n $currentName .= ltrim($token[1], '\\\\');\n } elseif ($token[0] === T_STRING) {\n $currentName .= $token[1];\n } elseif ($token[0] === T_NS_SEPARATOR) {\n $currentName .= '\\\\';\n }\n }\n\n return ['fqcns' => $fqcns, 'endIndex' => $i ?? $startIndex];\n }\n\n \/**\n * @param array<mixed> $tokens\n * @return array<array{name: string, type: string, line: int}>\n *\/\n private function extractClasses(array $tokens): array\n {\n $classes = [];\n $count = count($tokens);\n\n for ($i = 0; $i < $count; $i++) {\n $token = $tokens[$i];",
"numLines": 140,
"startLine": 128,
"totalLines": 671
}
}
}