Skip to content

Commit a9874a9

Browse files
authored
[CLEANUP] allSelectors() -> getAllSelectors() (#1245)
The renamed (internal) method now returns the result, instead of having a reference parameter for it. Closes #994.
1 parent 03ed64a commit a9874a9

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/CSSList/CSSBlockList.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,12 @@ public function getAllValues(
131131
}
132132

133133
/**
134-
* @param list<Selector> $result
134+
* @return list<Selector>
135135
*/
136-
protected function allSelectors(array &$result, ?string $specificitySearch = null): void
136+
protected function getAllSelectors(?string $specificitySearch = null): array
137137
{
138+
$result = [];
139+
138140
foreach ($this->getAllDeclarationBlocks() as $declarationBlock) {
139141
foreach ($declarationBlock->getSelectors() as $selector) {
140142
if ($specificitySearch === null) {
@@ -173,5 +175,7 @@ protected function allSelectors(array &$result, ?string $specificitySearch = nul
173175
}
174176
}
175177
}
178+
179+
return $result;
176180
}
177181
}

src/CSSList/Document.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,13 @@ public static function parse(ParserState $parserState): Document
3838
* An optional filter by specificity.
3939
* May contain a comparison operator and a number or just a number (defaults to "==").
4040
*
41-
* @return array<int, Selector>
41+
* @return list<Selector>
42+
*
4243
* @example `getSelectorsBySpecificity('>= 100')`
4344
*/
4445
public function getSelectorsBySpecificity(?string $specificitySearch = null): array
4546
{
46-
/** @var array<int, Selector> $result */
47-
$result = [];
48-
$this->allSelectors($result, $specificitySearch);
49-
return $result;
47+
return $this->getAllSelectors($specificitySearch);
5048
}
5149

5250
/**

0 commit comments

Comments
 (0)