From 0aa1263af70d772385c30bab5420b5c3b1a0b837 Mon Sep 17 00:00:00 2001 From: Jake Hotson Date: Sun, 15 Feb 2026 02:29:32 +0000 Subject: [PATCH] [TASK] Use 'declaration' internally in `RuleSet` ... in local variables and private method names, instead of the misnomered 'rule' --- src/RuleSet/RuleSet.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/RuleSet/RuleSet.php b/src/RuleSet/RuleSet.php index 6be349ea..83aeba71 100644 --- a/src/RuleSet/RuleSet.php +++ b/src/RuleSet/RuleSet.php @@ -59,15 +59,15 @@ public static function parseRuleSet(ParserState $parserState, RuleSet $ruleSet): $parserState->consume(';'); } while (true) { - $commentsBeforeRule = []; - $parserState->consumeWhiteSpace($commentsBeforeRule); + $commentsBeforeDeclaration = []; + $parserState->consumeWhiteSpace($commentsBeforeDeclaration); if ($parserState->comes('}')) { break; } $declaration = null; if ($parserState->getSettings()->usesLenientParsing()) { try { - $declaration = Declaration::parse($parserState, $commentsBeforeRule); + $declaration = Declaration::parse($parserState, $commentsBeforeDeclaration); } catch (UnexpectedTokenException $e) { try { $consumedText = $parserState->consumeUntil(["\n", ';', '}'], true); @@ -85,7 +85,7 @@ public static function parseRuleSet(ParserState $parserState, RuleSet $ruleSet): } } } else { - $declaration = Declaration::parse($parserState, $commentsBeforeRule); + $declaration = Declaration::parse($parserState, $commentsBeforeDeclaration); } if ($declaration instanceof Declaration) { $ruleSet->addRule($declaration); @@ -115,7 +115,7 @@ public function addRule(Declaration $declarationToAdd, ?Declaration $sibling = n $siblingIsInSet = true; $position = $siblingPosition; } else { - $siblingIsInSet = $this->hasRule($sibling); + $siblingIsInSet = $this->hasDeclaration($sibling); if ($siblingIsInSet) { // Maintain ordering within `$this->declarations[$propertyName]` // by inserting before first `Declaration` with a same-or-later position than the sibling. @@ -308,12 +308,12 @@ protected function renderRules(OutputFormat $outputFormat): string $nextLevelFormat = $outputFormat->nextLevel(); foreach ($this->getRules() as $declaration) { $nextLevelFormatter = $nextLevelFormat->getFormatter(); - $renderedRule = $nextLevelFormatter->safely( + $renderedDeclaration = $nextLevelFormatter->safely( static function () use ($declaration, $nextLevelFormat): string { return $declaration->render($nextLevelFormat); } ); - if ($renderedRule === null) { + if ($renderedDeclaration === null) { continue; } if ($isFirst) { @@ -322,7 +322,7 @@ static function () use ($declaration, $nextLevelFormat): string { } else { $result .= $nextLevelFormatter->spaceBetweenRules(); } - $result .= $renderedRule; + $result .= $renderedDeclaration; } $formatter = $outputFormat->getFormatter(); @@ -375,7 +375,7 @@ private static function comparePositionable(Positionable $first, Positionable $s return $firstsLineNumber - $secondsLineNumber; } - private function hasRule(Declaration $declaration): bool + private function hasDeclaration(Declaration $declaration): bool { foreach ($this->declarations as $declarationsForAProperty) { if (\in_array($declaration, $declarationsForAProperty, true)) {