From 257dc37a388c65e66eaae81a9898f0228956624d Mon Sep 17 00:00:00 2001 From: Jake Hotson Date: Fri, 2 May 2025 00:03:44 +0100 Subject: [PATCH] [TASK] Deprecate passing `Rule` to `RuleSet::getRules()` And also `getRulesAssoc()`. Relates to #1247. --- CHANGELOG.md | 3 +++ src/RuleSet/RuleSet.php | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 132605a9..f4b2fc5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,9 @@ Please also have a look at our ### Deprecated +- Passing a `Rule` to `RuleSet::getRules()` or `getRulesAssoc()` is deprecated, + affecting the implementing classes `AtRuleSet` and `DeclarationBlock` + (call e.g. `getRules($rule->getRule())` instead) (#1248) - Passing a string as the first argument to `getAllValues()` is deprecated; the search pattern should now be passed as the second argument (#1241) - Passing a Boolean as the second argument to `getAllValues()` is deprecated; diff --git a/src/RuleSet/RuleSet.php b/src/RuleSet/RuleSet.php index b10d3e97..d96787c5 100644 --- a/src/RuleSet/RuleSet.php +++ b/src/RuleSet/RuleSet.php @@ -135,7 +135,8 @@ public function addRule(Rule $ruleToAdd, ?Rule $sibling = null): void * Pattern to search for. If null, returns all rules. * If the pattern ends with a dash, all rules starting with the pattern are returned * as well as one matching the pattern with the dash excluded. - * Passing a `Rule` behaves like calling `getRules($rule->getRule())`. + * Passing a `Rule` for this parameter is deprecated in version 8.9.0, and will not work from v9.0. + * Call `getRules($rule->getRule())` instead. * * @return array, Rule> */ @@ -193,7 +194,9 @@ public function setRules(array $rules): void * @param Rule|string|null $searchPattern * Pattern to search for. If null, returns all rules. If the pattern ends with a dash, * all rules starting with the pattern are returned as well as one matching the pattern with the dash - * excluded. Passing a `Rule` behaves like calling `getRules($rule->getRule())`. + * excluded. + * Passing a `Rule` for this parameter is deprecated in version 8.9.0, and will not work from v9.0. + * Call `getRulesAssoc($rule->getRule())` instead. * * @return array */