Name the node types DataProviderDataRule wants - #333
Merged
Merged
Conversation
It looks at what a data provider returns or yields, and registered for Node to catch Return_, Yield_ and YieldFrom - so it was called for every node in the analysed code just to reject it. PHPStan 2.3.0's MultipleNodeTypesRule lets it name the three classes instead. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QL6WG3TUaXc6ggSoDLdorG
ondrejmirtes
force-pushed
the
rule-multiple-node-types
branch
from
September 22, 2026 19:46
bc751d0 to
53ebf2b
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.
Follow-up to phpstan/phpstan-src#6540, which added
MultipleNodeTypesRule.DataProviderDataRulelooks at what a data provider returns or yields, so it needsStmt\Return_,Expr\Yield_andExpr\YieldFrom. Those share no ancestor of their own, so the rule registered forNodeand rejected everything else inprocessNode()— which meant being called for every node in the analysed code to do so: 645K calls on phpstan-src's own analysis, all but a handful returning nothing.getNodeTypes()now names the three classes.getNodeType()staysNode, soprocessNode()'s parameter type is unchanged.Tests, lint and cs pass.
make phpstanreports 5 errors, but they are pre-existing on 2.1.x — the same 5 with this change reverted, and the Build workflow is already red on the default branch (2 aboutParameter #1 $args of static method, 3 aboutforeach.valueOverwrite).🤖 Generated with Claude Code
https://claude.ai/code/session_01QL6WG3TUaXc6ggSoDLdorG