-
Notifications
You must be signed in to change notification settings - Fork 150
[CLEANUP] Avoid Hungarian notation in CSSBlockList (part 2)
#851
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -96,42 +96,42 @@ protected function allValues( | |
| */ | ||
| protected function allSelectors(array &$result, $specificitySearch = null): void | ||
| { | ||
| /** @var array<int, DeclarationBlock> $aDeclarationBlocks */ | ||
| $aDeclarationBlocks = []; | ||
| $this->allDeclarationBlocks($aDeclarationBlocks); | ||
| foreach ($aDeclarationBlocks as $oBlock) { | ||
| /** @var array<int, DeclarationBlock> $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; | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be named with something like 'parts', 'elements' or 'components'. The input string contains either a number (e.g. "1"), or an operator and a number (e.g. ">= 1"). The result goes into
$result.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
$expressionParts?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I think that works. It's only used locally in that small section of code.