From 82667e2087ebf8884e6277eeedc2a555bc4e5982 Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Sun, 2 Mar 2025 19:46:20 +0100 Subject: [PATCH] [CLEANUP] Refactor `CSSBlockList::getAllRuleSets()` Also remove the now-unused method `allRuleSets()`. Part of #994. --- src/CSSList/CSSBlockList.php | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/CSSList/CSSBlockList.php b/src/CSSList/CSSBlockList.php index 0f8bbe36..10a7778c 100644 --- a/src/CSSList/CSSBlockList.php +++ b/src/CSSList/CSSBlockList.php @@ -57,28 +57,21 @@ protected function allDeclarationBlocks(array &$result): void /** * Returns all `RuleSet` objects recursively found in the tree, no matter how deeply nested the rule sets are. * - * @return array + * @return list */ public function getAllRuleSets(): array { - /** @var array $result */ $result = []; - $this->allRuleSets($result); - return $result; - } - /** - * @param array $result - */ - protected function allRuleSets(array &$result): void - { foreach ($this->contents as $item) { if ($item instanceof RuleSet) { $result[] = $item; } elseif ($item instanceof CSSBlockList) { - $item->allRuleSets($result); + $result = \array_merge($result, $item->getAllRuleSets()); } } + + return $result; } /**