diff --git a/src/Parsing/ParserState.php b/src/Parsing/ParserState.php index bfed3285..bf348ed6 100644 --- a/src/Parsing/ParserState.php +++ b/src/Parsing/ParserState.php @@ -49,7 +49,7 @@ class ParserState /** * @var int */ - private $iLength; + private $length; /** * @var int @@ -78,7 +78,7 @@ public function setCharset($charset): void $this->charset = $charset; $this->characters = $this->strsplit($this->text); if (\is_array($this->characters)) { - $this->iLength = \count($this->characters); + $this->length = \count($this->characters); } } @@ -233,7 +233,7 @@ public function consumeWhiteSpace(): array try { $oComment = $this->consumeComment(); } catch (UnexpectedEOFException $e) { - $this->currentPosition = $this->iLength; + $this->currentPosition = $this->length; return $comments; } } else { @@ -259,16 +259,16 @@ public function comes($sString, $bCaseInsensitive = false): bool } /** - * @param int $iLength + * @param int $length * @param int $iOffset */ - public function peek($iLength = 1, $iOffset = 0): string + public function peek($length = 1, $iOffset = 0): string { $iOffset += $this->currentPosition; - if ($iOffset >= $this->iLength) { + if ($iOffset >= $this->length) { return ''; } - return $this->substr($iOffset, $iLength); + return $this->substr($iOffset, $length); } /** @@ -281,11 +281,11 @@ public function consume($mValue = 1): string { if (\is_string($mValue)) { $iLineCount = \substr_count($mValue, "\n"); - $iLength = $this->strlen($mValue); - if (!$this->streql($this->substr($this->currentPosition, $iLength), $mValue)) { + $length = $this->strlen($mValue); + if (!$this->streql($this->substr($this->currentPosition, $length), $mValue)) { throw new UnexpectedTokenException( $mValue, - $this->peek(\max($iLength, 5)), + $this->peek(\max($length, 5)), 'literal', $this->lineNumber ); @@ -294,7 +294,7 @@ public function consume($mValue = 1): string $this->currentPosition += $this->strlen($mValue); return $mValue; } else { - if ($this->currentPosition + $mValue > $this->iLength) { + if ($this->currentPosition + $mValue > $this->length) { throw new UnexpectedEOFException((string) $mValue, $this->peek(5), 'count', $this->lineNumber); } $result = $this->substr($this->currentPosition, $mValue); @@ -351,7 +351,7 @@ public function consumeComment() public function isEnd(): bool { - return $this->currentPosition >= $this->iLength; + return $this->currentPosition >= $this->length; } /** @@ -439,21 +439,21 @@ public function strlen($sString): int /** * @param int $iStart - * @param int $iLength + * @param int $length */ - private function substr($iStart, $iLength): string + private function substr($iStart, $length): string { - if ($iLength < 0) { - $iLength = $this->iLength - $iStart + $iLength; + if ($length < 0) { + $length = $this->length - $iStart + $length; } - if ($iStart + $iLength > $this->iLength) { - $iLength = $this->iLength - $iStart; + if ($iStart + $length > $this->length) { + $length = $this->length - $iStart; } $result = ''; - while ($iLength > 0) { + while ($length > 0) { $result .= $this->characters[$iStart]; $iStart++; - $iLength--; + $length--; } return $result; } @@ -481,9 +481,9 @@ private function strsplit($sString) if ($this->streql($this->charset, 'utf-8')) { return \preg_split('//u', $sString, -1, PREG_SPLIT_NO_EMPTY); } else { - $iLength = \mb_strlen($sString, $this->charset); + $length = \mb_strlen($sString, $this->charset); $result = []; - for ($i = 0; $i < $iLength; ++$i) { + for ($i = 0; $i < $length; ++$i) { $result[] = \mb_substr($sString, $i, 1, $this->charset); } return $result; diff --git a/src/Value/Size.php b/src/Value/Size.php index 5f5ab4d7..748e2849 100644 --- a/src/Value/Size.php +++ b/src/Value/Size.php @@ -112,11 +112,11 @@ public static function parse(ParserState $parserState, $bIsColorComponent = fals $sUnit = null; $aSizeUnits = self::getSizeUnits(); - foreach ($aSizeUnits as $iLength => &$aValues) { - $sKey = \strtolower($parserState->peek($iLength)); + foreach ($aSizeUnits as $length => &$aValues) { + $sKey = \strtolower($parserState->peek($length)); if (\array_key_exists($sKey, $aValues)) { if (($sUnit = $aValues[$sKey]) !== null) { - $parserState->consume($iLength); + $parserState->consume($length); break; } } diff --git a/src/Value/Value.php b/src/Value/Value.php index b6973438..88b0255f 100644 --- a/src/Value/Value.php +++ b/src/Value/Value.php @@ -83,18 +83,18 @@ public static function parseValue(ParserState $parserState, array $aListDelimite $aNewStack[] = $aStack[$iStartPosition]; continue; } - $iLength = 2; //Number of elements to be joined - for ($i = $iStartPosition + 3; $i < $iStackLength; $i += 2, ++$iLength) { + $length = 2; //Number of elements to be joined + for ($i = $iStartPosition + 3; $i < $iStackLength; $i += 2, ++$length) { if ($sDelimiter !== $aStack[$i]) { break; } } $list = new RuleValueList($sDelimiter, $parserState->currentLine()); - for ($i = $iStartPosition; $i - $iStartPosition < $iLength * 2; $i += 2) { + for ($i = $iStartPosition; $i - $iStartPosition < $length * 2; $i += 2) { $list->addListComponent($aStack[$i]); } $aNewStack[] = $list; - $iStartPosition += $iLength * 2 - 2; + $iStartPosition += $length * 2 - 2; } $aStack = $aNewStack; }