From 258fd41d25bf9c80c474b2f842b296443cba843c Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Fri, 14 Feb 2025 23:21:44 +0100 Subject: [PATCH] [CLEANUP] Avoid Hungarian notation for `prefix` Part of #756 --- src/CSSList/CSSList.php | 10 +++++----- src/OutputFormat.php | 8 ++++---- src/Property/CSSNamespace.php | 22 +++++++++++----------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/CSSList/CSSList.php b/src/CSSList/CSSList.php index 7f21893b3..5e7cf2945 100644 --- a/src/CSSList/CSSList.php +++ b/src/CSSList/CSSList.php @@ -194,15 +194,15 @@ private static function parseAtRule(ParserState $parserState) } return $result; } elseif ($identifier === 'namespace') { - $sPrefix = null; + $prefix = null; $url = Value::parsePrimitiveValue($parserState); if (!$parserState->comes(';')) { - $sPrefix = $url; + $prefix = $url; $url = Value::parsePrimitiveValue($parserState); } $parserState->consumeUntil([';', ParserState::EOF], true, true); - if ($sPrefix !== null && !\is_string($sPrefix)) { - throw new UnexpectedTokenException('Wrong namespace prefix', $sPrefix, 'custom', $identifierLineNumber); + if ($prefix !== null && !\is_string($prefix)) { + throw new UnexpectedTokenException('Wrong namespace prefix', $prefix, 'custom', $identifierLineNumber); } if (!($url instanceof CSSString || $url instanceof URL)) { throw new UnexpectedTokenException( @@ -212,7 +212,7 @@ private static function parseAtRule(ParserState $parserState) $identifierLineNumber ); } - return new CSSNamespace($url, $sPrefix, $identifierLineNumber); + return new CSSNamespace($url, $prefix, $identifierLineNumber); } else { // Unknown other at rule (font-face or such) $arguments = \trim($parserState->consumeUntil('{', false, true)); diff --git a/src/OutputFormat.php b/src/OutputFormat.php index 52033bf42..1068fa1f9 100644 --- a/src/OutputFormat.php +++ b/src/OutputFormat.php @@ -237,8 +237,8 @@ public function __construct() {} public function get(string $sName) { $aVarPrefixes = ['a', 's', 'm', 'b', 'f', 'o', 'c', 'i']; - foreach ($aVarPrefixes as $sPrefix) { - $sFieldName = $sPrefix . \ucfirst($sName); + foreach ($aVarPrefixes as $prefix) { + $sFieldName = $prefix . \ucfirst($sName); if (isset($this->$sFieldName)) { return $this->$sFieldName; } @@ -265,10 +265,10 @@ public function set($aNames, $mValue) } elseif (!\is_array($aNames)) { $aNames = [$aNames]; } - foreach ($aVarPrefixes as $sPrefix) { + foreach ($aVarPrefixes as $prefix) { $bDidReplace = false; foreach ($aNames as $sName) { - $sFieldName = $sPrefix . \ucfirst($sName); + $sFieldName = $prefix . \ucfirst($sName); if (isset($this->$sFieldName)) { $this->$sFieldName = $mValue; $bDidReplace = true; diff --git a/src/Property/CSSNamespace.php b/src/Property/CSSNamespace.php index a646bcdde..eed63782a 100644 --- a/src/Property/CSSNamespace.php +++ b/src/Property/CSSNamespace.php @@ -20,7 +20,7 @@ class CSSNamespace implements AtRule /** * @var string */ - private $sPrefix; + private $prefix; /** * @var int @@ -36,13 +36,13 @@ class CSSNamespace implements AtRule /** * @param string $mUrl - * @param string|null $sPrefix + * @param string|null $prefix * @param int<0, max> $lineNumber */ - public function __construct($mUrl, $sPrefix = null, $lineNumber = 0) + public function __construct($mUrl, $prefix = null, $lineNumber = 0) { $this->mUrl = $mUrl; - $this->sPrefix = $sPrefix; + $this->prefix = $prefix; $this->lineNumber = $lineNumber; $this->comments = []; } @@ -62,7 +62,7 @@ public function __toString(): string public function render(OutputFormat $outputFormat): string { - return '@namespace ' . ($this->sPrefix === null ? '' : $this->sPrefix . ' ') + return '@namespace ' . ($this->prefix === null ? '' : $this->prefix . ' ') . $this->mUrl->render($outputFormat) . ';'; } @@ -79,7 +79,7 @@ public function getUrl() */ public function getPrefix() { - return $this->sPrefix; + return $this->prefix; } /** @@ -91,11 +91,11 @@ public function setUrl($mUrl): void } /** - * @param string $sPrefix + * @param string $prefix */ - public function setPrefix($sPrefix): void + public function setPrefix($prefix): void { - $this->sPrefix = $sPrefix; + $this->prefix = $prefix; } /** @@ -112,8 +112,8 @@ public function atRuleName(): string public function atRuleArgs(): array { $result = [$this->mUrl]; - if ($this->sPrefix) { - \array_unshift($result, $this->sPrefix); + if ($this->prefix) { + \array_unshift($result, $this->prefix); } return $result; }