Skip to content

Fix PHP CALL extraction: add support for method, static, and unqualified function calls #297#298

Open
Bakul2006 wants to merge 1 commit intotirth8205:mainfrom
Bakul2006:PHP_Call
Open

Fix PHP CALL extraction: add support for method, static, and unqualified function calls #297#298
Bakul2006 wants to merge 1 commit intotirth8205:mainfrom
Bakul2006:PHP_Call

Conversation

@Bakul2006
Copy link
Copy Markdown

Root cause: PHP node child-type mismatch in _get_call_name.
Fix: PHP-specific handling + scoped/nullsafe node coverage + regression tests.
Addressing the issue #297 and #273

Changes
Expanded PHP call node coverage in parser call node configuration.
Added PHP-specific call-name extraction logic

@kojiromike
Copy link
Copy Markdown

kojiromike commented Apr 16, 2026

Tested this PR locally against OpenEMR (4,770 files, a large PHP codebase). Results are dramatic:

Metric main PR #298
PHP CALLS edges 58 145,423
Total graph edges 156,005 304,632

Spot-checking the top targets shows real PHP patterns now resolve correctly — method calls (addChild, text, get, saveXML), static calls (OEGlobalsBag::getInstance), framework/test calls (assertEquals, assertSame), and OpenEMR-specific globals (sqlQuery, sqlStatement, xl, xlt).

Sample blast-radius query on sqlStatement now returns real callers with correct file paths and line numbers — e.g. C_Document.view_action at multiple sites, C_PatientFinder.search_by_FullName, etc. Pre-PR this returned nothing.

The scoped_call_expression handling that constructs Class::method targets is especially valuable — it's what makes OEGlobalsBag::getInstance (and many other singletons/factories across the codebase) participate in caller graphs. Also good catch on nullsafe_member_call_expression ($obj?->method()) — that's increasingly common in modern PHP.

One small observation: the _normalize_php_name helper is currently defined as a closure inside _get_call_name. If this pattern repeats for other languages (e.g. Perl/Ruby also have sigil-prefixed names in some grammars), it might be worth promoting to a module-level helper. Just a thought for a follow-up.

LGTM from an end-user perspective. Thanks for the fast turnaround.

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.

2 participants