@@ -103,15 +103,15 @@ public function getLineNo(): int
103
103
104
104
public function addRule (Rule $ ruleToAdd , ?Rule $ sibling = null ): void
105
105
{
106
- $ sRule = $ ruleToAdd ->getRule ();
107
- if (!isset ($ this ->rules [$ sRule ])) {
108
- $ this ->rules [$ sRule ] = [];
106
+ $ propertyName = $ ruleToAdd ->getRule ();
107
+ if (!isset ($ this ->rules [$ propertyName ])) {
108
+ $ this ->rules [$ propertyName ] = [];
109
109
}
110
110
111
- $ position = \count ($ this ->rules [$ sRule ]);
111
+ $ position = \count ($ this ->rules [$ propertyName ]);
112
112
113
113
if ($ sibling !== null ) {
114
- $ iSiblingPos = \array_search ($ sibling , $ this ->rules [$ sRule ], true );
114
+ $ iSiblingPos = \array_search ($ sibling , $ this ->rules [$ propertyName ], true );
115
115
if ($ iSiblingPos !== false ) {
116
116
$ position = $ iSiblingPos ;
117
117
$ ruleToAdd ->setPosition ($ sibling ->getLineNo (), $ sibling ->getColNo () - 1 );
@@ -127,7 +127,7 @@ public function addRule(Rule $ruleToAdd, ?Rule $sibling = null): void
127
127
}
128
128
}
129
129
130
- \array_splice ($ this ->rules [$ sRule ], $ position , 0 , [$ ruleToAdd ]);
130
+ \array_splice ($ this ->rules [$ propertyName ], $ position , 0 , [$ ruleToAdd ]);
131
131
}
132
132
133
133
/**
@@ -153,14 +153,15 @@ public function getRules($searchPattern = null)
153
153
}
154
154
/** @var array<int, Rule> $result */
155
155
$ result = [];
156
- foreach ($ this ->rules as $ sName => $ rules ) {
156
+ foreach ($ this ->rules as $ propertyName => $ 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
- !$ searchPattern || $ sName === $ searchPattern
160
+ !$ searchPattern || $ propertyName === $ searchPattern
161
161
|| (
162
162
\strrpos ($ searchPattern , '- ' ) === \strlen ($ searchPattern ) - \strlen ('- ' )
163
- && (\strpos ($ sName , $ searchPattern ) === 0 || $ sName === \substr ($ searchPattern , 0 , -1 ))
163
+ && (\strpos ($ propertyName , $ searchPattern ) === 0
164
+ || $ propertyName === \substr ($ searchPattern , 0 , -1 ))
164
165
)
165
166
) {
166
167
$ result = \array_merge ($ result , $ rules );
@@ -230,26 +231,27 @@ public function getRulesAssoc($searchPattern = null)
230
231
public function removeRule ($ searchPattern ): void
231
232
{
232
233
if ($ searchPattern instanceof Rule) {
233
- $ sRule = $ searchPattern ->getRule ();
234
- if (!isset ($ this ->rules [$ sRule ])) {
234
+ $ propertyName = $ searchPattern ->getRule ();
235
+ if (!isset ($ this ->rules [$ propertyName ])) {
235
236
return ;
236
237
}
237
- foreach ($ this ->rules [$ sRule ] as $ key => $ rule ) {
238
+ foreach ($ this ->rules [$ propertyName ] as $ key => $ rule ) {
238
239
if ($ rule === $ searchPattern ) {
239
- unset($ this ->rules [$ sRule ][$ key ]);
240
+ unset($ this ->rules [$ propertyName ][$ key ]);
240
241
}
241
242
}
242
243
} else {
243
- foreach ($ this ->rules as $ sName => $ rules ) {
244
+ foreach ($ this ->rules as $ propertyName => $ rules ) {
244
245
// Either no search rule is given or the search rule matches the found rule exactly
245
246
// or the search rule ends in “-” and the found rule starts with the search rule or equals it
246
247
// (without the trailing dash).
247
248
if (
248
- !$ searchPattern || $ sName === $ searchPattern
249
+ !$ searchPattern || $ propertyName === $ searchPattern
249
250
|| (\strrpos ($ searchPattern , '- ' ) === \strlen ($ searchPattern ) - \strlen ('- ' )
250
- && (\strpos ($ sName , $ searchPattern ) === 0 || $ sName === \substr ($ searchPattern , 0 , -1 )))
251
+ && (\strpos ($ propertyName , $ searchPattern ) === 0
252
+ || $ propertyName === \substr ($ searchPattern , 0 , -1 )))
251
253
) {
252
- unset($ this ->rules [$ sName ]);
254
+ unset($ this ->rules [$ propertyName ]);
253
255
}
254
256
}
255
257
}
0 commit comments