Skip to content

[perf] Skip scope fetch in RemoveUnusedNonEmptyArrayBeforeForeachRector unless if-with-only-foreach - #8581

Merged
TomasVotruba merged 1 commit into
mainfrom
perf-foreach-if-cheap-guard
Oct 10, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
perf-foreach-if-cheap-guard

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

The If_ branch of refactor() fetched the PHPStan scope for every If_ node. The only structural shape the rule acts on is an if-with-only-foreach, which IfManipulator::isIfWithOnly() detects without a scope.

Hoisting that cheap check above ScopeFetcher::fetch() lets the vast majority of If_ nodes bail out before any scope resolution.

@TomasVotruba
TomasVotruba merged commit 90012de into main Oct 10, 2026
49 checks passed
@TomasVotruba
TomasVotruba deleted the perf-foreach-if-cheap-guard branch October 10, 2026 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant