From d5681270d1766838266093eecec3817c0a1db820 Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Wed, 26 Feb 2025 11:26:32 +0100 Subject: [PATCH] [CLEANUP] Avoid Hungarian notation in `RuleSet` Part of #756 --- src/RuleSet/RuleSet.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/RuleSet/RuleSet.php b/src/RuleSet/RuleSet.php index f0de01d8..d1e790ad 100644 --- a/src/RuleSet/RuleSet.php +++ b/src/RuleSet/RuleSet.php @@ -114,18 +114,18 @@ public function addRule(Rule $ruleToAdd, ?Rule $sibling = null): void $position = \count($this->rules[$propertyName]); if ($sibling !== null) { - $iSiblingPos = \array_search($sibling, $this->rules[$propertyName], true); - if ($iSiblingPos !== false) { - $position = $iSiblingPos; + $siblingPosition = \array_search($sibling, $this->rules[$propertyName], true); + if ($siblingPosition !== false) { + $position = $siblingPosition; $ruleToAdd->setPosition($sibling->getLineNo(), $sibling->getColNo() - 1); } } 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]; + $rulesCount = \count($rules); + if ($rulesCount > 0) { + $last = $rules[$rulesCount - 1]; $ruleToAdd->setPosition($last->getLineNo() + 1, 0); } } @@ -176,6 +176,7 @@ public function getRules($searchPattern = null) } return $first->getLineNo() - $second->getLineNo(); }); + return $result; } @@ -234,13 +235,13 @@ public function getRulesAssoc($searchPattern = null) public function removeRule($searchPattern): void { if ($searchPattern instanceof Rule) { - $propertyName = $searchPattern->getRule(); - if (!isset($this->rules[$propertyName])) { + $nameOfPropertyToRemove = $searchPattern->getRule(); + if (!isset($this->rules[$nameOfPropertyToRemove])) { return; } - foreach ($this->rules[$propertyName] as $key => $rule) { + foreach ($this->rules[$nameOfPropertyToRemove] as $key => $rule) { if ($rule === $searchPattern) { - unset($this->rules[$propertyName][$key]); + unset($this->rules[$nameOfPropertyToRemove][$key]); } } } else {