Skip to content

Commit

Permalink
[CLEANUP] Avoid Hungarian notation for prefix (#926)
Browse files Browse the repository at this point in the history
Part of #756
  • Loading branch information
oliverklee authored Feb 15, 2025
1 parent fa5ff8a commit fa66e43
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
10 changes: 5 additions & 5 deletions src/CSSList/CSSList.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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));
Expand Down
8 changes: 4 additions & 4 deletions src/OutputFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down
22 changes: 11 additions & 11 deletions src/Property/CSSNamespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CSSNamespace implements AtRule
/**
* @var string
*/
private $sPrefix;
private $prefix;

/**
* @var int
Expand All @@ -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 = [];
}
Expand All @@ -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) . ';';
}

Expand All @@ -79,7 +79,7 @@ public function getUrl()
*/
public function getPrefix()
{
return $this->sPrefix;
return $this->prefix;
}

/**
Expand All @@ -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;
}

/**
Expand All @@ -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;
}
Expand Down

0 comments on commit fa66e43

Please sign in to comment.