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

Greater > and Less Than < comparisons with non-numeric, non-string, non-resource types should report error #10834

Open
wants to merge 9 commits into
base: 5.x
Choose a base branch
from

Conversation

kkmuffme
Copy link
Contributor

@kkmuffme kkmuffme commented Mar 15, 2024

Fix #10833

For int|null cases the errors could be slightly annoying, however null can refer to the minimum value (PHP_INT_MIN) but is compared as 0, or it refers to a non-numeric state and shouldn't be used in comparison in the first place (similar to what RiskyTruthyFalsyComparison checks, which I guess would apply here too, but I want to keep it simple for now)

@kkmuffme kkmuffme force-pushed the greater-less-than-possibly-unexpected branch from bb40f12 to 871574e Compare March 16, 2024 10:52
@kkmuffme kkmuffme force-pushed the greater-less-than-possibly-unexpected branch 4 times, most recently from c8f3a5d to 4f5c6cb Compare March 16, 2024 12:54
@kkmuffme kkmuffme marked this pull request as ready for review March 16, 2024 12:56
@kkmuffme
Copy link
Contributor Author

@jack-worman ready to be reviewed and merged

@kkmuffme kkmuffme force-pushed the greater-less-than-possibly-unexpected branch from 4f5c6cb to 5584673 Compare March 18, 2024 22:18
@weirdan
Copy link
Collaborator

weirdan commented Mar 20, 2024

Why allow comparing resources though?

@kkmuffme
Copy link
Contributor Author

Because the docs say that that's fine, as they are converted to numbers and regular math applies: https://www.php.net/manual/en/language.operators.comparison.php#language.operators.comparison.types

@kkmuffme kkmuffme requested a review from weirdan March 23, 2024 00:10
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

Successfully merging this pull request may close these issues.

Greater > and Less Than < comparisons with non-numeric, non-string, non-resource types should report error
3 participants