Take SymbolExtractor's declarations from the scanner - #418
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #418 +/- ##
============================================
- Coverage 98.62% 98.61% -0.02%
+ Complexity 1814 1805 -9
============================================
Files 128 128
Lines 4571 4534 -37
============================================
- Hits 4508 4471 -37
Misses 63 63 ☔ View full report in Codecov by Harness. |
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.
SymbolExtractorwalked the AST itself to decide what a file declares, while every other consumer askedDeclarationScanner. Two opinions about the same question is how afunction_exists-guarded polyfill came to resolve on hover while being invisible to completion (SC.5), and how itsclass_existstwin dropped out of open-document lookup (SC.9). This is the last of those insrc/, so no consumer can now disagree about what a file declares.Slice SC.3. Plan step: 0002 Step 3a teardown. RFC 1 §4.2, §8.1.
What changed
SymbolExtractorno longer extendsNodeVisitorAbstractor builds aNodeTraverser. It readsDeclarationScanner's class-likes and functions, and takes each class-like's methods fromClassLike::getMethods()on the node the scanner already hands back.Deleted with it: the hand-tracked
$namespacefield, theStmt\Namespace_branch, theleaveNodereset, and the three places an FQN was rebuilt by string concatenation against anamespacedNamethe parser had already computed.The one thing added is a sort. The scanner returns class-likes and functions as separate lists, and callers read
$symbols[0]as the file's first declaration, so the output is ordered by position rather than by kind.Behaviour
Preserved, and proven by tests that already existed rather than new ones:
WritePathParityTestandPrefixSearchParityTestboth drive a realSymbolExtractorand passed without regenerating a golden, alongsideSymbolExtractorTest's per-kind cases.One latent bug goes away as a side effect.
leaveNodereset the current class tonullrather than to the enclosing one, so after a nested class-like closed, the outer class's remaining methods stopped being indexed. Methods now come from each class-like's own node, so nesting cannot drop them.Baseline
phpstan-baseline.neon43 → 39. The four drained are exactly this file's frozen AST-traversal violations;bin/check-baseline-shrinkrecords the shrink. The confinement rule inphpstan.neonwas already enforcing this — the entries were what kept it quiet.Checklist
SymbolExtractorno longer referencesNodeVisitorAbstract,NodeTraverserorNodeFinderClass::methodFQN strings unchanged, pinned by the existing testsNotes
Two manifest rows are now wrong and neither is edited here, to keep this diff to one file. SC.3's own note says
Class::methodFQNs "are its own and stay", which read as blocking —getMethods()is the route it missed. SC.10 is filed as "the invariant has no mechanism";phpstan.neonhas enforced it all along, so that row has no work in it.Candidate closes (pending review verification): none.