Extract statement handling from NodeScopeResolver into StmtHandler classes - #6247
Merged
Merged
Conversation
Statement processing moves out of NodeScopeResolver's processStmtNode if-chain into per-statement StmtHandler classes, dispatched through StmtHandlerRegistry (memoized by statement class, mirroring ExprHandlerRegistry). Overriding @throws points are applied centrally by the dispatcher, so handlers return their computed throw points plainly. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GnwgpaeUXRkgSDyg95tfK8
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GnwgpaeUXRkgSDyg95tfK8
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GnwgpaeUXRkgSDyg95tfK8
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GnwgpaeUXRkgSDyg95tfK8
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GnwgpaeUXRkgSDyg95tfK8
PhpClassReflectionExtension no longer needs the whole NodeScopeResolver - it injects the PhpDocsResolver it actually uses. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GnwgpaeUXRkgSDyg95tfK8
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GnwgpaeUXRkgSDyg95tfK8
ondrejmirtes
force-pushed
the
stmt-handler
branch
from
August 23, 2026 17:21
f636003 to
7dd6382
Compare
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.
Extracts per-statement analysis out of
NodeScopeResolverinto dedicatedStmtHandlerclasses, mirroring the existingExprHandlerarchitecture. Pure code move — every moved line comes fromNodeScopeResolververbatim (modulo the mechanical transforms below); analysis output is unchanged.What's in here
Commit 1 — Introduce StmtHandler
StmtHandlerinterface (#[ExtensionInterface(tag: 'phpstan.stmtHandler')],@template T of Stmt) +StmtHandlerRegistry(per-container resolution memoized by statement class).src/Analyser/StmtHandler/(If, Foreach, For, While, DoWhile, Switch, TryCatch, Return, Expression, Echo, Unset, ClassLike, ClassMethod, Function, Property, TraitUse, …).NodeScopeResolver::processStmtNode()becomes a dispatcher;NodeScopeResolvershrinks from ~5800 to ~3200 lines.$this->x(...)→$nodeScopeResolver->x(...)for NSR APIs (NSR is passed toprocessStmt()), constructor state read through accessors, plain services injected into handler constructors.$overridingThrowPointsis now applied centrally by the dispatcher instead of per statement branch.Commits 2–7 — service extractions
Non-
@apipublicNodeScopeResolvermethods used only by handlers move into their own#[AutowiredService]classes, together with their private dependencies:PropertyHookThrowPointsResolver,VarAnnotationProcessor,CalledMethodProcessor(takes the called-method stack/results state with it),PropertyHooksProcessor,PhpDocsResolver(PhpClassReflectionExtensionnow injects it instead of the wholeNodeScopeResolver),DeprecatedAttributeResolver.🤖 Generated with Claude Code
https://claude.ai/code/session_01GnwgpaeUXRkgSDyg95tfK8