Repository navigation
Fix Intervals::isSubsetOf() returning false for < 0.0.0 - #192
Merged
Merged
Conversation
…sion A constraint like `< 0.0.0` (normalized to `< 0.0.0.0-dev`) produced the invalid interval `>= 0.0.0.0-dev - < 0.0.0.0-dev` from get(), whereas the multi-constraint path already filters such intervals out. The interval counts compared in isSubsetOf() then differed, so the constraint was not considered a subset of itself (or of anything else). Return no numeric interval for it instead, matching how empty intervals are represented elsewhere. Fixes composer#191 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Seldaek
reviewed
Oct 5, 2026
Member
|
Thanks! |
This file contains hidden or 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
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.
What
Intervals::isSubsetOf($x, $x)returnedfalsefor$x = < 0.0.0. Since< 0.0.0matches nothing, it should be a subset of any constraint, like the existing< dev-foocase.Why
< 0.0.0normalizes to< 0.0.0.0-dev, andgenerateSingleConstraintIntervals()turned it into the invalid interval>= 0.0.0.0-dev - < 0.0.0.0-dev.generateIntervals()already filters out such>= x - < xintervals.isSubsetOf(), the intersection had 0 numeric intervals while the candidate had 1, and the count comparison failed.How
For a
<constraint on the lowest version (the version ofInterval::fromZero()), return an empty numeric interval list with no dev branches, instead of the invalid interval. This follows:get()convention: "if the returned numeric array is empty it means the constraint matches nothing in the numeric range";>= x - < xcheck already used by the multi-constraint path.An alternative would be to handle this only inside
isSubsetOf(), butget()would then still return an interval that can never match. I fixed it where the interval is generated. Happy to switch if you prefer.How tested
SubsetsTest:< 0.0.0is a subset of< 0.0.0and of^1.0.IntervalsTest:get('< 0.0.0')returns no numeric interval.haveIntersections()andcompactConstraint()return the same results for this input as before.Fixes #191
AI disclosure: this change was prepared with the help of Claude Code and reviewed by me.
🤖 Generated with Claude Code