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
Missing potential false on DateTime::modify #4927
Comments
Hello, ran into this issue as well on version 1.5.2 |
This can be fixed by changing this line https://github.com/phpstan/phpstan-src/blob/1.6.x/resources/functionMap.php#L1607 But having an error because |
Will be fixed by phpstan/phpstan-src#1267 |
@yann-eugone After the latest commit in 1.7.x, PHPStan now reports different result with your code snippet: @@ @@
-3: Strict comparison using === between DateTimeImmutable and false will always evaluate to false.
-6: Strict comparison using === between DateTime and false will always evaluate to false.
+No errors |
Fixed: phpstan/phpstan-src#1267 |
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
Both
DateTime::modify
&DateTimeImmutable::modify
can returnfalse
, but got following message when testing result :I found #1934 which is about almost the same thing, but somehow the issue get closed.
Code snippet that reproduces the problem
https://phpstan.org/r/3b587421-aa5b-4c3f-ac48-7b5c20e1d61c
https://3v4l.org/sTN7A
Expected output
These 2 methods should consider that the return type is potentially false, as documented here :
DateTime::modify
: https://www.php.net/manual/en/datetime.modify.php#refsect1-datetime.modify-returnvaluesDateTimeImmutable::modify
: https://www.php.net/manual/en/datetimeimmutable.modify.php#refsect1-datetimeimmutable.modify-returnvaluesThe text was updated successfully, but these errors were encountered: