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

Bleeding edge + strict rules in v1.12.11 suggests comparing DateTime objects via strict comparison. #251

Open
whataboutpereira opened this issue Nov 19, 2024 · 1 comment

Comments

@whataboutpereira
Copy link

Bug report

Dates in DateTime objects can be compared only using the loose == operator, however when I switched bleeding edge on (on top of strict rules), phpstan started suggesting to compare DateTime objects via strict === comparison, which compares the objects themselves, instead of dates.

Code snippet that reproduces the problem

https://phpstan.org/r/2c276792-c7f0-41b1-bde7-2dc8de08adcb

Expected output

I think phpstan should not suggest strict comparison using === for DateTime and other date objects.

Did PHPStan help you today? Did it make you happy in any way?

No response

@ondrejmirtes ondrejmirtes transferred this issue from phpstan/phpstan Nov 19, 2024
@janedbal
Copy link

Just FYI there are custom rules to deny the strict comparison: https://github.com/shipmonk-rnd/phpstan-rules?tab=readme-ov-file#forbididenticalclasscomparison

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants