Skip to content

[CLEANUP] Avoid Hungarian notation for charset #948

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
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
22 changes: 11 additions & 11 deletions src/Parsing/ParserState.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ParserState
*
* @var string
*/
private $sCharset;
private $charset;

/**
* @var int
Expand All @@ -71,11 +71,11 @@ public function __construct($text, Settings $parserSettings, $lineNumber = 1)
/**
* Sets the charset to be used if the CSS does not contain an `@charset` declaration.
*
* @param string $sCharset
* @param string $charset
*/
public function setCharset($sCharset): void
public function setCharset($charset): void
{
$this->sCharset = $sCharset;
$this->charset = $charset;
$this->characters = $this->strsplit($this->text);
if (\is_array($this->characters)) {
$this->iLength = \count($this->characters);
Expand Down Expand Up @@ -195,7 +195,7 @@ public function parseCharacter($bIsForIdentifier)
$sUtf32 .= \chr($iUnicode & 0xff);
$iUnicode = $iUnicode >> 8;
}
return \iconv('utf-32le', $this->sCharset, $sUtf32);
return \iconv('utf-32le', $this->charset, $sUtf32);
}
if ($bIsForIdentifier) {
$peek = \ord($this->peek());
Expand Down Expand Up @@ -431,7 +431,7 @@ public function backtrack($iAmount): void
public function strlen($sString): int
{
if ($this->parserSettings->bMultibyteSupport) {
return \mb_strlen($sString, $this->sCharset);
return \mb_strlen($sString, $this->charset);
} else {
return \strlen($sString);
}
Expand Down Expand Up @@ -464,7 +464,7 @@ private function substr($iStart, $iLength): string
private function strtolower($sString): string
{
if ($this->parserSettings->bMultibyteSupport) {
return \mb_strtolower($sString, $this->sCharset);
return \mb_strtolower($sString, $this->charset);
} else {
return \strtolower($sString);
}
Expand All @@ -478,13 +478,13 @@ private function strtolower($sString): string
private function strsplit($sString)
{
if ($this->parserSettings->bMultibyteSupport) {
if ($this->streql($this->sCharset, 'utf-8')) {
if ($this->streql($this->charset, 'utf-8')) {
return \preg_split('//u', $sString, -1, PREG_SPLIT_NO_EMPTY);
} else {
$iLength = \mb_strlen($sString, $this->sCharset);
$iLength = \mb_strlen($sString, $this->charset);
$result = [];
for ($i = 0; $i < $iLength; ++$i) {
$result[] = \mb_substr($sString, $i, 1, $this->sCharset);
$result[] = \mb_substr($sString, $i, 1, $this->charset);
}
return $result;
}
Expand All @@ -507,7 +507,7 @@ private function strsplit($sString)
private function strpos($sString, $sNeedle, $iOffset)
{
if ($this->parserSettings->bMultibyteSupport) {
return \mb_strpos($sString, $sNeedle, $iOffset, $this->sCharset);
return \mb_strpos($sString, $sNeedle, $iOffset, $this->charset);
} else {
return \strpos($sString, $sNeedle, $iOffset);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Property/Charset.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ public function getLineNo(): int
}

/**
* @param string|CSSString $sCharset
* @param string|CSSString $charset
*/
public function setCharset($sCharset): void
public function setCharset($charset): void
{
$sCharset = $sCharset instanceof CSSString ? $sCharset : new CSSString($sCharset);
$this->oCharset = $sCharset;
$charset = $charset instanceof CSSString ? $charset : new CSSString($charset);
$this->oCharset = $charset;
}

/**
Expand Down