diff --git a/src/Composer/DependencyResolver/MultiConflictRule.php b/src/Composer/DependencyResolver/MultiConflictRule.php index 8ec6b46c0..d564ced2e 100644 --- a/src/Composer/DependencyResolver/MultiConflictRule.php +++ b/src/Composer/DependencyResolver/MultiConflictRule.php @@ -34,6 +34,10 @@ class MultiConflictRule extends Rule { parent::__construct($reason, $reasonData, $job); + if (count($literals) < 3) { + throw new \RuntimeException("multi conflict rule requires at least 3 literals"); + } + // sort all packages ascending by id sort($literals); @@ -62,7 +66,10 @@ class MultiConflictRule extends Rule */ public function equals(Rule $rule) { - return $this->literals === $rule->getLiterals(); + if ($rule instanceof MultiConflictRule) { + return $this->literals === $rule->getLiterals(); + } + return false; } public function isAssertion() diff --git a/src/Composer/DependencyResolver/RuleSetGenerator.php b/src/Composer/DependencyResolver/RuleSetGenerator.php index aaa253bed..442be135c 100644 --- a/src/Composer/DependencyResolver/RuleSetGenerator.php +++ b/src/Composer/DependencyResolver/RuleSetGenerator.php @@ -136,6 +136,10 @@ class RuleSetGenerator $literals[] = -$package->id; } + if (count($literals) == 2) { + return new Rule2Literals($literals[0], $literals[1], $reason, $reasonData); + } + return new MultiConflictRule($literals, $reason, $reasonData); }