Skip to content

Commit 3b7f793

Browse files
committed
Separate conditional from assignment
1 parent 459e403 commit 3b7f793

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/RuleSet/RuleSet.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,16 @@ public function addRule(Rule $ruleToAdd, ?Rule $sibling = null): void
109109
if ($siblingPosition !== false) {
110110
$siblingIsInSet = true;
111111
$position = $siblingPosition;
112-
} elseif ($siblingIsInSet = $this->hasRule($sibling)) {
113-
// Maintain ordering within `$this->rules[$propertyName]`
114-
// by inserting before first `Rule` with a same-or-later position than the sibling.
115-
foreach ($this->rules[$propertyName] as $index => $rule) {
116-
if (self::comparePositionable($rule, $sibling) >= 0) {
117-
$position = $index;
118-
break;
112+
} else {
113+
$siblingIsInSet = $this->hasRule($sibling);
114+
if ($siblingIsInSet) {
115+
// Maintain ordering within `$this->rules[$propertyName]`
116+
// by inserting before first `Rule` with a same-or-later position than the sibling.
117+
foreach ($this->rules[$propertyName] as $index => $rule) {
118+
if (self::comparePositionable($rule, $sibling) >= 0) {
119+
$position = $index;
120+
break;
121+
}
119122
}
120123
}
121124
}

0 commit comments

Comments
 (0)