Skip to content

Commit 9706931

Browse files
authored
[TASK] Drop allowing Rule to be passed to RuleSet::getRules() (#1253)
... and `getRulesAssoc()`. Relates to #1247.
1 parent c3905a7 commit 9706931

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ Please also have a look at our
3131

3232
### Changed
3333

34+
- `RuleSet::getRules()` and `getRulesAssoc()` now only allow `string` or `null`
35+
as the parameter (implementing classes are `AtRuleSet` and `DeclarationBlock`)
36+
(#1253)
3437
- Parameters for `getAllValues()` are deconflated, so it now takes three (all
3538
optional), allowing `$element` and `$ruleSearchPattern` to be specified
3639
separately (#1241)

src/RuleSet/RuleSet.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -131,20 +131,15 @@ public function addRule(Rule $ruleToAdd, ?Rule $sibling = null): void
131131
* @example $ruleSet->getRules('font-')
132132
* //returns an array of all rules either beginning with font- or matching font.
133133
*
134-
* @param Rule|string|null $searchPattern
134+
* @param string|null $searchPattern
135135
* Pattern to search for. If null, returns all rules.
136136
* If the pattern ends with a dash, all rules starting with the pattern are returned
137137
* as well as one matching the pattern with the dash excluded.
138-
* Passing a `Rule` for this parameter is deprecated in version 8.9.0, and will not work from v9.0.
139-
* Call `getRules($rule->getRule())` instead.
140138
*
141139
* @return array<int<0, max>, Rule>
142140
*/
143-
public function getRules($searchPattern = null): array
141+
public function getRules(?string $searchPattern = null): array
144142
{
145-
if ($searchPattern instanceof Rule) {
146-
$searchPattern = $searchPattern->getRule();
147-
}
148143
$result = [];
149144
foreach ($this->rules as $propertyName => $rules) {
150145
// Either no search rule is given or the search rule matches the found rule exactly
@@ -191,16 +186,14 @@ public function setRules(array $rules): void
191186
* like `{ background-color: green; background-color; rgba(0, 127, 0, 0.7); }` will only yield an associative array
192187
* containing the rgba-valued rule while `getRules()` would yield an indexed array containing both.
193188
*
194-
* @param Rule|string|null $searchPattern
189+
* @param string|null $searchPattern
195190
* Pattern to search for. If null, returns all rules. If the pattern ends with a dash,
196191
* all rules starting with the pattern are returned as well as one matching the pattern with the dash
197192
* excluded.
198-
* Passing a `Rule` for this parameter is deprecated in version 8.9.0, and will not work from v9.0.
199-
* Call `getRulesAssoc($rule->getRule())` instead.
200193
*
201194
* @return array<string, Rule>
202195
*/
203-
public function getRulesAssoc($searchPattern = null): array
196+
public function getRulesAssoc(?string $searchPattern = null): array
204197
{
205198
/** @var array<string, Rule> $result */
206199
$result = [];

0 commit comments

Comments
 (0)