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-ignore-line
not ignoring line
#6175
Comments
Hi, a similar thing was recently fixed in 1.1.1:
But I'm aware that traits still suffer from this problem as the ignoring still works the old way in them. It will took a bit more effort to fix them too. |
Right now you can reformat the ignoring a bit and it will work: https://phpstan.org/r/3dcb41d8-d561-4df1-956e-846a60755dbd Also here's proof it works in classes as it's supposed to: https://phpstan.org/r/5abe62eb-3ccc-4263-b4c8-683620db20e3 |
Thanks for workaround! I'm aware that some related bugs were fixed, I've also checked it with class when i was trying to create minimal reproduction, it worked fine hence the repro with traits |
https://phpstan.org/r/147c59df-897d-4e3e-926b-221ec945bab3 repro from #6444/duplicate |
@mvorisek After the latest push in 1.10.x, PHPStan now reports different result with your code snippet: @@ @@
-PHP 8.0 – 8.1 (1 error)
+PHP 8.0 – 8.1 (3 errors)
==========
+19: Tip: Method A::a() always throws an exception, it should have return type "never".
+24: Tip: Method A::b() always throws an exception, it should have return type "never".
11: Parameter #2 ...$arrays of function array_merge expects array, null given.
-PHP 7.1 – 7.4 (1 error)
+PHP 7.1 – 7.4 (3 errors)
==========
+19: Tip: Method A::a() always throws an exception, it should have return type "never".
+24: Tip: Method A::b() always throws an exception, it should have return type "never".
11: Parameter #2 ...$args of function array_merge expects array, null given. Full reportPHP 8.0 – 8.1 (3 errors)
PHP 7.1 – 7.4 (3 errors)
|
@mvorisek After the latest push in 1.11.x, PHPStan now reports different result with your code snippet: @@ @@
-PHP 8.0 – 8.1 (1 error)
+PHP 8.0 – 8.1 (3 errors)
==========
+19: Tip: Method A::a() always throws an exception, it should have return type "never".
+24: Tip: Method A::b() always throws an exception, it should have return type "never".
11: Parameter #2 ...$arrays of function array_merge expects array, null given.
-PHP 7.1 – 7.4 (1 error)
+PHP 7.1 – 7.4 (4 errors)
==========
+19: Constructor of class A has a return type.
+19: Tip: Method A::a() always throws an exception, it should have return type "never".
+24: Tip: Method A::b() always throws an exception, it should have return type "never".
11: Parameter #2 ...$args of function array_merge expects array, null given. Full reportPHP 8.0 – 8.1 (3 errors)
PHP 7.1 – 7.4 (4 errors)
|
@jacekkarczmarczyk After the latest push in 1.11.x, PHPStan now reports different result with your code snippet: @@ @@
-4: Method HelloWorld2::sayHello() never returns null so it can be removed from the return type.
+No errors |
@mvorisek After the latest push in 1.11.x, PHPStan now reports different result with your code snippet: @@ @@
-PHP 8.0 – 8.1 (1 error)
+PHP 8.0 – 8.1 (2 errors)
==========
-11: Parameter #2 ...$arrays of function array_merge expects array, null given.
+19: Tip: Method A::a() always throws an exception, it should have return type "never".
+24: Tip: Method A::b() always throws an exception, it should have return type "never".
-PHP 7.1 – 7.4 (1 error)
+PHP 7.1 – 7.4 (3 errors)
==========
-11: Parameter #2 ...$args of function array_merge expects array, null given.
+19: Constructor of class A has a return type.
+19: Tip: Method A::a() always throws an exception, it should have return type "never".
+24: Tip: Method A::b() always throws an exception, it should have return type "never". Full reportPHP 8.0 – 8.1 (2 errors)
PHP 7.1 – 7.4 (3 errors)
|
@mvorisek After the latest push in 1.11.x, PHPStan now reports different result with your code snippet: @@ @@
-14: Method Model::foo() should return B but returns A.
19: Dumped type: B Full report
|
Fixed: phpstan/phpstan-src@01294d8 |
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-ignore-line
does not work in certain circumstancesCode snippet that reproduces the problem
https://phpstan.org/r/51956c1f-c771-478e-b8b7-3ce82321edc6
Code above raises
Method HelloWorld2::sayHello() never returns null so it can be removed from the return type.
errorExpected output
no error
Did PHPStan help you today? Did it make you happy in any way?
yup!
The text was updated successfully, but these errors were encountered: