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
18 changes: 9 additions & 9 deletions src/RuleSet/RuleSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand All @@ -322,7 +322,7 @@ static function () use ($declaration, $nextLevelFormat): string {
} else {
$result .= $nextLevelFormatter->spaceBetweenRules();
}
$result .= $renderedRule;
$result .= $renderedDeclaration;
}

$formatter = $outputFormat->getFormatter();
Expand Down Expand Up @@ -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)) {
Expand Down