From ac5aec38b53753851a6438c8826d0c367809ae5f Mon Sep 17 00:00:00 2001 From: Jake Hotson Date: Sun, 13 Apr 2025 23:39:34 +0100 Subject: [PATCH] [CLEANUP] `allSelectors()` -> `getAllSelectors()` The renamed (internal) method now returns the result, instead of having a reference parameter for it. Closes #994. --- src/CSSList/CSSBlockList.php | 8 ++++++-- src/CSSList/Document.php | 8 +++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/CSSList/CSSBlockList.php b/src/CSSList/CSSBlockList.php index 53004b90..90643968 100644 --- a/src/CSSList/CSSBlockList.php +++ b/src/CSSList/CSSBlockList.php @@ -131,10 +131,12 @@ public function getAllValues( } /** - * @param list $result + * @return list */ - protected function allSelectors(array &$result, ?string $specificitySearch = null): void + protected function getAllSelectors(?string $specificitySearch = null): array { + $result = []; + foreach ($this->getAllDeclarationBlocks() as $declarationBlock) { foreach ($declarationBlock->getSelectors() as $selector) { if ($specificitySearch === null) { @@ -173,5 +175,7 @@ protected function allSelectors(array &$result, ?string $specificitySearch = nul } } } + + return $result; } } diff --git a/src/CSSList/Document.php b/src/CSSList/Document.php index d743b0fb..b7a65835 100644 --- a/src/CSSList/Document.php +++ b/src/CSSList/Document.php @@ -38,15 +38,13 @@ public static function parse(ParserState $parserState): Document * An optional filter by specificity. * May contain a comparison operator and a number or just a number (defaults to "=="). * - * @return array + * @return list + * * @example `getSelectorsBySpecificity('>= 100')` */ public function getSelectorsBySpecificity(?string $specificitySearch = null): array { - /** @var array $result */ - $result = []; - $this->allSelectors($result, $specificitySearch); - return $result; + return $this->getAllSelectors($specificitySearch); } /**