Fix slow analysis on return with a big OR condition#5053
Fix slow analysis on return with a big OR condition#5053staabm wants to merge 6 commits intophpstan:2.1.xfrom
Conversation
|
You've opened the pull request against the latest branch 2.2.x. PHPStan 2.2 is not going to be released for months. If your code is relevant on 2.1.x and you want it to be released sooner, please rebase your pull request and change its target to 2.1.x. |
|
This pull request has been marked as ready for review. |
|
what I like about this fix
what I don't like about this fix
|
|
the issue-bot result seems outdated, as I get the same diff when I open the playground link and click "Show the latest result" (so the diff the bot reports with this PR, is already on 2.1.x) |
src/Analyser/SpecifiedTypes.php
Outdated
| continue; | ||
| } | ||
|
|
||
| if ($type instanceof UnionType && count($type->getTypes()) >= self::MAX_SURE_NOT_TYPES) { |
There was a problem hiding this comment.
I'd limit the sureTypes the same way, just to be consistent and find possible issues with this approach
There was a problem hiding this comment.
so you mean we should generalize a sure-type when this limit is hit?
not beeing precise about what we not know has less impact on the overall analysis as generalizing what we know though.
There was a problem hiding this comment.
I just meant to copy:
if ($type instanceof UnionType && count($type->getTypes()) >= self::MAX_SURE_NOT_TYPES) {
continue;
}in the foreach ($this->sureTypes... above.
There was a problem hiding this comment.
ok - did just that. I don't understand why so ;-)
There was a problem hiding this comment.
The two arrays have the same importance. I feel like what we do to one we should do to the other.
If some tests start failing, it means the fix is wrong for both sureTypes and sureNotTypes.
|
Superseded by #5076 |
Closes phpstan/phpstan#14207
Regression test before PR:
After PR (equal fast as
AnalyserIntegrationTeston 2.1.x):Wordpress
phpstan analyse --debug src/wp-includes/html-api/class-wp-html-processor.php -vbefore PR:after PR: