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
Throw in short closure false-positive #7890
Comments
Why would you write this? |
A callback that needs to exist because of architecture but throws an IntentionallyNotImplementedException because it should never be executed. |
Interesting fact: |
@enumag After the latest push in 1.11.x, PHPStan now reports different result with your code snippet: @@ @@
-PHP 8.0 – 8.2 (1 error)
+PHP 8.0 – 8.2
==========
-3: Anonymous function should never return but return statement found.
+No errors
-PHP 7.4 (2 errors)
+PHP 7.4 (1 error)
==========
-3: Anonymous function should never return but return statement found.
3: Throw expression is supported only on PHP 8.0 and later.
PHP 7.1 – 7.3 (2 errors) Full reportPHP 8.0 – 8.2No errors PHP 7.4 (1 error)
PHP 7.1 – 7.3 (2 errors)
|
Fixed: phpstan/phpstan-src@758e5f1 |
ty! |
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. |
https://phpstan.org/r/32d2c030-666b-4e37-94bf-2f82ca9ce28f
Considering that throw is now an expression I think this should be considered valid. Code works perfectly fine in newer versions of PHP.
The text was updated successfully, but these errors were encountered: