Skip to content

Faster IntersectionType->getFiniteTypes()#4746

Merged
ondrejmirtes merged 3 commits intophpstan:2.1.xfrom
staabm:fast-inf
Jan 12, 2026
Merged

Faster IntersectionType->getFiniteTypes()#4746
ondrejmirtes merged 3 commits intophpstan:2.1.xfrom
staabm:fast-inf

Conversation

@staabm
Copy link
Copy Markdown
Contributor

@staabm staabm commented Jan 12, 2026

make large enum analysis faster


requires #4744


the repro from phpstan/phpstan#11968

before this PR: 32.32 seconds
after this PR: 8.57 seconds

@staabm staabm marked this pull request as ready for review January 12, 2026 08:28
@phpstan-bot
Copy link
Copy Markdown
Collaborator

This pull request has been marked as ready for review.

Comment on lines +1348 to +1351
if ($finiteType instanceof EnumCaseObjectType) {
$oneType[$finiteType->getClassName() . '::' . $finiteType->getEnumCaseName()] = $finiteType;
continue;
}
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.

using the same type description as in

$oneType[$enumCase->getClassName() . '::' . $enumCase->getEnumCaseName()] = $enumCase;

@ondrejmirtes ondrejmirtes merged commit 6373c84 into phpstan:2.1.x Jan 12, 2026
339 of 346 checks passed
@ondrejmirtes
Copy link
Copy Markdown
Member

Thank you!

@staabm staabm deleted the fast-inf branch January 12, 2026 08:43
@staabm
Copy link
Copy Markdown
Contributor Author

staabm commented Jan 14, 2026

@ondrejmirtes since the repro from phpstan/phpstan#11968 is now below 9 seconds, it might be worth adding it as a AnalyserIntegrationTest (before we only had a stripped down version of it in the test-suite, because the original case was still too slow with 49 seconds)

wdyt?

@ondrejmirtes
Copy link
Copy Markdown
Member

I feel like in the longterm, we need a different approach to performance tests, not just shove them into AnalyserIntegrationTest. I don't want to slow down the main test suite because of them, I think that fixing bugs != performance work. I think that out of those 200 tests in AnalyserIntegrationTest, we should pick the ones about performance and have a separate job for them in GitHub Actions, maybe with phpbench, that would reliably detect when it gets slower.

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.

3 participants