Closed Maurisss94 closed 5 years ago
5.7.*
is a version constraint, not a version. The Comparator class is about comparing versions.
And what class should be use, to compare constraints?
Constraints cannot directly be compared to each other as done by the Comparator class, because constraints are not ordered (saying $constraint1 > $constraint2
does not make any sense).
What are you trying to achieve exactly ?
Sure, it makes a lot of sense.
I wanted to compare both versions and constraints between two composer.json files, and pick up the package with the newest version.
I will use the equality comparer ==
, for constraints and the Comparator class for versions.
Thank you.
The only thing you could compare between constraints is their upper and lower boundaries. Comparing the constraints themselves does not make much sense as @stof said because they generally represent a range.
The only thing you could compare between constraints is their upper and lower boundaries.
even that may not always work fine, as constraints don't represent one range, but a union of ranges (due to the ||
operator)
Hi, i need to check if two versions constraints
5.7.*
are equal, and not want to do with comparator===
.But my surprirse is, when i check this line
Comparator::equalTo($this->composer['require'][$dependency], $version)
, the result is false, but the two strings are5.7.*
.Somebody can help me?