Skip to content

Name the node types DataProviderDataRule wants - #333

Merged
ondrejmirtes merged 1 commit into
2.1.xfrom
rule-multiple-node-types
Sep 22, 2026
Merged

ondrejmirtes merged 1 commit into
2.1.xfrom
rule-multiple-node-types

Conversation

@ondrejmirtes

Copy link
Copy Markdown
Member

Follow-up to phpstan/phpstan-src#6540, which added MultipleNodeTypesRule.

DataProviderDataRule looks at what a data provider returns or yields, so it needs Stmt\Return_, Expr\Yield_ and Expr\YieldFrom. Those share no ancestor of their own, so the rule registered for Node and rejected everything else in processNode() — 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() stays Node, so processNode()'s parameter type is unchanged.

Tests, lint and cs pass. make phpstan reports 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 about Parameter #1 $args of static method, 3 about foreach.valueOverwrite).

🤖 Generated with Claude Code

https://claude.ai/code/session_01QL6WG3TUaXc6ggSoDLdorG

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
ondrejmirtes force-pushed the rule-multiple-node-types branch from bc751d0 to 53ebf2b Compare September 22, 2026 19:46
@ondrejmirtes
ondrejmirtes merged commit ba569da into 2.1.x Sep 22, 2026
90 of 91 checks passed
@ondrejmirtes
ondrejmirtes deleted the rule-multiple-node-types branch September 22, 2026 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant