Fix PHP CALL extraction: add support for method, static, and unqualified function calls #297#298
Conversation
|
Tested this PR locally against OpenEMR (4,770 files, a large PHP codebase). Results are dramatic:
Spot-checking the top targets shows real PHP patterns now resolve correctly — method calls ( Sample blast-radius query on The One small observation: the LGTM from an end-user perspective. Thanks for the fast turnaround. |
After rebase onto upstream/main: - `test_finds_static_calls`: upstream tirth8205#298 keeps `::` as the static-call separator instead of normalizing to `.`, so assert on `User::find`. - Add `test_finds_calls_comprehensive` covering plain/member/nullsafe/ scoped/global-namespaced extraction (the test upstream tirth8205#298 introduced in TestPHPParsing — rebase placed it inside TestBladeParsing by accident, where `sqlQuery`/`xl`/`text` aren't present in the Blade fixture). - Remove unused `sources` local in `test_finds_inheritance` (F841).
After rebase onto upstream/main: - `test_finds_static_calls`: upstream tirth8205#298 keeps `::` as the static-call separator instead of normalizing to `.`, so assert on `User::find`. - Add `test_finds_calls_comprehensive` covering plain/member/nullsafe/ scoped/global-namespaced extraction (the test upstream tirth8205#298 introduced in TestPHPParsing — rebase placed it inside TestBladeParsing by accident, where `sqlQuery`/`xl`/`text` aren't present in the Blade fixture). - Remove unused `sources` local in `test_finds_inheritance` (F841).
Codex review flagged two PHP blocks in `_get_call_name()` after the rebase: upstream tirth8205#298's block (function/member/nullsafe/scoped) runs first and returns, making the later feat-branch block unreachable for those node types. The two blocks also disagreed on scoped-call formatting (`::` vs `.`), which is exactly the sort of latent rebase hazard that would bite the next editor. - Merge the only live arm (`object_creation_expression`) into the upstream block with consistent `_normalize_php_name` handling. - Delete the shadowed/duplicated PHP block entirely.
After rebase onto upstream/main: - `test_finds_static_calls`: upstream tirth8205#298 keeps `::` as the static-call separator instead of normalizing to `.`, so assert on `User::find`. - Add `test_finds_calls_comprehensive` covering plain/member/nullsafe/ scoped/global-namespaced extraction (the test upstream tirth8205#298 introduced in TestPHPParsing — rebase placed it inside TestBladeParsing by accident, where `sqlQuery`/`xl`/`text` aren't present in the Blade fixture). - Remove unused `sources` local in `test_finds_inheritance` (F841).
Codex review flagged two PHP blocks in `_get_call_name()` after the rebase: upstream tirth8205#298's block (function/member/nullsafe/scoped) runs first and returns, making the later feat-branch block unreachable for those node types. The two blocks also disagreed on scoped-call formatting (`::` vs `.`), which is exactly the sort of latent rebase hazard that would bite the next editor. - Merge the only live arm (`object_creation_expression`) into the upstream block with consistent `_normalize_php_name` handling. - Delete the shadowed/duplicated PHP block entirely.
After rebase onto upstream/main: - `test_finds_static_calls`: upstream tirth8205#298 keeps `::` as the static-call separator instead of normalizing to `.`, so assert on `User::find`. - Add `test_finds_calls_comprehensive` covering plain/member/nullsafe/ scoped/global-namespaced extraction (the test upstream tirth8205#298 introduced in TestPHPParsing — rebase placed it inside TestBladeParsing by accident, where `sqlQuery`/`xl`/`text` aren't present in the Blade fixture). - Remove unused `sources` local in `test_finds_inheritance` (F841).
Codex review flagged two PHP blocks in `_get_call_name()` after the rebase: upstream tirth8205#298's block (function/member/nullsafe/scoped) runs first and returns, making the later feat-branch block unreachable for those node types. The two blocks also disagreed on scoped-call formatting (`::` vs `.`), which is exactly the sort of latent rebase hazard that would bite the next editor. - Merge the only live arm (`object_creation_expression`) into the upstream block with consistent `_normalize_php_name` handling. - Delete the shadowed/duplicated PHP block entirely.
After rebase onto upstream/main: - `test_finds_static_calls`: upstream tirth8205#298 keeps `::` as the static-call separator instead of normalizing to `.`, so assert on `User::find`. - Add `test_finds_calls_comprehensive` covering plain/member/nullsafe/ scoped/global-namespaced extraction (the test upstream tirth8205#298 introduced in TestPHPParsing — rebase placed it inside TestBladeParsing by accident, where `sqlQuery`/`xl`/`text` aren't present in the Blade fixture). - Remove unused `sources` local in `test_finds_inheritance` (F841).
Codex review flagged two PHP blocks in `_get_call_name()` after the rebase: upstream tirth8205#298's block (function/member/nullsafe/scoped) runs first and returns, making the later feat-branch block unreachable for those node types. The two blocks also disagreed on scoped-call formatting (`::` vs `.`), which is exactly the sort of latent rebase hazard that would bite the next editor. - Merge the only live arm (`object_creation_expression`) into the upstream block with consistent `_normalize_php_name` handling. - Delete the shadowed/duplicated PHP block entirely.
…alls (tirth8205#298) (cherry picked from commit d660e02)
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