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
24 changes: 12 additions & 12 deletions src/Value/Value.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct($lineNumber = 0)
}

/**
* @param array<array-key, string> $aListDelimiters
* @param array<array-key, string> $listDelimiters
*
* @return Value|string
*
Expand All @@ -41,7 +41,7 @@ public function __construct($lineNumber = 0)
*
* @internal since V8.8.0
*/
public static function parseValue(ParserState $parserState, array $aListDelimiters = [])
public static function parseValue(ParserState $parserState, array $listDelimiters = [])
{
/** @var array<int, Value|string> $stack */
$stack = [];
Expand All @@ -53,16 +53,16 @@ public static function parseValue(ParserState $parserState, array $aListDelimite
|| $parserState->isEnd())
) {
if (\count($stack) > 0) {
$bFoundDelimiter = false;
foreach ($aListDelimiters as $sDelimiter) {
if ($parserState->comes($sDelimiter)) {
\array_push($stack, $parserState->consume($sDelimiter));
$foundDelimiter = false;
foreach ($listDelimiters as $delimiter) {
if ($parserState->comes($delimiter)) {
\array_push($stack, $parserState->consume($delimiter));
$parserState->consumeWhiteSpace();
$bFoundDelimiter = true;
$foundDelimiter = true;
break;
}
}
if (!$bFoundDelimiter) {
if (!$foundDelimiter) {
//Whitespace was the list delimiter
\array_push($stack, ' ');
}
Expand All @@ -71,24 +71,24 @@ public static function parseValue(ParserState $parserState, array $aListDelimite
$parserState->consumeWhiteSpace();
}
// Convert the list to list objects
foreach ($aListDelimiters as $sDelimiter) {
foreach ($listDelimiters as $delimiter) {
$stackSize = \count($stack);
if ($stackSize === 1) {
return $stack[0];
}
$newStack = [];
for ($offset = 0; $offset < $stackSize; ++$offset) {
if ($offset === ($stackSize - 1) || $sDelimiter !== $stack[$offset + 1]) {
if ($offset === ($stackSize - 1) || $delimiter !== $stack[$offset + 1]) {
$newStack[] = $stack[$offset];
continue;
}
$length = 2; //Number of elements to be joined
for ($i = $offset + 3; $i < $stackSize; $i += 2, ++$length) {
if ($sDelimiter !== $stack[$i]) {
if ($delimiter !== $stack[$i]) {
break;
}
}
$list = new RuleValueList($sDelimiter, $parserState->currentLine());
$list = new RuleValueList($delimiter, $parserState->currentLine());
for ($i = $offset; $i - $offset < $length * 2; $i += 2) {
$list->addListComponent($stack[$i]);
}
Expand Down