Skip to content

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

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

Closed
whataboutpereira opened this issue Nov 19, 2024 · 4 comments

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

@whataboutpereira
Copy link
Author

Oh, somehow I missed the existing #232

@ondrejmirtes
Copy link
Member

Duplicate of #232

@ondrejmirtes ondrejmirtes marked this as a duplicate of #232 Nov 25, 2024
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 Dec 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants