{
"event": "PreToolUse",
"tool_name": "Read",
"tool_input": {
"file_path": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Infrastructure\/CodeAnalysis\/PhpFileParser.php",
"offset": 260,
"limit": 150
}
}
{
"tool_response": {
"type": "text",
"file": {
"filePath": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Infrastructure\/CodeAnalysis\/PhpFileParser.php",
"content": " }\n\n \/**\n * Extract constructor parameter type hints (DI dependencies).\n *\n * @param array<mixed> $tokens\n * @return array<string>\n *\/\n private function extractConstructorDeps(array $tokens): array\n {\n $deps = [];\n $count = count($tokens);\n $braceDepth = 0;\n $inClass = false;\n\n for ($i = 0; $i < $count; $i++) {\n $token = $tokens[$i];\n\n if (!is_array($token)) {\n if ($token === '{') {\n $braceDepth++;\n } elseif ($token === '}') {\n $braceDepth--;\n if ($braceDepth === 0) {\n $inClass = false;\n }\n }\n\n continue;\n }\n\n if (in_array($token[0], [T_CLASS, T_TRAIT, T_ENUM], true)) {\n $inClass = true;\n\n continue;\n }\n\n \/\/ Look for T_FUNCTION with name __construct\n if ($token[0] !== T_FUNCTION) {\n continue;\n }\n\n \/\/ Check if it's __construct\n $funcName = $this->findNextString($tokens, $i);\n if ($funcName !== '__construct') {\n continue;\n }\n\n \/\/ Find opening parenthesis\n $parenStart = null;\n for ($j = $i + 1; $j < $count; $j++) {\n if ($tokens[$j] === '(') {\n $parenStart = $j;\n\n break;\n }\n }\n\n if ($parenStart === null) {\n continue;\n }\n\n \/\/ Extract type hints from parameters\n $parenDepth = 1;\n $lastType = null;\n\n for ($j = $parenStart + 1; $j < $count && $parenDepth > 0; $j++) {\n $paramToken = $tokens[$j];\n\n if ($paramToken === '(') {\n $parenDepth++;\n\n continue;\n }\n if ($paramToken === ')') {\n $parenDepth--;\n\n continue;\n }\n\n if (!is_array($paramToken)) {\n continue;\n }\n\n \/\/ Type hint tokens (skip built-in types)\n if (in_array($paramToken[0], [T_STRING, T_NAME_QUALIFIED, T_NAME_FULLY_QUALIFIED], true)) {\n $typeName = $paramToken[1];\n\n \/\/ Skip built-in types\n if (!$this->isBuiltInType($typeName)) {\n $lastType = $typeName;\n }\n }\n\n \/\/ Variable = end of parameter, save type if found\n if ($paramToken[0] === T_VARIABLE && $lastType !== null) {\n $deps[] = $this->resolveFqcn($lastType);\n $lastType = null;\n }\n }\n\n \/\/ Only process first constructor found\n break;\n }\n\n return array_unique($deps);\n }\n\n \/**\n * Resolve a short or qualified name to FQCN.\n *\/\n private function resolveFqcn(string $name): string\n {\n \/\/ Already fully qualified\n if (str_starts_with($name, '\\\\')) {\n return ltrim($name, '\\\\');\n }\n\n \/\/ Already contains namespace separator (qualified name)\n if (str_contains($name, '\\\\')) {\n return $name;\n }\n\n \/\/ Check import map\n if (isset($this->importMap[$name])) {\n return $this->importMap[$name];\n }\n\n \/\/ Default to current namespace + name\n if ($this->currentNamespace !== null) {\n return $this->currentNamespace . '\\\\' . $name;\n }\n\n return $name;\n }\n\n \/**\n * Check if a type name is a PHP built-in type.\n *\/\n private function isBuiltInType(string $type): bool\n {\n $builtIn = [\n 'int', 'float', 'bool', 'string', 'array', 'object', 'callable',\n 'iterable', 'void', 'null', 'mixed', 'never', 'true', 'false',\n 'self', 'static', 'parent',\n ];\n\n return in_array(strtolower($type), $builtIn, true);\n }\n}",
"numLines": 150,
"startLine": 260,
"totalLines": 410
}
}
}