Ensure multi conflict rules are only used for 3+ literals
Implements the equals method correctly on multi conflict rules. If there are fewer literals a regular Rule2Literals is enough to represent the basic conflict rule.pull/8424/head
parent
ed300b9f22
commit
dc0f2e7e46
|
@ -34,6 +34,10 @@ class MultiConflictRule extends Rule
|
||||||
{
|
{
|
||||||
parent::__construct($reason, $reasonData, $job);
|
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 all packages ascending by id
|
||||||
sort($literals);
|
sort($literals);
|
||||||
|
|
||||||
|
@ -62,8 +66,11 @@ class MultiConflictRule extends Rule
|
||||||
*/
|
*/
|
||||||
public function equals(Rule $rule)
|
public function equals(Rule $rule)
|
||||||
{
|
{
|
||||||
|
if ($rule instanceof MultiConflictRule) {
|
||||||
return $this->literals === $rule->getLiterals();
|
return $this->literals === $rule->getLiterals();
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public function isAssertion()
|
public function isAssertion()
|
||||||
{
|
{
|
||||||
|
|
|
@ -136,6 +136,10 @@ class RuleSetGenerator
|
||||||
$literals[] = -$package->id;
|
$literals[] = -$package->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (count($literals) == 2) {
|
||||||
|
return new Rule2Literals($literals[0], $literals[1], $reason, $reasonData);
|
||||||
|
}
|
||||||
|
|
||||||
return new MultiConflictRule($literals, $reason, $reasonData);
|
return new MultiConflictRule($literals, $reason, $reasonData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue