We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Variable assignment within is_null() doesn't take into account the result of that is_null()
is_null()
https://phpstan.org/r/a158f7de-7672-4860-a430-4beb421ae544
<?php declare(strict_types = 1); /** * @return array<mixed>|null */ function foo(){ if (rand()<.5){ return [1,2,3]; } return null; } if (!is_null($c = foo())){ echo count($c); // line 14 }
14 | Parameter #1 $value of function count expects array\|Countable, array\|null given.
No Errors!
The text was updated successfully, but these errors were encountered:
@pauljherring After the latest commit in dev-master, PHPStan now reports different result with your code snippet:
@@ @@ -PHP 8.0 (1 error) -========== - -14: Parameter #1 $value of function count expects array|Countable, array|null given. - -PHP 7.1 – 7.4 (1 error) -========== - -14: Parameter #1 $var of function count expects array|Countable, array|null given. +No errors
Sorry, something went wrong.
Fixed: phpstan/phpstan-src@b2bf703
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.
No branches or pull requests
Bug report
Variable assignment within
is_null()
doesn't take into account the result of thatis_null()
Code snippet that reproduces the problem
https://phpstan.org/r/a158f7de-7672-4860-a430-4beb421ae544
Output
Expected output
The text was updated successfully, but these errors were encountered: