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); } /**