You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug(indexer): PHP imports query matches use_declaration (trait use) instead of namespace_use_declaration, so PHP files produce no imports at all #1522
The imports query captures (use_declaration). That is the trait use inside a class body — php.py relies on exactly that at line 309. A top-level use App\Models\User; is a different node type: namespace_use_declaration.
Reproduction
$ .venv/bin/python -c "from codegraphcontext.tools.tree_sitter_parser import TreeSitterParserfrom codegraphcontext.tools.languages.php import PhpTreeSitterParserimport tempfile, pathlibp = pathlib.Path(tempfile.mkdtemp())/'a.php'p.write_text('<?php\nuse App\\\\Models\\\\User;\nuse App\\\\Models\\\\Post as BlogPost;\n')print([i.get('name') for i in PhpTreeSitterParser(TreeSitterParser('php')).parse(str(p))['imports']])"[]
Two consequences, in opposite directions:
Real imports are dropped entirely — PHP files produce noModule nodes and noIMPORTS edges.
Trait uses inside class bodies are captured by this query, so they are mislabelled as imports. Across the PHP fixtures the only two "imports" found are trait uses; all four genuine imports are missing.
Impact
use is how PHP does every cross-file reference. With no import data, resolution/calls.py has an empty local_imports map for PHP, so no call to a class imported from another file can be resolved to its definition. PHP call graphs are limited to same-file resolution.
Suggested fix
Capture namespace_use_declaration for imports and keep use_declaration for the trait-use handling that already exists at line 309 — they are genuinely different constructs and should not share a query.
Environment
Commit
c0e0bed (main)
Python
3.12.3, Linux
Reproduced with the snippet above and against the repo's PHP fixtures.
Activity
github-actions commentedon Aug 1, 2026
Hi! 👋 Join our CodeGraphContext Discord channel to collaborate: https://discord.gg/dR4QY32uYQ
fix(parsers): capture PHP imports, not trait uses (#1522) (#1563)
chore(release): bump version to 0.5.5 (#1569)