Repository navigation
fix(php): statement-anchored, one-line _dependency_capture (#3609) - #3634
Merged
Merged
Conversation
The capture started at any `require`/`include`/`use` word (bare `\b`, no
closing boundary) and ran to the next `;` across lines, so `included`,
`includes/x.php`, `'require_once'` array keys, `$required`,
`->aliasInclude(`, `d="required"` in inline HTML and English in strings all
became "imports" -- wordpress/functions.php carried 56 of them, including a
table of HTTP status strings. And `include` was tried before `include_once`,
so `include_once ABSPATH . 'x.php'` captured `_once ABSPATH . 'x.php'`.
A keyword now starts a capture only as a whole word in statement position
(line start, after `; { } = ( , @ & | )`, `return`, `else`, `echo`, `print`
or `<?php`); `require`/`include` take their `_once` suffix; the statement
stays on one line with a bounded expression and bounded trailing blanks
(ReDoS-tested). `use` imports keep their multi-line group form.
import_graph_accuracy php (guzzle): precision 99.0 -> 99.2, recall 100.
Golden masters: PHP Extracted Dependencies only (13 files: 231 junk tokens
out, 20 real include expressions in or corrected), firewall imports_unknown
10501 -> 10290, plus Composition Fit ripple. No kept `use` import changed.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YAtpBfGGyBGGovitSVaM5Q
Contributor
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.
Closes #3609.
Problem
PHP's
_dependency_capturestarted a capture at anyrequire,includeoruseword. There was a\bbefore the keyword but none after it, and the capture ran to the next;, across lines. So all of these became "imports":included,includes/x.php,$required;'require_once'used as an array key;$this->aliasInclude(...);id="required"in inline HTML;wordpress/functions.phpcarried 56 of these, including a whole table of HTTP status strings (403 => 'Forbidden'). The alternation also triedincludebeforeinclude_once, soinclude_once ABSPATH . 'x.php'was captured as_once ABSPATH . 'x.php'.Fix
;{}=(,@&|)(soif (...) require ...still counts);return,else,echo,printor<?php.requireandincludetake their_oncesuffix.useimports keep their multi-line group form (use A\{B, C};).Verification
import_graph_accuracy php(guzzle): precision 99.0% → 99.2%, recall 100%. Baseline regenerated. The 3 remaining false edges are the resolver mappingGuzzleHttp\Psr7\Utilsto guzzle's ownsrc/Utils.php; that isn't a capture problem.Extracted Dependencies, the matchingDirect Upstream Fragility, firewallimports_unknown10501 → 10290, and the Composition Fit ripple._once-prefixed ones lose their prefix, and 3require_once $plugin-style variables are newly captured.$path/$aliascame fromaliasInclude($path, $alias), and none of the changed files contains another include statement. Nouseimport changed.tests/extraction/languages/test_php.py; the php tests pass.tree_sitter_accuracy_audit --lang php --ci: OK.call_graph_accuracy --ci: OK.🤖 Generated with Claude Code
https://claude.ai/code/session_01YAtpBfGGyBGGovitSVaM5Q
Generated by Claude Code