Skip to content

fix(parsers/php): resolve same-class methods that shadow a PHP builtin name - #140

Merged
gadievron merged 2 commits into
masterfrom
fix/php-builtin-shadow-callgraph
Jul 14, 2026
Merged

fix(parsers/php): resolve same-class methods that shadow a PHP builtin name#140
gadievron merged 2 commits into
masterfrom
fix/php-builtin-shadow-callgraph

Conversation

@gadievron

Copy link
Copy Markdown
Collaborator

_resolve_member_call ($this->) and _resolve_scoped_call (self::/static::/
parent::/Class::) ran if self._is_builtin(method_name): return None BEFORE
the same-class method lookup, so a call to a method named like a PHP builtin
(count/next/key — the Countable/Iterator/Serializable interface methods) was
dropped from the call graph even though the class defines it. The missing edge
survives into call_graph.json with no downstream rescue.

Remove the two premature guards so $this->count()/self::count() route to the
class-method resolver, which returns an id only when the method exists in the
class index (real builtin calls with no matching own method still resolve to
None below). The builtin filter is intentionally kept for bare func() and
string callbacks, where an unqualified name binds the global PHP builtin.

Mirrors the shadow-aware resolution already shipped in parsers/ruby.

Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com


Found by a deep reachability/call-graph validation of the parser corpus: the 2026 release fixed this bug class at some parser sites but left this sibling. Ships with a RED->GREEN regression test driving the real parser/detector pipeline (not a mock). One of a 9-PR series of independent, region-disjoint fixes; verified together (full suite green, no collisions).

🤖 Generated with Claude Code

…n name

_resolve_member_call ($this->) and _resolve_scoped_call (self::/static::/
parent::/Class::) ran `if self._is_builtin(method_name): return None` BEFORE
the same-class method lookup, so a call to a method named like a PHP builtin
(count/next/key — the Countable/Iterator/Serializable interface methods) was
dropped from the call graph even though the class defines it. The missing edge
survives into call_graph.json with no downstream rescue.

Remove the two premature guards so $this->count()/self::count() route to the
class-method resolver, which returns an id only when the method exists in the
class index (real builtin calls with no matching own method still resolve to
None below). The builtin filter is intentionally kept for bare func() and
string callbacks, where an unqualified name binds the global PHP builtin.

Mirrors the shadow-aware resolution already shipped in parsers/ruby.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@gadievron
gadievron marked this pull request as ready for review July 10, 2026 18:17
…h_builder + re-anchor test)

# Conflicts:
#	libs/openant-core/parsers/php/call_graph_builder.py
#	libs/openant-core/tests/parsers/php/test_call_graph_builder.py
@gadievron
gadievron merged commit d993f07 into master Jul 14, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant