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
PHPStan does not expect an exception in method call in a try block. #4879
Comments
Why it currently doesn't work: PHPStan differentiates between explicit throw points ("throw" keyword, function calls that have But I found out that the analysis works best if the explicit throw points have priority. My thinking is that if that if you throw something explicitly, then all the throw points in the try block should be explicit. See the following examples that work correctly:
I'll fix your example for the Throwable catch block. Analysis of more specific catch blocks will not be changed. |
Hi, I have a similar problem which is difficult for me to solve. We often on entities call "get" methods after exception to get an identifier, see .. https://phpstan.org/r/995e1b4f-bdd6-4c7b-84aa-42ecfd51760d |
Fixed: phpstan/phpstan-src@54a204e |
Thanks! |
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
PHPStan does not expect an exception in method call in a try block. In the code snippet below, PHPStan should expect that the "test" method call can throw an exception.
Code snippet that reproduces the problem
https://phpstan.org/r/9e470be5-ea3b-461d-9a38-7a1ca66e526b
Expected output
No errors.
The text was updated successfully, but these errors were encountered: