Skip to content

fix(parsers/php): attribute a method-nested named function to global scope - #143

Merged
gadievron merged 1 commit into
masterfrom
fix/php-method-nested-global
Jul 14, 2026
Merged

fix(parsers/php): attribute a method-nested named function to global scope#143
gadievron merged 1 commit into
masterfrom
fix/php-method-nested-global

Conversation

@gadievron

Copy link
Copy Markdown
Collaborator

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

…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
gadievron force-pushed the fix/php-method-nested-global branch from 65b803d to 5be1cec Compare July 10, 2026 18:08
@gadievron
gadievron marked this pull request as ready for review July 10, 2026 18:17
@gadievron
gadievron merged commit 8f915b5 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