improve literal inequality with ranges and rework GreaterThan/LessThan assertions #7511
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.
I'm pretty happy with this one. I started by fixing the literal inequality reconciliation that I couldn't do before when TPositiveInt was still here. However, there was snippets I expected to be fixed by this change but weren't so I went a little deeper.
I discovered that a previous PR that introduced filtering of null value through (>/</>=/<=) operators added an isset assertion in addition to the integer comparison. However, Psalm can reconcile two assertions but struggles with negation of two assertions so it made reconciliation difficult in some cases.
I reworked the entire thing, I used the new Assertions object system as well as the two new assertions (IsGreaterThanOrEqualTo/IsLessThanOrEqualTo) to have a much nicer system (that allows me to stop considering that
>=5
is>4
) and I introduced a function to know if the assertions filters the null value. That way I can use only one assertion and reconcile both.It fixes #6797
It fixes #6871
It fixes #6778
It fixes #4358