Get rid of continue 2; and use array_filter instead of manual looping
parent
451bab1c2c
commit
a395bc04d7
|
@ -57,15 +57,16 @@ class RuleWatchGraph
|
||||||
if (!$node->getRule()->isDisabled() && !call_user_func($skipCallback, $otherWatch)) {
|
if (!$node->getRule()->isDisabled() && !call_user_func($skipCallback, $otherWatch)) {
|
||||||
$ruleLiterals = $node->getRule()->getLiterals();
|
$ruleLiterals = $node->getRule()->getLiterals();
|
||||||
|
|
||||||
foreach ($ruleLiterals as $ruleLiteral) {
|
$alternativeLiterals = array_filter($ruleLiterals, function ($ruleLiteral) use ($literal, $otherWatch, $conflictCallback) {
|
||||||
if ($literal !== $ruleLiteral &&
|
return $literal !== $ruleLiteral &&
|
||||||
$otherWatch !== $ruleLiteral &&
|
$otherWatch !== $ruleLiteral &&
|
||||||
!call_user_func($conflictCallback, $ruleLiteral)) {
|
!call_user_func($conflictCallback, $ruleLiteral);
|
||||||
|
});
|
||||||
|
|
||||||
$this->moveWatch($literal, $ruleLiteral, $node);
|
if ($alternativeLiterals) {
|
||||||
|
reset($alternativeLiterals);
|
||||||
continue 2;
|
$this->moveWatch($literal, current($alternativeLiterals), $node);
|
||||||
}
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (call_user_func($conflictCallback, $otherWatch)) {
|
if (call_user_func($conflictCallback, $otherWatch)) {
|
||||||
|
|
Loading…
Reference in New Issue