Skip to content

Commit f9424cd

Browse files
authored
[TASK] Use 'declaration' internally in RuleSet (#1525)
... in local variables and private method names, instead of the misnomered 'rule'
1 parent 81cc71e commit f9424cd

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

src/RuleSet/RuleSet.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ public static function parseRuleSet(ParserState $parserState, RuleSet $ruleSet):
5959
$parserState->consume(';');
6060
}
6161
while (true) {
62-
$commentsBeforeRule = [];
63-
$parserState->consumeWhiteSpace($commentsBeforeRule);
62+
$commentsBeforeDeclaration = [];
63+
$parserState->consumeWhiteSpace($commentsBeforeDeclaration);
6464
if ($parserState->comes('}')) {
6565
break;
6666
}
6767
$declaration = null;
6868
if ($parserState->getSettings()->usesLenientParsing()) {
6969
try {
70-
$declaration = Declaration::parse($parserState, $commentsBeforeRule);
70+
$declaration = Declaration::parse($parserState, $commentsBeforeDeclaration);
7171
} catch (UnexpectedTokenException $e) {
7272
try {
7373
$consumedText = $parserState->consumeUntil(["\n", ';', '}'], true);
@@ -85,7 +85,7 @@ public static function parseRuleSet(ParserState $parserState, RuleSet $ruleSet):
8585
}
8686
}
8787
} else {
88-
$declaration = Declaration::parse($parserState, $commentsBeforeRule);
88+
$declaration = Declaration::parse($parserState, $commentsBeforeDeclaration);
8989
}
9090
if ($declaration instanceof Declaration) {
9191
$ruleSet->addRule($declaration);
@@ -115,7 +115,7 @@ public function addRule(Declaration $declarationToAdd, ?Declaration $sibling = n
115115
$siblingIsInSet = true;
116116
$position = $siblingPosition;
117117
} else {
118-
$siblingIsInSet = $this->hasRule($sibling);
118+
$siblingIsInSet = $this->hasDeclaration($sibling);
119119
if ($siblingIsInSet) {
120120
// Maintain ordering within `$this->declarations[$propertyName]`
121121
// by inserting before first `Declaration` with a same-or-later position than the sibling.
@@ -311,12 +311,12 @@ protected function renderRules(OutputFormat $outputFormat): string
311311
$nextLevelFormat = $outputFormat->nextLevel();
312312
foreach ($this->getRules() as $declaration) {
313313
$nextLevelFormatter = $nextLevelFormat->getFormatter();
314-
$renderedRule = $nextLevelFormatter->safely(
314+
$renderedDeclaration = $nextLevelFormatter->safely(
315315
static function () use ($declaration, $nextLevelFormat): string {
316316
return $declaration->render($nextLevelFormat);
317317
}
318318
);
319-
if ($renderedRule === null) {
319+
if ($renderedDeclaration === null) {
320320
continue;
321321
}
322322
if ($isFirst) {
@@ -325,7 +325,7 @@ static function () use ($declaration, $nextLevelFormat): string {
325325
} else {
326326
$result .= $nextLevelFormatter->spaceBetweenRules();
327327
}
328-
$result .= $renderedRule;
328+
$result .= $renderedDeclaration;
329329
}
330330

331331
$formatter = $outputFormat->getFormatter();
@@ -378,7 +378,7 @@ private static function comparePositionable(Positionable $first, Positionable $s
378378
return $firstsLineNumber - $secondsLineNumber;
379379
}
380380

381-
private function hasRule(Declaration $declaration): bool
381+
private function hasDeclaration(Declaration $declaration): bool
382382
{
383383
foreach ($this->declarations as $declarationsForAProperty) {
384384
if (\in_array($declaration, $declarationsForAProperty, true)) {

0 commit comments

Comments
 (0)