Repository navigation
Description
Parent
Spec: #18. Found while implementing #19 (shared use-parser extraction) and deliberately not fixed there: #19 is metadata-only and carries a strict no-behavior-change-to-any-resolver constraint.
Problem
_resolve_php_type_references (graphify/extractors/resolution.py) builds its per-file class-name map (uses_by_file) from use statements and correctly refuses use function / use const — but only when the keyword sits on the clause. tree-sitter-php puts it on the declaration for the group form:
use function A\f; namespace_use_declaration
namespace_use_clause
function <-- clause-level, rejected
qualified_name
use function A\{f, g}; namespace_use_declaration
function <-- declaration-level, never inspected
namespace_name
namespace_use_group
namespace_use_clause
namespace_use_clause
(probed against tree-sitter-php 0.24.1)
The pass only ever iterated clause children, so a group-form use function A\{f, g}; / use const A\{K}; registers f, g, K as claimed class names. Any inherits / implements / mixes_in / imports / references to that short name in the same file is then treated as explicit and re-pointed onto an FQN-labeled external stub — a name the file never imported as a class.
Pre-existing; not a regression from #19.
Repro (through the public extract() seam)
Three files, semantically equivalent pairs written in the two spellings:
// a/A.php
<?php
namespace App\A;
use function Vendor\Sdk\{Render};
class UsesGroup extends Render {}// b/B.php
<?php
namespace App\B;
use function Vendor\Sdk\Render;
class UsesPlain extends Render {}// c/C.php
<?php
namespace App\C;
use const Vendor\Sdk\{LIMIT};
class UsesConstGroup extends LIMIT {}Actual (identical at 102ae79 and at the #19 commit f8c58e6 — verified by re-running against both):
imports A.php -> 'Vendor\Sdk\Render' <-- wrong
inherits UsesGroup -> 'Vendor\Sdk\Render' <-- wrong
imports B.php -> 'Render' <-- correct
inherits UsesPlain -> 'Render' <-- correct
imports C.php -> 'Vendor\Sdk\LIMIT' <-- wrong
inherits UsesConstGroup -> 'Vendor\Sdk\LIMIT' <-- wrong
B.php is the control: the same import, written without braces, correctly leaves the supertype reference on the bare stub for the legacy unique-label rewire.
Impact is a mis-targeted supertype/reference edge (and, transitively, a stub node labeled with an FQN that names a function or constant, not a class). Rare in practice — it needs a group-form use function/use const whose member short name is also used in a class position in the same file — which is why it is filed separately rather than folded into #19.
The fix is already scaffolded
#19 extracted the parser into _php_use_declaration_facts(decl, source, *, apply_declaration_kind=True) in resolution.py. The helper already reads the declaration-level keyword and reports the right use_kind; the new imports-edge capture (_import_php) consumes it that way and tags group-form members function / const correctly today.
_resolve_php_type_references is the only caller passing apply_declaration_kind=False, purely to preserve the legacy behavior byte-for-byte under #19's constraint. The fix is to drop that argument and delete the flag once the behavior change is accepted and covered.
Acceptance criteria
- Group-form
use function A\{f, g};anduse const A\{K};do not enter the class-name map — the repro above makesA.php/C.phpbehave like theB.phpcontrol -
apply_declaration_kindand itsFalsecall site are removed fromresolution.py(one code path, no legacy flag) - Test through the public
extract()seam, group form vs plain form side by side, with the non-group control asserted in the same test - Existing PHP suites unchanged (
tests/test_php_type_resolution.py,tests/test_php_member_calls.py,tests/test_php_use_imports.py) - Full suite green
Note for #21 / #22
Strictly subtractive: it can only remove an explicit class-name claim, which makes the affected reference fall back to the namespace-relative FQN or the legacy unique-label rewire. Worth landing before the PhpNameResolver decisive-refusal work (#21), since a wrongly claimed short name would there become a wrongly decisive refusal.
Activity
Merge pull request #30 from lawnstarter/fix/php-group-use-kind-26
filipechagas commentedon Aug 5, 2026
Closed by PR #30 (merge commit noted in the PR). Orchestrator gate evidence: independent full-suite run reproduced 4061/36 (baseline 4057/36 + 4 new tests). Red state recorded: 3 failures against unfixed code matching the issue's stated output; over-subtraction guard green by design. v8 baseline is now 4061/36. #21 is unblocked on this fix.