@@ -103,15 +103,15 @@ public function getLineNo(): int
103103
104104 public function addRule (Rule $ ruleToAdd , ?Rule $ sibling = null ): void
105105 {
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 ] = [];
109109 }
110110
111- $ position = \count ($ this ->rules [$ sRule ]);
111+ $ position = \count ($ this ->rules [$ propertyName ]);
112112
113113 if ($ sibling !== null ) {
114- $ iSiblingPos = \array_search ($ sibling , $ this ->rules [$ sRule ], true );
114+ $ iSiblingPos = \array_search ($ sibling , $ this ->rules [$ propertyName ], true );
115115 if ($ iSiblingPos !== false ) {
116116 $ position = $ iSiblingPos ;
117117 $ ruleToAdd ->setPosition ($ sibling ->getLineNo (), $ sibling ->getColNo () - 1 );
@@ -127,7 +127,7 @@ public function addRule(Rule $ruleToAdd, ?Rule $sibling = null): void
127127 }
128128 }
129129
130- \array_splice ($ this ->rules [$ sRule ], $ position , 0 , [$ ruleToAdd ]);
130+ \array_splice ($ this ->rules [$ propertyName ], $ position , 0 , [$ ruleToAdd ]);
131131 }
132132
133133 /**
@@ -153,14 +153,15 @@ public function getRules($searchPattern = null)
153153 }
154154 /** @var array<int, Rule> $result */
155155 $ result = [];
156- foreach ($ this ->rules as $ sName => $ rules ) {
156+ foreach ($ this ->rules as $ propertyName => $ 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- !$ searchPattern || $ sName === $ searchPattern
160+ !$ searchPattern || $ propertyName === $ searchPattern
161161 || (
162162 \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 ))
164165 )
165166 ) {
166167 $ result = \array_merge ($ result , $ rules );
@@ -230,26 +231,27 @@ public function getRulesAssoc($searchPattern = null)
230231 public function removeRule ($ searchPattern ): void
231232 {
232233 if ($ searchPattern instanceof Rule) {
233- $ sRule = $ searchPattern ->getRule ();
234- if (!isset ($ this ->rules [$ sRule ])) {
234+ $ propertyName = $ searchPattern ->getRule ();
235+ if (!isset ($ this ->rules [$ propertyName ])) {
235236 return ;
236237 }
237- foreach ($ this ->rules [$ sRule ] as $ key => $ rule ) {
238+ foreach ($ this ->rules [$ propertyName ] as $ key => $ rule ) {
238239 if ($ rule === $ searchPattern ) {
239- unset($ this ->rules [$ sRule ][$ key ]);
240+ unset($ this ->rules [$ propertyName ][$ key ]);
240241 }
241242 }
242243 } else {
243- foreach ($ this ->rules as $ sName => $ rules ) {
244+ foreach ($ this ->rules as $ propertyName => $ rules ) {
244245 // Either no search rule is given or the search rule matches the found rule exactly
245246 // or the search rule ends in “-” and the found rule starts with the search rule or equals it
246247 // (without the trailing dash).
247248 if (
248- !$ searchPattern || $ sName === $ searchPattern
249+ !$ searchPattern || $ propertyName === $ searchPattern
249250 || (\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 )))
251253 ) {
252- unset($ this ->rules [$ sName ]);
254+ unset($ this ->rules [$ propertyName ]);
253255 }
254256 }
255257 }
0 commit comments