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
False positive: expects int, int|null given after If condition #4177
Comments
I'd argue that both calls on lines 24 and 28 shold report an error, because of |
@ondrejmirtes Sorry, didn't catch what the problem with rand() ? |
The main problem here is that you rely on multiple calls to |
I got it. |
@oldy777 PHPStan now reports different result with your code snippet: @@ @@
-PHP 8.0 (1 error)
-==========
-
-24: Parameter #1 $timestamp of method DateTime::setTimestamp() expects int, int|null given.
-
-PHP 7.1 – 7.4 (1 error)
-==========
-
-24: Parameter #1 $unixtimestamp of method DateTime::setTimestamp() expects int, int|null given.
+24: Parameter #1 $timestamp of method DateTime::setTimestamp() expects int, int|null given. Full report
|
@oldy777 After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-PHP 8.0 (1 error)
-==========
-
-24: Parameter #1 $timestamp of method DateTime::setTimestamp() expects int, int|null given.
-
-PHP 7.1 – 7.4 (1 error)
-==========
-
-24: Parameter #1 $unixtimestamp of method DateTime::setTimestamp() expects int, int|null given.
+No errors |
Fixed: phpstan/phpstan-src@d4edc59 |
Closes phpstan/phpstan#4588 Closes phpstan/phpstan#4091 Closes phpstan/phpstan#3382 Closes phpstan/phpstan#4177 Closes phpstan/phpstan#2288 Closes phpstan/phpstan#1157
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 - PHP Static Analysis Tool 0.12.56
I get an error "expects int, int|null given" despite the fact that I checked it before
if I checking clearly !== null everything works good
Code snippet that reproduces the problem
https://phpstan.org/r/d4e9e96b-9902-4da4-a85a-ae487094aa68
Expected output "No errors"
The text was updated successfully, but these errors were encountered: