Skip to content
Merged
Show file tree
Hide file tree
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
30 changes: 15 additions & 15 deletions src/CSSList/CSSList.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,37 +62,37 @@ public function __construct($lineNumber = 0)
* @throws UnexpectedTokenException
* @throws SourceException
*/
public static function parseList(ParserState $parserState, CSSList $oList): void
public static function parseList(ParserState $parserState, CSSList $list): void
{
$bIsRoot = $oList instanceof Document;
$bIsRoot = $list instanceof Document;
if (\is_string($parserState)) {
$parserState = new ParserState($parserState, Settings::create());
}
$bLenientParsing = $parserState->getSettings()->bLenientParsing;
$comments = [];
while (!$parserState->isEnd()) {
$comments = \array_merge($comments, $parserState->consumeWhiteSpace());
$oListItem = null;
$listItem = null;
if ($bLenientParsing) {
try {
$oListItem = self::parseListItem($parserState, $oList);
$listItem = self::parseListItem($parserState, $list);
} catch (UnexpectedTokenException $e) {
$oListItem = false;
$listItem = false;
}
} else {
$oListItem = self::parseListItem($parserState, $oList);
$listItem = self::parseListItem($parserState, $list);
}
if ($oListItem === null) {
if ($listItem === null) {
// List parsing finished
return;
}
if ($oListItem) {
$oListItem->addComments($comments);
$oList->append($oListItem);
if ($listItem) {
$listItem->addComments($comments);
$list->append($listItem);
}
$comments = $parserState->consumeWhiteSpace();
}
$oList->addComments($comments);
$list->addComments($comments);
if (!$bIsRoot && !$bLenientParsing) {
throw new SourceException('Unexpected end of document', $parserState->currentLine());
}
Expand All @@ -105,9 +105,9 @@ public static function parseList(ParserState $parserState, CSSList $oList): void
* @throws UnexpectedEOFException
* @throws UnexpectedTokenException
*/
private static function parseListItem(ParserState $parserState, CSSList $oList)
private static function parseListItem(ParserState $parserState, CSSList $list)
{
$bIsRoot = $oList instanceof Document;
$bIsRoot = $list instanceof Document;
if ($parserState->comes('@')) {
$oAtRule = self::parseAtRule($parserState);
if ($oAtRule instanceof Charset) {
Expand All @@ -119,7 +119,7 @@ private static function parseListItem(ParserState $parserState, CSSList $oList)
$parserState->currentLine()
);
}
if (\count($oList->getContents()) > 0) {
if (\count($list->getContents()) > 0) {
throw new UnexpectedTokenException(
'@charset must be the first parseable token in a document',
'',
Expand All @@ -142,7 +142,7 @@ private static function parseListItem(ParserState $parserState, CSSList $oList)
return null;
}
} else {
return DeclarationBlock::parse($parserState, $oList);
return DeclarationBlock::parse($parserState, $list);
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/RuleSet/DeclarationBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ public function __construct($lineNumber = 0)
}

/**
* @param CSSList|null $oList
* @param CSSList|null $list
*
* @return DeclarationBlock|false
*
* @throws UnexpectedTokenException
* @throws UnexpectedEOFException
*/
public static function parse(ParserState $parserState, $oList = null)
public static function parse(ParserState $parserState, $list = null)
{
$comments = [];
$oResult = new DeclarationBlock($parserState->currentLine());
Expand All @@ -64,7 +64,7 @@ public static function parse(ParserState $parserState, $oList = null)
}
}
} while (!\in_array($parserState->peek(), ['{', '}'], true) || $sStringWrapperChar !== false);
$oResult->setSelectors(\implode('', $aSelectorParts), $oList);
$oResult->setSelectors(\implode('', $aSelectorParts), $list);
if ($parserState->comes('{')) {
$parserState->consume(1);
}
Expand All @@ -85,11 +85,11 @@ public static function parse(ParserState $parserState, $oList = null)

/**
* @param array<int, Selector|string>|string $mSelector
* @param CSSList|null $oList
* @param CSSList|null $list
*
* @throws UnexpectedTokenException
*/
public function setSelectors($mSelector, $oList = null): void
public function setSelectors($mSelector, $list = null): void
{
if (\is_array($mSelector)) {
$this->aSelectors = $mSelector;
Expand All @@ -98,7 +98,7 @@ public function setSelectors($mSelector, $oList = null): void
}
foreach ($this->aSelectors as $iKey => $mSelector) {
if (!($mSelector instanceof Selector)) {
if ($oList === null || !($oList instanceof KeyFrame)) {
if ($list === null || !($list instanceof KeyFrame)) {
if (!Selector::isValid($mSelector)) {
throw new UnexpectedTokenException(
"Selector did not match '" . Selector::SELECTOR_VALIDATION_RX . "'.",
Expand Down
6 changes: 3 additions & 3 deletions src/Value/CalcFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static function parse(ParserState $parserState, bool $bIgnoreCase = false
}
$parserState->consume('(');
$oCalcList = new CalcRuleValueList($parserState->currentLine());
$oList = new RuleValueList(',', $parserState->currentLine());
$list = new RuleValueList(',', $parserState->currentLine());
$iNestingLevel = 0;
$iLastComponentType = null;
while (!$parserState->comes(')') || $iNestingLevel > 0) {
Expand Down Expand Up @@ -94,10 +94,10 @@ public static function parse(ParserState $parserState, bool $bIgnoreCase = false
}
$parserState->consumeWhiteSpace();
}
$oList->addListComponent($oCalcList);
$list->addListComponent($oCalcList);
if (!$parserState->isEnd()) {
$parserState->consume(')');
}
return new CalcFunction($sFunction, $oList, ',', $parserState->currentLine());
return new CalcFunction($sFunction, $list, ',', $parserState->currentLine());
}
}
6 changes: 3 additions & 3 deletions src/Value/Value.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ public static function parseValue(ParserState $parserState, array $aListDelimite
break;
}
}
$oList = new RuleValueList($sDelimiter, $parserState->currentLine());
$list = new RuleValueList($sDelimiter, $parserState->currentLine());
for ($i = $iStartPosition; $i - $iStartPosition < $iLength * 2; $i += 2) {
$oList->addListComponent($aStack[$i]);
$list->addListComponent($aStack[$i]);
}
$aNewStack[] = $oList;
$aNewStack[] = $list;
$iStartPosition += $iLength * 2 - 2;
}
$aStack = $aNewStack;
Expand Down