New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
match() false-positive with treatPhpDocTypesAsCertain: false #5454
Comments
Seems like this has something to do with the number of match arms. If I remove one of the non-FP lines, one of the FP lines stops having an error: https://phpstan.org/r/15bc7c6b-d793-4e33-9cae-36f77625cc33 |
phpstan seems to have some trouble with large match statements (phpstan/phpstan#5454)
If we get rid of #3555 then this will also be fixed. |
I don't really see why #3555 should need to be fixed. This problem only arises when PhpDoc certainty is disabled. There's no uncertain types involved here anyway. If the problem is type exclusion, match arms anyway shouldn't be duplicated. |
It's the same underlying issue. If you remove this piece of code https://github.com/phpstan/phpstan-src/blob/cee6f684d0e57091435dfb03ce7d597c438fe29a/src/Type/TypeCombinator.php#L292-L300, it will start working. Feel free to try that out locally. |
I don't doubt it, I just don't understand why that issue has any bearing considering there's no unions or PhpDocs involved here. |
I managed to solve this.
Look forward to the next release (0.12.95) :) |
Awesome, thank you! |
Ref phpstan/phpstan#4793 Ref phpstan/phpstan#5062 Ref phpstan/phpstan#5447 Ref phpstan/phpstan#5454 Ref phpstan/phpstan#3366 Ref phpstan/phpstan#5072 Ref phpstan/phpstan#3530 Ref phpstan/phpstan#5530 Ref phpstan/phpstan#1861 Ref phpstan/phpstan#4843 Ref phpstan/phpstan#4602 Ref phpstan/phpstan#4499 Ref phpstan/phpstan#2142
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Bug report
Code snippet that reproduces the problem
https://phpstan.org/r/3b328b19-5f95-41a4-821b-aebd56cfc4d7
https://phpstan.org/r/6c518228-b50f-4408-8d09-42d1ae8b9e36
Expected output
No error should be reported in either case.
Did PHPStan help you today? Did it make you happy in any way?
It caught some bugs in code I wrote today that I don't have to think about anymore thanks to PHPStan. It's a great relief for my overstressed brain.
The text was updated successfully, but these errors were encountered: