Skip to content

Commit 0079925

Browse files
authored
[CLEANUP] Avoid Hungarian notation for length (#950)
Part of #756
1 parent 0cf4a76 commit 0079925

File tree

3 files changed

+29
-29
lines changed

3 files changed

+29
-29
lines changed

src/Parsing/ParserState.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class ParserState
4949
/**
5050
* @var int
5151
*/
52-
private $iLength;
52+
private $length;
5353

5454
/**
5555
* @var int
@@ -78,7 +78,7 @@ public function setCharset($charset): void
7878
$this->charset = $charset;
7979
$this->characters = $this->strsplit($this->text);
8080
if (\is_array($this->characters)) {
81-
$this->iLength = \count($this->characters);
81+
$this->length = \count($this->characters);
8282
}
8383
}
8484

@@ -233,7 +233,7 @@ public function consumeWhiteSpace(): array
233233
try {
234234
$oComment = $this->consumeComment();
235235
} catch (UnexpectedEOFException $e) {
236-
$this->currentPosition = $this->iLength;
236+
$this->currentPosition = $this->length;
237237
return $comments;
238238
}
239239
} else {
@@ -259,16 +259,16 @@ public function comes($sString, $bCaseInsensitive = false): bool
259259
}
260260

261261
/**
262-
* @param int $iLength
262+
* @param int $length
263263
* @param int $iOffset
264264
*/
265-
public function peek($iLength = 1, $iOffset = 0): string
265+
public function peek($length = 1, $iOffset = 0): string
266266
{
267267
$iOffset += $this->currentPosition;
268-
if ($iOffset >= $this->iLength) {
268+
if ($iOffset >= $this->length) {
269269
return '';
270270
}
271-
return $this->substr($iOffset, $iLength);
271+
return $this->substr($iOffset, $length);
272272
}
273273

274274
/**
@@ -281,11 +281,11 @@ public function consume($mValue = 1): string
281281
{
282282
if (\is_string($mValue)) {
283283
$iLineCount = \substr_count($mValue, "\n");
284-
$iLength = $this->strlen($mValue);
285-
if (!$this->streql($this->substr($this->currentPosition, $iLength), $mValue)) {
284+
$length = $this->strlen($mValue);
285+
if (!$this->streql($this->substr($this->currentPosition, $length), $mValue)) {
286286
throw new UnexpectedTokenException(
287287
$mValue,
288-
$this->peek(\max($iLength, 5)),
288+
$this->peek(\max($length, 5)),
289289
'literal',
290290
$this->lineNumber
291291
);
@@ -294,7 +294,7 @@ public function consume($mValue = 1): string
294294
$this->currentPosition += $this->strlen($mValue);
295295
return $mValue;
296296
} else {
297-
if ($this->currentPosition + $mValue > $this->iLength) {
297+
if ($this->currentPosition + $mValue > $this->length) {
298298
throw new UnexpectedEOFException((string) $mValue, $this->peek(5), 'count', $this->lineNumber);
299299
}
300300
$result = $this->substr($this->currentPosition, $mValue);
@@ -351,7 +351,7 @@ public function consumeComment()
351351

352352
public function isEnd(): bool
353353
{
354-
return $this->currentPosition >= $this->iLength;
354+
return $this->currentPosition >= $this->length;
355355
}
356356

357357
/**
@@ -439,21 +439,21 @@ public function strlen($sString): int
439439

440440
/**
441441
* @param int $iStart
442-
* @param int $iLength
442+
* @param int $length
443443
*/
444-
private function substr($iStart, $iLength): string
444+
private function substr($iStart, $length): string
445445
{
446-
if ($iLength < 0) {
447-
$iLength = $this->iLength - $iStart + $iLength;
446+
if ($length < 0) {
447+
$length = $this->length - $iStart + $length;
448448
}
449-
if ($iStart + $iLength > $this->iLength) {
450-
$iLength = $this->iLength - $iStart;
449+
if ($iStart + $length > $this->length) {
450+
$length = $this->length - $iStart;
451451
}
452452
$result = '';
453-
while ($iLength > 0) {
453+
while ($length > 0) {
454454
$result .= $this->characters[$iStart];
455455
$iStart++;
456-
$iLength--;
456+
$length--;
457457
}
458458
return $result;
459459
}
@@ -481,9 +481,9 @@ private function strsplit($sString)
481481
if ($this->streql($this->charset, 'utf-8')) {
482482
return \preg_split('//u', $sString, -1, PREG_SPLIT_NO_EMPTY);
483483
} else {
484-
$iLength = \mb_strlen($sString, $this->charset);
484+
$length = \mb_strlen($sString, $this->charset);
485485
$result = [];
486-
for ($i = 0; $i < $iLength; ++$i) {
486+
for ($i = 0; $i < $length; ++$i) {
487487
$result[] = \mb_substr($sString, $i, 1, $this->charset);
488488
}
489489
return $result;

src/Value/Size.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ public static function parse(ParserState $parserState, $bIsColorComponent = fals
112112

113113
$sUnit = null;
114114
$aSizeUnits = self::getSizeUnits();
115-
foreach ($aSizeUnits as $iLength => &$aValues) {
116-
$sKey = \strtolower($parserState->peek($iLength));
115+
foreach ($aSizeUnits as $length => &$aValues) {
116+
$sKey = \strtolower($parserState->peek($length));
117117
if (\array_key_exists($sKey, $aValues)) {
118118
if (($sUnit = $aValues[$sKey]) !== null) {
119-
$parserState->consume($iLength);
119+
$parserState->consume($length);
120120
break;
121121
}
122122
}

src/Value/Value.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,18 @@ public static function parseValue(ParserState $parserState, array $aListDelimite
8383
$aNewStack[] = $aStack[$iStartPosition];
8484
continue;
8585
}
86-
$iLength = 2; //Number of elements to be joined
87-
for ($i = $iStartPosition + 3; $i < $iStackLength; $i += 2, ++$iLength) {
86+
$length = 2; //Number of elements to be joined
87+
for ($i = $iStartPosition + 3; $i < $iStackLength; $i += 2, ++$length) {
8888
if ($sDelimiter !== $aStack[$i]) {
8989
break;
9090
}
9191
}
9292
$list = new RuleValueList($sDelimiter, $parserState->currentLine());
93-
for ($i = $iStartPosition; $i - $iStartPosition < $iLength * 2; $i += 2) {
93+
for ($i = $iStartPosition; $i - $iStartPosition < $length * 2; $i += 2) {
9494
$list->addListComponent($aStack[$i]);
9595
}
9696
$aNewStack[] = $list;
97-
$iStartPosition += $iLength * 2 - 2;
97+
$iStartPosition += $length * 2 - 2;
9898
}
9999
$aStack = $aNewStack;
100100
}

0 commit comments

Comments
 (0)