@@ -114,18 +114,18 @@ public function addRule(Rule $ruleToAdd, ?Rule $sibling = null): void
114
114
$ position = \count ($ this ->rules [$ propertyName ]);
115
115
116
116
if ($ sibling !== null ) {
117
- $ iSiblingPos = \array_search ($ sibling , $ this ->rules [$ propertyName ], true );
118
- if ($ iSiblingPos !== false ) {
119
- $ position = $ iSiblingPos ;
117
+ $ siblingPosition = \array_search ($ sibling , $ this ->rules [$ propertyName ], true );
118
+ if ($ siblingPosition !== false ) {
119
+ $ position = $ siblingPosition ;
120
120
$ ruleToAdd ->setPosition ($ sibling ->getLineNo (), $ sibling ->getColNo () - 1 );
121
121
}
122
122
}
123
123
if ($ ruleToAdd ->getLineNo () === 0 && $ ruleToAdd ->getColNo () === 0 ) {
124
124
//this node is added manually, give it the next best line
125
125
$ rules = $ this ->getRules ();
126
- $ pos = \count ($ rules );
127
- if ($ pos > 0 ) {
128
- $ last = $ rules [$ pos - 1 ];
126
+ $ rulesCount = \count ($ rules );
127
+ if ($ rulesCount > 0 ) {
128
+ $ last = $ rules [$ rulesCount - 1 ];
129
129
$ ruleToAdd ->setPosition ($ last ->getLineNo () + 1 , 0 );
130
130
}
131
131
}
@@ -176,6 +176,7 @@ public function getRules($searchPattern = null)
176
176
}
177
177
return $ first ->getLineNo () - $ second ->getLineNo ();
178
178
});
179
+
179
180
return $ result ;
180
181
}
181
182
@@ -234,13 +235,13 @@ public function getRulesAssoc($searchPattern = null)
234
235
public function removeRule ($ searchPattern ): void
235
236
{
236
237
if ($ searchPattern instanceof Rule) {
237
- $ propertyName = $ searchPattern ->getRule ();
238
- if (!isset ($ this ->rules [$ propertyName ])) {
238
+ $ nameOfPropertyToRemove = $ searchPattern ->getRule ();
239
+ if (!isset ($ this ->rules [$ nameOfPropertyToRemove ])) {
239
240
return ;
240
241
}
241
- foreach ($ this ->rules [$ propertyName ] as $ key => $ rule ) {
242
+ foreach ($ this ->rules [$ nameOfPropertyToRemove ] as $ key => $ rule ) {
242
243
if ($ rule === $ searchPattern ) {
243
- unset($ this ->rules [$ propertyName ][$ key ]);
244
+ unset($ this ->rules [$ nameOfPropertyToRemove ][$ key ]);
244
245
}
245
246
}
246
247
} else {
0 commit comments