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
kkmuffme
wants to merge
9
commits into
vimeo:5.x
Choose a base branch
from
kkmuffme:greater-less-than-possibly-unexpected
base: 5.x
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Greater > and Less Than < comparisons with non-numeric, non-string, non-resource types should report error #10834
kkmuffme
wants to merge
9
commits into
vimeo:5.x
from
kkmuffme:greater-less-than-possibly-unexpected
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jack-worman
reviewed
Mar 15, 2024
src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOpAnalyzer.php
Outdated
Show resolved
Hide resolved
kkmuffme
force-pushed
the
greater-less-than-possibly-unexpected
branch
from
March 16, 2024 10:52
bb40f12
to
871574e
Compare
kkmuffme
force-pushed
the
greater-less-than-possibly-unexpected
branch
4 times, most recently
from
March 16, 2024 12:54
c8f3a5d
to
4f5c6cb
Compare
@jack-worman ready to be reviewed and merged |
jack-worman
reviewed
Mar 17, 2024
jack-worman
reviewed
Mar 17, 2024
src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOpAnalyzer.php
Outdated
Show resolved
Hide resolved
jack-worman
reviewed
Mar 17, 2024
src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOpAnalyzer.php
Outdated
Show resolved
Hide resolved
jack-worman
reviewed
Mar 17, 2024
jack-worman
reviewed
Mar 17, 2024
…lity relation leading to missing errors
kkmuffme
force-pushed
the
greater-less-than-possibly-unexpected
branch
from
March 18, 2024 22:18
4f5c6cb
to
5584673
Compare
Why allow comparing resources though? |
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 |
…on with same object type
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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)