Skip to content

Commit dfd1fb8

Browse files
committed
[CLEANUP] Use the accessor for the charset in ParserState
Also make the getter `private` as it's not (intended to be) called from the outside. As the whole `ParserState` class is `@internal`, this does does not require a deprecation process.
1 parent 6775b97 commit dfd1fb8

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/Parsing/ParserState.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function setCharset($sCharset): void
8787
*
8888
* @return string
8989
*/
90-
public function getCharset()
90+
private function getCharset()
9191
{
9292
return $this->sCharset;
9393
}
@@ -205,7 +205,7 @@ public function parseCharacter($bIsForIdentifier)
205205
$sUtf32 .= \chr($iUnicode & 0xff);
206206
$iUnicode = $iUnicode >> 8;
207207
}
208-
return \iconv('utf-32le', $this->sCharset, $sUtf32);
208+
return \iconv('utf-32le', $this->getCharset(), $sUtf32);
209209
}
210210
if ($bIsForIdentifier) {
211211
$peek = \ord($this->peek());
@@ -441,7 +441,7 @@ public function backtrack($iAmount): void
441441
public function strlen($sString): int
442442
{
443443
if ($this->oParserSettings->bMultibyteSupport) {
444-
return \mb_strlen($sString, $this->sCharset);
444+
return \mb_strlen($sString, $this->getCharset());
445445
} else {
446446
return \strlen($sString);
447447
}
@@ -474,7 +474,7 @@ private function substr($iStart, $iLength): string
474474
private function strtolower($sString): string
475475
{
476476
if ($this->oParserSettings->bMultibyteSupport) {
477-
return \mb_strtolower($sString, $this->sCharset);
477+
return \mb_strtolower($sString, $this->getCharset());
478478
} else {
479479
return \strtolower($sString);
480480
}
@@ -488,13 +488,13 @@ private function strtolower($sString): string
488488
private function strsplit($sString)
489489
{
490490
if ($this->oParserSettings->bMultibyteSupport) {
491-
if ($this->streql($this->sCharset, 'utf-8')) {
491+
if ($this->streql($this->getCharset(), 'utf-8')) {
492492
return \preg_split('//u', $sString, -1, PREG_SPLIT_NO_EMPTY);
493493
} else {
494-
$iLength = \mb_strlen($sString, $this->sCharset);
494+
$iLength = \mb_strlen($sString, $this->getCharset());
495495
$result = [];
496496
for ($i = 0; $i < $iLength; ++$i) {
497-
$result[] = \mb_substr($sString, $i, 1, $this->sCharset);
497+
$result[] = \mb_substr($sString, $i, 1, $this->getCharset());
498498
}
499499
return $result;
500500
}
@@ -517,7 +517,7 @@ private function strsplit($sString)
517517
private function strpos($sString, $sNeedle, $iOffset)
518518
{
519519
if ($this->oParserSettings->bMultibyteSupport) {
520-
return \mb_strpos($sString, $sNeedle, $iOffset, $this->sCharset);
520+
return \mb_strpos($sString, $sNeedle, $iOffset, $this->getCharset());
521521
} else {
522522
return \strpos($sString, $sNeedle, $iOffset);
523523
}

0 commit comments

Comments
 (0)