diff --git a/src/Parsing/ParserState.php b/src/Parsing/ParserState.php index 35e495cb..000d4f98 100644 --- a/src/Parsing/ParserState.php +++ b/src/Parsing/ParserState.php @@ -424,21 +424,21 @@ public function strlen($string): int } /** - * @param int $iStart + * @param int $offset * @param int $length */ - private function substr($iStart, $length): string + private function substr($offset, $length): string { if ($length < 0) { - $length = \count($this->characters) - $iStart + $length; + $length = \count($this->characters) - $offset + $length; } - if ($iStart + $length > \count($this->characters)) { - $length = \count($this->characters) - $iStart; + if ($offset + $length > \count($this->characters)) { + $length = \count($this->characters) - $offset; } $result = ''; while ($length > 0) { - $result .= $this->characters[$iStart]; - $iStart++; + $result .= $this->characters[$offset]; + $offset++; $length--; } return $result; diff --git a/src/Value/Value.php b/src/Value/Value.php index e2082d5e..2cb6eeb4 100644 --- a/src/Value/Value.php +++ b/src/Value/Value.php @@ -78,23 +78,23 @@ public static function parseValue(ParserState $parserState, array $aListDelimite return $aStack[0]; } $aNewStack = []; - for ($iStartPosition = 0; $iStartPosition < $iStackLength; ++$iStartPosition) { - if ($iStartPosition === ($iStackLength - 1) || $sDelimiter !== $aStack[$iStartPosition + 1]) { - $aNewStack[] = $aStack[$iStartPosition]; + for ($offset = 0; $offset < $iStackLength; ++$offset) { + if ($offset === ($iStackLength - 1) || $sDelimiter !== $aStack[$offset + 1]) { + $aNewStack[] = $aStack[$offset]; continue; } $length = 2; //Number of elements to be joined - for ($i = $iStartPosition + 3; $i < $iStackLength; $i += 2, ++$length) { + for ($i = $offset + 3; $i < $iStackLength; $i += 2, ++$length) { if ($sDelimiter !== $aStack[$i]) { break; } } $list = new RuleValueList($sDelimiter, $parserState->currentLine()); - for ($i = $iStartPosition; $i - $iStartPosition < $length * 2; $i += 2) { + for ($i = $offset; $i - $offset < $length * 2; $i += 2) { $list->addListComponent($aStack[$i]); } $aNewStack[] = $list; - $iStartPosition += $length * 2 - 2; + $offset += $length * 2 - 2; } $aStack = $aNewStack; }