@@ -138,29 +138,29 @@ public function addRule(Rule $rule, ?Rule $oSibling = null): void
138
138
* @example $ruleSet->getRules('font-')
139
139
* //returns an array of all rules either beginning with font- or matching font.
140
140
*
141
- * @param Rule|string|null $mRule
141
+ * @param Rule|string|null $searchPattern
142
142
* Pattern to search for. If null, returns all rules.
143
143
* If the pattern ends with a dash, all rules starting with the pattern are returned
144
144
* as well as one matching the pattern with the dash excluded.
145
145
* Passing a Rule behaves like calling `getRules($mRule->getRule())`.
146
146
*
147
147
* @return array<int, Rule>
148
148
*/
149
- public function getRules ($ mRule = null )
149
+ public function getRules ($ searchPattern = null )
150
150
{
151
- if ($ mRule instanceof Rule) {
152
- $ mRule = $ mRule ->getRule ();
151
+ if ($ searchPattern instanceof Rule) {
152
+ $ searchPattern = $ searchPattern ->getRule ();
153
153
}
154
154
/** @var array<int, Rule> $result */
155
155
$ result = [];
156
156
foreach ($ this ->rules as $ sName => $ rules ) {
157
157
// Either no search rule is given or the search rule matches the found rule exactly
158
158
// or the search rule ends in “-” and the found rule starts with the search rule.
159
159
if (
160
- !$ mRule || $ sName === $ mRule
160
+ !$ searchPattern || $ sName === $ searchPattern
161
161
|| (
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 ))
164
164
)
165
165
) {
166
166
$ result = \array_merge ($ result , $ rules );
@@ -196,18 +196,18 @@ public function setRules(array $rules): void
196
196
* like `{ background-color: green; background-color; rgba(0, 127, 0, 0.7); }` will only yield an associative array
197
197
* containing the rgba-valued rule while `getRules()` would yield an indexed array containing both.
198
198
*
199
- * @param Rule|string|null $mRule $mRule
199
+ * @param Rule|string|null $searchPattern
200
200
* Pattern to search for. If null, returns all rules. If the pattern ends with a dash,
201
201
* all rules starting with the pattern are returned as well as one matching the pattern with the dash
202
202
* excluded. Passing a Rule behaves like calling `getRules($mRule->getRule())`.
203
203
*
204
204
* @return array<string, Rule>
205
205
*/
206
- public function getRulesAssoc ($ mRule = null )
206
+ public function getRulesAssoc ($ searchPattern = null )
207
207
{
208
208
/** @var array<string, Rule> $result */
209
209
$ result = [];
210
- foreach ($ this ->getRules ($ mRule ) as $ rule ) {
210
+ foreach ($ this ->getRules ($ searchPattern ) as $ rule ) {
211
211
$ result [$ rule ->getRule ()] = $ rule ;
212
212
}
213
213
return $ result ;
@@ -222,20 +222,20 @@ public function getRulesAssoc($mRule = null)
222
222
* Note: this is different from pre-v.2.0 behaviour of PHP-CSS-Parser, where passing a Rule instance would
223
223
* remove all rules with the same name. To get the old behaviour, use `removeRule($rule->getRule())`.
224
224
*
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,
227
227
* all rules starting with the pattern are removed as well as one matching the pattern with the dash
228
228
* excluded. Passing a Rule behaves matches by identity.
229
229
*/
230
- public function removeRule ($ mRule ): void
230
+ public function removeRule ($ searchPattern ): void
231
231
{
232
- if ($ mRule instanceof Rule) {
233
- $ sRule = $ mRule ->getRule ();
232
+ if ($ searchPattern instanceof Rule) {
233
+ $ sRule = $ searchPattern ->getRule ();
234
234
if (!isset ($ this ->rules [$ sRule ])) {
235
235
return ;
236
236
}
237
237
foreach ($ this ->rules [$ sRule ] as $ key => $ rule ) {
238
- if ($ rule === $ mRule ) {
238
+ if ($ rule === $ searchPattern ) {
239
239
unset($ this ->rules [$ sRule ][$ key ]);
240
240
}
241
241
}
@@ -245,9 +245,9 @@ public function removeRule($mRule): void
245
245
// or the search rule ends in “-” and the found rule starts with the search rule or equals it
246
246
// (without the trailing dash).
247
247
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 )))
251
251
) {
252
252
unset($ this ->rules [$ sName ]);
253
253
}
0 commit comments