Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[CLEANUP] Improve a parameter name in RuleSet::addRule()
  • Loading branch information
oliverklee committed Feb 28, 2025
commit f8ed3f3b5c8119a8ef1bbd4b07429bc7756e67ab
12 changes: 6 additions & 6 deletions src/RuleSet/RuleSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -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] = [];
}
Expand All @@ -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]);
}

/**
Expand Down