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
34 changes: 17 additions & 17 deletions src/Parsing/ParserState.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ParserState
/**
* @var int
*/
private $iCurrentPosition = 0;
private $currentPosition = 0;

/**
* will only be used if the CSS does not contain an `@charset` declaration
Expand Down Expand Up @@ -95,7 +95,7 @@ public function currentLine()
*/
public function currentColumn()
{
return $this->iCurrentPosition;
return $this->currentPosition;
}

/**
Expand All @@ -108,15 +108,15 @@ public function getSettings()

public function anchor(): Anchor
{
return new Anchor($this->iCurrentPosition, $this);
return new Anchor($this->currentPosition, $this);
}

/**
* @param int $position
*/
public function setPosition($position): void
{
$this->iCurrentPosition = $position;
$this->currentPosition = $position;
}

/**
Expand Down Expand Up @@ -233,7 +233,7 @@ public function consumeWhiteSpace(): array
try {
$oComment = $this->consumeComment();
} catch (UnexpectedEOFException $e) {
$this->iCurrentPosition = $this->iLength;
$this->currentPosition = $this->iLength;
return $comments;
}
} else {
Expand Down Expand Up @@ -264,7 +264,7 @@ public function comes($sString, $bCaseInsensitive = false): bool
*/
public function peek($iLength = 1, $iOffset = 0): string
{
$iOffset += $this->iCurrentPosition;
$iOffset += $this->currentPosition;
if ($iOffset >= $this->iLength) {
return '';
}
Expand All @@ -282,7 +282,7 @@ 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->iCurrentPosition, $iLength), $mValue)) {
if (!$this->streql($this->substr($this->currentPosition, $iLength), $mValue)) {
throw new UnexpectedTokenException(
$mValue,
$this->peek(\max($iLength, 5)),
Expand All @@ -291,16 +291,16 @@ public function consume($mValue = 1): string
);
}
$this->lineNumber += $iLineCount;
$this->iCurrentPosition += $this->strlen($mValue);
$this->currentPosition += $this->strlen($mValue);
return $mValue;
} else {
if ($this->iCurrentPosition + $mValue > $this->iLength) {
if ($this->currentPosition + $mValue > $this->iLength) {
throw new UnexpectedEOFException((string) $mValue, $this->peek(5), 'count', $this->lineNumber);
}
$result = $this->substr($this->iCurrentPosition, $mValue);
$result = $this->substr($this->currentPosition, $mValue);
$iLineCount = \substr_count($result, "\n");
$this->lineNumber += $iLineCount;
$this->iCurrentPosition += $mValue;
$this->currentPosition += $mValue;
return $result;
}
}
Expand Down Expand Up @@ -351,7 +351,7 @@ public function consumeComment()

public function isEnd(): bool
{
return $this->iCurrentPosition >= $this->iLength;
return $this->currentPosition >= $this->iLength;
}

/**
Expand All @@ -367,15 +367,15 @@ public function consumeUntil($aEnd, $bIncludeEnd = false, $consumeEnd = false, a
{
$aEnd = \is_array($aEnd) ? $aEnd : [$aEnd];
$out = '';
$start = $this->iCurrentPosition;
$start = $this->currentPosition;

while (!$this->isEnd()) {
$char = $this->consume(1);
if (\in_array($char, $aEnd, true)) {
if ($bIncludeEnd) {
$out .= $char;
} elseif (!$consumeEnd) {
$this->iCurrentPosition -= $this->strlen($char);
$this->currentPosition -= $this->strlen($char);
}
return $out;
}
Expand All @@ -389,7 +389,7 @@ public function consumeUntil($aEnd, $bIncludeEnd = false, $consumeEnd = false, a
return $out;
}

$this->iCurrentPosition = $start;
$this->currentPosition = $start;
throw new UnexpectedEOFException(
'One of ("' . \implode('","', $aEnd) . '")',
$this->peek(5),
Expand All @@ -400,7 +400,7 @@ public function consumeUntil($aEnd, $bIncludeEnd = false, $consumeEnd = false, a

private function inputLeft(): string
{
return $this->substr($this->iCurrentPosition, -1);
return $this->substr($this->currentPosition, -1);
}

/**
Expand All @@ -422,7 +422,7 @@ public function streql($sString1, $sString2, $bCaseInsensitive = true): bool
*/
public function backtrack($iAmount): void
{
$this->iCurrentPosition -= $iAmount;
$this->currentPosition -= $iAmount;
}

/**
Expand Down