Skip to content
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: strtotime($date) < time() is always true #5969

Closed
schlndh opened this issue Nov 10, 2021 · 5 comments
Closed

False positive: strtotime($date) < time() is always true #5969

schlndh opened this issue Nov 10, 2021 · 5 comments
Labels
Milestone

Comments

@schlndh
Copy link

schlndh commented Nov 10, 2021

Bug report

It looks like PHPStan is confused about (int|false) < int<1, max>, the fact that it's related to time functions is probably just because of the changes from 1.1.2.

Code snippet that reproduces the problem

https://phpstan.org/r/2096429c-7a1b-438a-9738-2be373692672

Expected output

No errors.

@staabm
Copy link
Contributor

staabm commented Nov 10, 2021

The actual problem is you are passing a mixed to strtotime()

@schlndh
Copy link
Author

schlndh commented Nov 10, 2021

@staabm Thanks, that explains why it works fine with the typed property. I guess that phpstan is unable to take advantage of is_string in the last case then. Even so, the (int|false) < int<1, max> part remains valid.

@phpstan-bot
Copy link
Contributor

@schlndh After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

@@ @@
-11: Comparison operation "<" between (int|false) and int<1, max> is always true.
-16: Comparison operation "<" between (int|false) and int<1, max> is always true.
+No errors

@ondrejmirtes
Copy link
Member

Fixed: phpstan/phpstan-src@dd5633f

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants