fix(parsers/php): attribute a method-nested named function to global scope - #143
Merged
Conversation
…scope A named function declared inside a method (or function) body is a GLOBAL function in PHP, not a method of the enclosing class. The extractor keyed it as a phantom Class.<fn> (class_name preserved from the enclosing method), so the real global function was never registered and a genuine call to it lost its edge (false negative), while the phantom polluted the class namespace. In the function_definition branch, emit the unit with class_name=None (the file's namespace is still preserved) so a method-nested function is registered as the global it is. The enclosing method is unaffected. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
gadievron
force-pushed
the
fix/php-method-nested-global
branch
from
July 10, 2026 18:08
65b803d to
5be1cec
Compare
gadievron
marked this pull request as ready for review
July 10, 2026 18:17
gadievron
requested review from
dgeyshis,
shahar-davidson and
sounil
as code owners
July 10, 2026 18:17
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A named function declared inside a method (or function) body is a GLOBAL
function in PHP, not a method of the enclosing class. The extractor keyed it as
a phantom Class. (class_name preserved from the enclosing method), so the
real global function was never registered and a genuine call to it lost its
edge (false negative), while the phantom polluted the class namespace.
In the function_definition branch, emit the unit with class_name=None (the
file's namespace is still preserved) so a method-nested function is registered
as the global it is. The enclosing method is unaffected.
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