Skip to content

Commit

Permalink
[CLEANUP] Avoid Hungarian notation for sIdentifier (#863)
Browse files Browse the repository at this point in the history
Part of #756
  • Loading branch information
oliverklee authored Feb 2, 2025
1 parent 95005c9 commit b584760
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
26 changes: 13 additions & 13 deletions src/CSSList/CSSList.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@ private static function parseListItem(ParserState $parserState, CSSList $list)
private static function parseAtRule(ParserState $parserState)
{
$parserState->consume('@');
$sIdentifier = $parserState->parseIdentifier();
$identifier = $parserState->parseIdentifier();
$iIdentifierLineNum = $parserState->currentLine();
$parserState->consumeWhiteSpace();
if ($sIdentifier === 'import') {
if ($identifier === 'import') {
$oLocation = URL::parse($parserState);
$parserState->consumeWhiteSpace();
$mediaQuery = null;
Expand All @@ -171,21 +171,21 @@ private static function parseAtRule(ParserState $parserState)
}
$parserState->consumeUntil([';', ParserState::EOF], true, true);
return new Import($oLocation, $mediaQuery, $iIdentifierLineNum);
} elseif ($sIdentifier === 'charset') {
} elseif ($identifier === 'charset') {
$oCharsetString = CSSString::parse($parserState);
$parserState->consumeWhiteSpace();
$parserState->consumeUntil([';', ParserState::EOF], true, true);
return new Charset($oCharsetString, $iIdentifierLineNum);
} elseif (self::identifierIs($sIdentifier, 'keyframes')) {
} elseif (self::identifierIs($identifier, 'keyframes')) {
$oResult = new KeyFrame($iIdentifierLineNum);
$oResult->setVendorKeyFrame($sIdentifier);
$oResult->setVendorKeyFrame($identifier);
$oResult->setAnimationName(\trim($parserState->consumeUntil('{', false, true)));
CSSList::parseList($parserState, $oResult);
if ($parserState->comes('}')) {
$parserState->consume('}');
}
return $oResult;
} elseif ($sIdentifier === 'namespace') {
} elseif ($identifier === 'namespace') {
$sPrefix = null;
$mUrl = Value::parsePrimitiveValue($parserState);
if (!$parserState->comes(';')) {
Expand Down Expand Up @@ -217,16 +217,16 @@ private static function parseAtRule(ParserState $parserState)
}
$bUseRuleSet = true;
foreach (\explode('/', AtRule::BLOCK_RULES) as $sBlockRuleName) {
if (self::identifierIs($sIdentifier, $sBlockRuleName)) {
if (self::identifierIs($identifier, $sBlockRuleName)) {
$bUseRuleSet = false;
break;
}
}
if ($bUseRuleSet) {
$oAtRule = new AtRuleSet($sIdentifier, $sArgs, $iIdentifierLineNum);
$oAtRule = new AtRuleSet($identifier, $sArgs, $iIdentifierLineNum);
RuleSet::parseRuleSet($parserState, $oAtRule);
} else {
$oAtRule = new AtRuleBlockList($sIdentifier, $sArgs, $iIdentifierLineNum);
$oAtRule = new AtRuleBlockList($identifier, $sArgs, $iIdentifierLineNum);
CSSList::parseList($parserState, $oAtRule);
if ($parserState->comes('}')) {
$parserState->consume('}');
Expand All @@ -240,12 +240,12 @@ private static function parseAtRule(ParserState $parserState)
* Tests an identifier for a given value. Since identifiers are all keywords, they can be vendor-prefixed.
* We need to check for these versions too.
*
* @param string $sIdentifier
* @param string $identifier
*/
private static function identifierIs($sIdentifier, string $sMatch): bool
private static function identifierIs($identifier, string $sMatch): bool
{
return (\strcasecmp($sIdentifier, $sMatch) === 0)
?: \preg_match("/^(-\\w+-)?$sMatch$/i", $sIdentifier) === 1;
return (\strcasecmp($identifier, $sMatch) === 0)
?: \preg_match("/^(-\\w+-)?$sMatch$/i", $identifier) === 1;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Value/URL.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ public function __construct(CSSString $oURL, $lineNumber = 0)
public static function parse(ParserState $parserState): URL
{
$oAnchor = $parserState->anchor();
$sIdentifier = '';
$identifier = '';
for ($i = 0; $i < 3; $i++) {
$sChar = $parserState->parseCharacter(true);
if ($sChar === null) {
break;
}
$sIdentifier .= $sChar;
$identifier .= $sChar;
}
$bUseUrl = $parserState->streql($sIdentifier, 'url');
$bUseUrl = $parserState->streql($identifier, 'url');
if ($bUseUrl) {
$parserState->consumeWhiteSpace();
$parserState->consume('(');
Expand Down

0 comments on commit b584760

Please sign in to comment.