diff --git a/src/RuleSet/RuleSet.php b/src/RuleSet/RuleSet.php index 27750dcf..6e3b7639 100644 --- a/src/RuleSet/RuleSet.php +++ b/src/RuleSet/RuleSet.php @@ -101,9 +101,9 @@ public function getLineNo(): int return $this->lineNumber; } - public function addRule(Rule $rule, ?Rule $sibling = null): void + public function addRule(Rule $ruleToAdd, ?Rule $sibling = null): void { - $sRule = $rule->getRule(); + $sRule = $ruleToAdd->getRule(); if (!isset($this->rules[$sRule])) { $this->rules[$sRule] = []; } @@ -114,20 +114,20 @@ public function addRule(Rule $rule, ?Rule $sibling = null): void $iSiblingPos = \array_search($sibling, $this->rules[$sRule], true); if ($iSiblingPos !== false) { $position = $iSiblingPos; - $rule->setPosition($sibling->getLineNo(), $sibling->getColNo() - 1); + $ruleToAdd->setPosition($sibling->getLineNo(), $sibling->getColNo() - 1); } } - if ($rule->getLineNo() === 0 && $rule->getColNo() === 0) { + if ($ruleToAdd->getLineNo() === 0 && $ruleToAdd->getColNo() === 0) { //this node is added manually, give it the next best line $rules = $this->getRules(); $pos = \count($rules); if ($pos > 0) { $last = $rules[$pos - 1]; - $rule->setPosition($last->getLineNo() + 1, 0); + $ruleToAdd->setPosition($last->getLineNo() + 1, 0); } } - \array_splice($this->rules[$sRule], $position, 0, [$rule]); + \array_splice($this->rules[$sRule], $position, 0, [$ruleToAdd]); } /**