From 7c7b1270c7faa06203cfc4a8e8c9f293ace0c4de Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Wed, 29 Jan 2025 17:18:29 +0100 Subject: [PATCH 1/4] [CLEANUP] Avoid Hungarian notation in `CSSBlockList` (part 2) Part of #756 --- src/CSSList/CSSBlockList.php | 40 ++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/CSSList/CSSBlockList.php b/src/CSSList/CSSBlockList.php index 96c25a35..120cedf8 100644 --- a/src/CSSList/CSSBlockList.php +++ b/src/CSSList/CSSBlockList.php @@ -96,42 +96,42 @@ protected function allValues( */ protected function allSelectors(array &$result, $specificitySearch = null): void { - /** @var array $aDeclarationBlocks */ - $aDeclarationBlocks = []; - $this->allDeclarationBlocks($aDeclarationBlocks); - foreach ($aDeclarationBlocks as $oBlock) { + /** @var array $declarationBlocks */ + $declarationBlocks = []; + $this->allDeclarationBlocks($declarationBlocks); + foreach ($declarationBlocks as $oBlock) { foreach ($oBlock->getSelectors() as $selector) { if ($specificitySearch === null) { $result[] = $selector; } else { - $sComparator = '==='; - $aSpecificitySearch = \explode(' ', $specificitySearch); - $iTargetSpecificity = $aSpecificitySearch[0]; - if (\count($aSpecificitySearch) > 1) { - $sComparator = $aSpecificitySearch[0]; - $iTargetSpecificity = $aSpecificitySearch[1]; + $comparator = '==='; + $specificitySearchResults = \explode(' ', $specificitySearch); + $targetSpecificity = $specificitySearchResults[0]; + if (\count($specificitySearchResults) > 1) { + $comparator = $specificitySearchResults[0]; + $targetSpecificity = $specificitySearchResults[1]; } - $iTargetSpecificity = (int) $iTargetSpecificity; - $iSelectorSpecificity = $selector->getSpecificity(); - $bMatches = false; - switch ($sComparator) { + $targetSpecificity = (int) $targetSpecificity; + $selectorSpecificity = $selector->getSpecificity(); + $hasMatches = false; + switch ($comparator) { case '<=': - $bMatches = $iSelectorSpecificity <= $iTargetSpecificity; + $hasMatches = $selectorSpecificity <= $targetSpecificity; break; case '<': - $bMatches = $iSelectorSpecificity < $iTargetSpecificity; + $hasMatches = $selectorSpecificity < $targetSpecificity; break; case '>=': - $bMatches = $iSelectorSpecificity >= $iTargetSpecificity; + $hasMatches = $selectorSpecificity >= $targetSpecificity; break; case '>': - $bMatches = $iSelectorSpecificity > $iTargetSpecificity; + $hasMatches = $selectorSpecificity > $targetSpecificity; break; default: - $bMatches = $iSelectorSpecificity === $iTargetSpecificity; + $hasMatches = $selectorSpecificity === $targetSpecificity; break; } - if ($bMatches) { + if ($hasMatches) { $result[] = $selector; } } From afdefc5878e472b5cadeb94481a111d67572df1e Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Thu, 30 Jan 2025 10:45:27 +0100 Subject: [PATCH 2/4] Changes suggested in code review --- src/CSSList/CSSBlockList.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/CSSList/CSSBlockList.php b/src/CSSList/CSSBlockList.php index 120cedf8..91e0fa2e 100644 --- a/src/CSSList/CSSBlockList.php +++ b/src/CSSList/CSSBlockList.php @@ -105,11 +105,11 @@ protected function allSelectors(array &$result, $specificitySearch = null): void $result[] = $selector; } else { $comparator = '==='; - $specificitySearchResults = \explode(' ', $specificitySearch); - $targetSpecificity = $specificitySearchResults[0]; - if (\count($specificitySearchResults) > 1) { - $comparator = $specificitySearchResults[0]; - $targetSpecificity = $specificitySearchResults[1]; + $expressionParts = \explode(' ', $specificitySearch); + $targetSpecificity = $expressionParts[0]; + if (\count($expressionParts) > 1) { + $comparator = $expressionParts[0]; + $targetSpecificity = $expressionParts[1]; } $targetSpecificity = (int) $targetSpecificity; $selectorSpecificity = $selector->getSpecificity(); From 1a46b730f90a1ff6044bffee4b1958b276fb6015 Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Thu, 30 Jan 2025 17:32:06 +0100 Subject: [PATCH 3/4] More change suggested in review --- src/CSSList/CSSBlockList.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/CSSList/CSSBlockList.php b/src/CSSList/CSSBlockList.php index 91e0fa2e..7ce16008 100644 --- a/src/CSSList/CSSBlockList.php +++ b/src/CSSList/CSSBlockList.php @@ -113,25 +113,25 @@ protected function allSelectors(array &$result, $specificitySearch = null): void } $targetSpecificity = (int) $targetSpecificity; $selectorSpecificity = $selector->getSpecificity(); - $hasMatches = false; + $isAMatch = false; switch ($comparator) { case '<=': - $hasMatches = $selectorSpecificity <= $targetSpecificity; + $isAMatch = $selectorSpecificity <= $targetSpecificity; break; case '<': - $hasMatches = $selectorSpecificity < $targetSpecificity; + $isAMatch = $selectorSpecificity < $targetSpecificity; break; case '>=': - $hasMatches = $selectorSpecificity >= $targetSpecificity; + $isAMatch = $selectorSpecificity >= $targetSpecificity; break; case '>': - $hasMatches = $selectorSpecificity > $targetSpecificity; + $isAMatch = $selectorSpecificity > $targetSpecificity; break; default: - $hasMatches = $selectorSpecificity === $targetSpecificity; + $isAMatch = $selectorSpecificity === $targetSpecificity; break; } - if ($hasMatches) { + if ($isAMatch) { $result[] = $selector; } } From f349c988e6306583d85119747745f8141361f2bb Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Thu, 30 Jan 2025 17:50:04 +0100 Subject: [PATCH 4/4] Change according to code review --- src/CSSList/CSSBlockList.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/CSSList/CSSBlockList.php b/src/CSSList/CSSBlockList.php index 7ce16008..2d1e014e 100644 --- a/src/CSSList/CSSBlockList.php +++ b/src/CSSList/CSSBlockList.php @@ -113,25 +113,25 @@ protected function allSelectors(array &$result, $specificitySearch = null): void } $targetSpecificity = (int) $targetSpecificity; $selectorSpecificity = $selector->getSpecificity(); - $isAMatch = false; + $comparatorMatched = false; switch ($comparator) { case '<=': - $isAMatch = $selectorSpecificity <= $targetSpecificity; + $comparatorMatched = $selectorSpecificity <= $targetSpecificity; break; case '<': - $isAMatch = $selectorSpecificity < $targetSpecificity; + $comparatorMatched = $selectorSpecificity < $targetSpecificity; break; case '>=': - $isAMatch = $selectorSpecificity >= $targetSpecificity; + $comparatorMatched = $selectorSpecificity >= $targetSpecificity; break; case '>': - $isAMatch = $selectorSpecificity > $targetSpecificity; + $comparatorMatched = $selectorSpecificity > $targetSpecificity; break; default: - $isAMatch = $selectorSpecificity === $targetSpecificity; + $comparatorMatched = $selectorSpecificity === $targetSpecificity; break; } - if ($isAMatch) { + if ($comparatorMatched) { $result[] = $selector; } }