@@ -138,29 +138,29 @@ public function addRule(Rule $rule, ?Rule $oSibling = null): void
138138 * @example $ruleSet->getRules('font-')
139139 * //returns an array of all rules either beginning with font- or matching font.
140140 *
141- * @param Rule|string|null $mRule
141+ * @param Rule|string|null $searchPattern
142142 * Pattern to search for. If null, returns all rules.
143143 * If the pattern ends with a dash, all rules starting with the pattern are returned
144144 * as well as one matching the pattern with the dash excluded.
145145 * Passing a Rule behaves like calling `getRules($mRule->getRule())`.
146146 *
147147 * @return array<int, Rule>
148148 */
149- public function getRules ($ mRule = null )
149+ public function getRules ($ searchPattern = null )
150150 {
151- if ($ mRule instanceof Rule) {
152- $ mRule = $ mRule ->getRule ();
151+ if ($ searchPattern instanceof Rule) {
152+ $ searchPattern = $ searchPattern ->getRule ();
153153 }
154154 /** @var array<int, Rule> $result */
155155 $ result = [];
156156 foreach ($ this ->rules as $ sName => $ rules ) {
157157 // Either no search rule is given or the search rule matches the found rule exactly
158158 // or the search rule ends in “-” and the found rule starts with the search rule.
159159 if (
160- !$ mRule || $ sName === $ mRule
160+ !$ searchPattern || $ sName === $ searchPattern
161161 || (
162- \strrpos ($ mRule , '- ' ) === \strlen ($ mRule ) - \strlen ('- ' )
163- && (\strpos ($ sName , $ mRule ) === 0 || $ sName === \substr ($ mRule , 0 , -1 ))
162+ \strrpos ($ searchPattern , '- ' ) === \strlen ($ searchPattern ) - \strlen ('- ' )
163+ && (\strpos ($ sName , $ searchPattern ) === 0 || $ sName === \substr ($ searchPattern , 0 , -1 ))
164164 )
165165 ) {
166166 $ result = \array_merge ($ result , $ rules );
@@ -196,18 +196,18 @@ public function setRules(array $rules): void
196196 * like `{ background-color: green; background-color; rgba(0, 127, 0, 0.7); }` will only yield an associative array
197197 * containing the rgba-valued rule while `getRules()` would yield an indexed array containing both.
198198 *
199- * @param Rule|string|null $mRule $mRule
199+ * @param Rule|string|null $searchPattern
200200 * Pattern to search for. If null, returns all rules. If the pattern ends with a dash,
201201 * all rules starting with the pattern are returned as well as one matching the pattern with the dash
202202 * excluded. Passing a Rule behaves like calling `getRules($mRule->getRule())`.
203203 *
204204 * @return array<string, Rule>
205205 */
206- public function getRulesAssoc ($ mRule = null )
206+ public function getRulesAssoc ($ searchPattern = null )
207207 {
208208 /** @var array<string, Rule> $result */
209209 $ result = [];
210- foreach ($ this ->getRules ($ mRule ) as $ rule ) {
210+ foreach ($ this ->getRules ($ searchPattern ) as $ rule ) {
211211 $ result [$ rule ->getRule ()] = $ rule ;
212212 }
213213 return $ result ;
@@ -222,20 +222,20 @@ public function getRulesAssoc($mRule = null)
222222 * Note: this is different from pre-v.2.0 behaviour of PHP-CSS-Parser, where passing a Rule instance would
223223 * remove all rules with the same name. To get the old behaviour, use `removeRule($rule->getRule())`.
224224 *
225- * @param Rule|string|null $mRule
226- * pattern to remove. If $mRule is null, all rules are removed. If the pattern ends in a dash,
225+ * @param Rule|string|null $searchPattern
226+ * pattern to remove. If null, all rules are removed. If the pattern ends in a dash,
227227 * all rules starting with the pattern are removed as well as one matching the pattern with the dash
228228 * excluded. Passing a Rule behaves matches by identity.
229229 */
230- public function removeRule ($ mRule ): void
230+ public function removeRule ($ searchPattern ): void
231231 {
232- if ($ mRule instanceof Rule) {
233- $ sRule = $ mRule ->getRule ();
232+ if ($ searchPattern instanceof Rule) {
233+ $ sRule = $ searchPattern ->getRule ();
234234 if (!isset ($ this ->rules [$ sRule ])) {
235235 return ;
236236 }
237237 foreach ($ this ->rules [$ sRule ] as $ key => $ rule ) {
238- if ($ rule === $ mRule ) {
238+ if ($ rule === $ searchPattern ) {
239239 unset($ this ->rules [$ sRule ][$ key ]);
240240 }
241241 }
@@ -245,9 +245,9 @@ public function removeRule($mRule): void
245245 // or the search rule ends in “-” and the found rule starts with the search rule or equals it
246246 // (without the trailing dash).
247247 if (
248- !$ mRule || $ sName === $ mRule
249- || (\strrpos ($ mRule , '- ' ) === \strlen ($ mRule ) - \strlen ('- ' )
250- && (\strpos ($ sName , $ mRule ) === 0 || $ sName === \substr ($ mRule , 0 , -1 )))
248+ !$ searchPattern || $ sName === $ searchPattern
249+ || (\strrpos ($ searchPattern , '- ' ) === \strlen ($ searchPattern ) - \strlen ('- ' )
250+ && (\strpos ($ sName , $ searchPattern ) === 0 || $ sName === \substr ($ searchPattern , 0 , -1 )))
251251 ) {
252252 unset($ this ->rules [$ sName ]);
253253 }
0 commit comments