Skip to content

Commit

Permalink
Revert #129 to fix regression
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Feb 4, 2022
1 parent 84ce71b commit a951f61
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
12 changes: 0 additions & 12 deletions src/Constraint/MultiConstraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,18 +228,6 @@ public static function create(array $constraints, $conjunctive = true)
return $constraints[0];
}

foreach ($constraints as $k => $constraint) {
if ($constraint instanceof MatchAllConstraint) {
if (!$conjunctive) {
return new MatchAllConstraint();
}
unset($constraints[$k]);
if (1 === \count($constraints)) {
return $constraints[0];
}
}
}

$optimized = self::optimizeConstraints($constraints, $conjunctive);
if ($optimized !== null) {
list($constraints, $conjunctive) = $optimized;
Expand Down
8 changes: 4 additions & 4 deletions tests/Constraint/MultiConstraintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,16 +290,16 @@ public function testCreatesMatchAllConstraintIfNoneGiven()
$this->assertInstanceOf('Composer\Semver\Constraint\MatchAllConstraint', MultiConstraint::create(array()));
}

public function testRemovesMatchAllConstraintIfConjunctiveAndCombinedWithOtherConstraints()
public function testMatchAllConstraintWithinConjunctiveMultiConstraint()
{
$this->assertSame('[>= 2.5.0.0-dev <= 3.0.0.0-dev]', (string) MultiConstraint::create(
$this->assertSame('[>= 2.5.0.0-dev <= 3.0.0.0-dev *]', (string) MultiConstraint::create(
array(new Constraint('>=', '2.5.0.0-dev'), new Constraint('<=', '3.0.0.0-dev'), new MatchAllConstraint())
));
}

public function testCreatesMatchAllConstraintIfDisjunctiveAndCombinedWithAnotherOne()
public function testMatchAllConstraintWithinDisjunctiveMultiConstraint()
{
$this->assertInstanceOf('Composer\Semver\Constraint\MatchAllConstraint', MultiConstraint::create(
$this->assertSame('[>= 2.5.0.0-dev || *]', (string) MultiConstraint::create(
array(new Constraint('>=', '2.5.0.0-dev'), new MatchAllConstraint()), false
));
}
Expand Down

0 comments on commit a951f61

Please sign in to comment.