Skip to content

[CLEANUP] Avoid Hungarian notation for prefix #926

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 15, 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
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