diff --git a/src/CSSList/CSSList.php b/src/CSSList/CSSList.php index a747e90c..5be091e6 100644 --- a/src/CSSList/CSSList.php +++ b/src/CSSList/CSSList.php @@ -69,9 +69,9 @@ public static function parseList(ParserState $parserState, CSSList $oList): void $parserState = new ParserState($parserState, Settings::create()); } $bLenientParsing = $parserState->getSettings()->bLenientParsing; - $aComments = []; + $comments = []; while (!$parserState->isEnd()) { - $aComments = \array_merge($aComments, $parserState->consumeWhiteSpace()); + $comments = \array_merge($comments, $parserState->consumeWhiteSpace()); $oListItem = null; if ($bLenientParsing) { try { @@ -87,12 +87,12 @@ public static function parseList(ParserState $parserState, CSSList $oList): void return; } if ($oListItem) { - $oListItem->addComments($aComments); + $oListItem->addComments($comments); $oList->append($oListItem); } - $aComments = $parserState->consumeWhiteSpace(); + $comments = $parserState->consumeWhiteSpace(); } - $oList->addComments($aComments); + $oList->addComments($comments); if (!$bIsRoot && !$bLenientParsing) { throw new SourceException('Unexpected end of document', $parserState->currentLine()); } diff --git a/src/OutputFormatter.php b/src/OutputFormatter.php index 6e68037f..7ef86a3c 100644 --- a/src/OutputFormatter.php +++ b/src/OutputFormatter.php @@ -178,11 +178,6 @@ public function removeLastSemicolon($sString) return \implode(';', $sString); } - /** - * @param array $aComments - * - * @return string - */ public function comments(Commentable $oCommentable): string { if (!$this->oFormat->bRenderComments) { @@ -190,10 +185,10 @@ public function comments(Commentable $oCommentable): string } $sResult = ''; - $aComments = $oCommentable->getComments(); - $iLastCommentIndex = \count($aComments) - 1; + $comments = $oCommentable->getComments(); + $iLastCommentIndex = \count($comments) - 1; - foreach ($aComments as $i => $oComment) { + foreach ($comments as $i => $oComment) { $sResult .= $oComment->render($this->oFormat); $sResult .= $i === $iLastCommentIndex ? $this->spaceAfterBlocks() : $this->spaceBetweenBlocks(); } diff --git a/src/Parsing/ParserState.php b/src/Parsing/ParserState.php index e1e98386..c14674d2 100644 --- a/src/Parsing/ParserState.php +++ b/src/Parsing/ParserState.php @@ -231,7 +231,7 @@ public function parseCharacter($bIsForIdentifier) */ public function consumeWhiteSpace(): array { - $aComments = []; + $comments = []; do { while (\preg_match('/\\s/isSu', $this->peek()) === 1) { $this->consume(1); @@ -241,16 +241,16 @@ public function consumeWhiteSpace(): array $oComment = $this->consumeComment(); } catch (UnexpectedEOFException $e) { $this->iCurrentPosition = $this->iLength; - return $aComments; + return $comments; } } else { $oComment = $this->consumeComment(); } if ($oComment !== false) { - $aComments[] = $oComment; + $comments[] = $oComment; } } while ($oComment !== false); - return $aComments; + return $comments; } /** diff --git a/src/Rule/Rule.php b/src/Rule/Rule.php index f4033468..9375cef3 100644 --- a/src/Rule/Rule.php +++ b/src/Rule/Rule.php @@ -78,13 +78,13 @@ public function __construct($sRule, $lineNumber = 0, $iColNo = 0) */ public static function parse(ParserState $parserState): Rule { - $aComments = $parserState->consumeWhiteSpace(); + $comments = $parserState->consumeWhiteSpace(); $rule = new Rule( $parserState->parseIdentifier(!$parserState->comes('--')), $parserState->currentLine(), $parserState->currentColumn() ); - $rule->setComments($aComments); + $rule->setComments($comments); $rule->addComments($parserState->consumeWhiteSpace()); $parserState->consume(':'); $oValue = Value::parseValue($parserState, self::listDelimiterForRule($rule->getRule())); diff --git a/src/RuleSet/DeclarationBlock.php b/src/RuleSet/DeclarationBlock.php index ec4b6d65..c0c26fc5 100644 --- a/src/RuleSet/DeclarationBlock.php +++ b/src/RuleSet/DeclarationBlock.php @@ -48,14 +48,14 @@ public function __construct($lineNumber = 0) */ public static function parse(ParserState $parserState, $oList = null) { - $aComments = []; + $comments = []; $oResult = new DeclarationBlock($parserState->currentLine()); try { $aSelectorParts = []; $sStringWrapperChar = false; do { $aSelectorParts[] = $parserState->consume(1) - . $parserState->consumeUntil(['{', '}', '\'', '"'], false, false, $aComments); + . $parserState->consumeUntil(['{', '}', '\'', '"'], false, false, $comments); if (\in_array($parserState->peek(), ['\'', '"'], true) && \substr(\end($aSelectorParts), -1) != '\\') { if ($sStringWrapperChar === false) { $sStringWrapperChar = $parserState->peek(); @@ -78,7 +78,7 @@ public static function parse(ParserState $parserState, $oList = null) throw $e; } } - $oResult->setComments($aComments); + $oResult->setComments($comments); RuleSet::parseRuleSet($parserState, $oResult); return $oResult; }