Skip to content

TypeCombinator: remove unnecessary iteration over types - #6194

Merged
staabm merged 1 commit into
phpstan:2.2.xfrom
staabm:less-iteration
Aug 8, 2026
Merged

TypeCombinator: remove unnecessary iteration over types#6194
staabm merged 1 commit into
phpstan:2.2.xfrom
staabm:less-iteration

Conversation

@staabm

@staabm staabm commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

drive by cleanup while looking into bug 15061

php bin/phpstan analyze bug-15061.php --debug -vv

before this PR
4.63s 4.61s 4.57s

after this PR
4.47s 4.49s 4.50s

@staabm
staabm marked this pull request as ready for review August 8, 2026 07:11
@phpstan-bot

Copy link
Copy Markdown
Collaborator

This pull request has been marked as ready for review.

Comment on lines -1673 to -1681
foreach ($types as $type) {
if (!$type instanceof UnionType) {
continue;
}
$unionTypesCount++;
if ($unionTypesCount >= 2) {
break;
}
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merges this loop into the above one so we don't need to run thru all types another time

@staabm
staabm merged commit 03fb80d into phpstan:2.2.x Aug 8, 2026
1119 of 1124 checks passed
@staabm
staabm deleted the less-iteration branch August 8, 2026 07:34
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.

2 participants