Skip to content

Commit c22d738

Browse files
authored
[CLEANUP] Avoid Hungarian notation for rules (#1024)
Part of #756
1 parent 58ef076 commit c22d738

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

src/RuleSet/RuleSet.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ abstract class RuleSet implements Renderable, Commentable
2727
/**
2828
* @var array<string, Rule>
2929
*/
30-
private $aRules = [];
30+
private $rules = [];
3131

3232
/**
3333
* @var int<0, max>
@@ -104,14 +104,14 @@ public function getLineNo(): int
104104
public function addRule(Rule $rule, ?Rule $oSibling = null): void
105105
{
106106
$sRule = $rule->getRule();
107-
if (!isset($this->aRules[$sRule])) {
108-
$this->aRules[$sRule] = [];
107+
if (!isset($this->rules[$sRule])) {
108+
$this->rules[$sRule] = [];
109109
}
110110

111-
$position = \count($this->aRules[$sRule]);
111+
$position = \count($this->rules[$sRule]);
112112

113113
if ($oSibling !== null) {
114-
$iSiblingPos = \array_search($oSibling, $this->aRules[$sRule], true);
114+
$iSiblingPos = \array_search($oSibling, $this->rules[$sRule], true);
115115
if ($iSiblingPos !== false) {
116116
$position = $iSiblingPos;
117117
$rule->setPosition($oSibling->getLineNo(), $oSibling->getColNo() - 1);
@@ -127,7 +127,7 @@ public function addRule(Rule $rule, ?Rule $oSibling = null): void
127127
}
128128
}
129129

130-
\array_splice($this->aRules[$sRule], $position, 0, [$rule]);
130+
\array_splice($this->rules[$sRule], $position, 0, [$rule]);
131131
}
132132

133133
/**
@@ -153,7 +153,7 @@ public function getRules($mRule = null)
153153
}
154154
/** @var array<int, Rule> $result */
155155
$result = [];
156-
foreach ($this->aRules as $sName => $aRules) {
156+
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 (
@@ -163,7 +163,7 @@ public function getRules($mRule = null)
163163
&& (\strpos($sName, $mRule) === 0 || $sName === \substr($mRule, 0, -1))
164164
)
165165
) {
166-
$result = \array_merge($result, $aRules);
166+
$result = \array_merge($result, $rules);
167167
}
168168
}
169169
\usort($result, static function (Rule $first, Rule $second): int {
@@ -178,12 +178,12 @@ public function getRules($mRule = null)
178178
/**
179179
* Overrides all the rules of this set.
180180
*
181-
* @param array<array-key, Rule> $aRules The rules to override with.
181+
* @param array<array-key, Rule> $rules The rules to override with.
182182
*/
183-
public function setRules(array $aRules): void
183+
public function setRules(array $rules): void
184184
{
185-
$this->aRules = [];
186-
foreach ($aRules as $rule) {
185+
$this->rules = [];
186+
foreach ($rules as $rule) {
187187
$this->addRule($rule);
188188
}
189189
}
@@ -231,16 +231,16 @@ public function removeRule($mRule): void
231231
{
232232
if ($mRule instanceof Rule) {
233233
$sRule = $mRule->getRule();
234-
if (!isset($this->aRules[$sRule])) {
234+
if (!isset($this->rules[$sRule])) {
235235
return;
236236
}
237-
foreach ($this->aRules[$sRule] as $key => $rule) {
237+
foreach ($this->rules[$sRule] as $key => $rule) {
238238
if ($rule === $mRule) {
239-
unset($this->aRules[$sRule][$key]);
239+
unset($this->rules[$sRule][$key]);
240240
}
241241
}
242242
} else {
243-
foreach ($this->aRules as $sName => $aRules) {
243+
foreach ($this->rules as $sName => $rules) {
244244
// Either no search rule is given or the search rule matches the found rule exactly
245245
// or the search rule ends in “-” and the found rule starts with the search rule or equals it
246246
// (without the trailing dash).
@@ -249,7 +249,7 @@ public function removeRule($mRule): void
249249
|| (\strrpos($mRule, '-') === \strlen($mRule) - \strlen('-')
250250
&& (\strpos($sName, $mRule) === 0 || $sName === \substr($mRule, 0, -1)))
251251
) {
252-
unset($this->aRules[$sName]);
252+
unset($this->rules[$sName]);
253253
}
254254
}
255255
}
@@ -271,8 +271,8 @@ protected function renderRules(OutputFormat $outputFormat)
271271
$result = '';
272272
$isFirst = true;
273273
$oNextLevel = $outputFormat->nextLevel();
274-
foreach ($this->aRules as $aRules) {
275-
foreach ($aRules as $rule) {
274+
foreach ($this->rules as $rules) {
275+
foreach ($rules as $rule) {
276276
$sRendered = $oNextLevel->safely(static function () use ($rule, $oNextLevel): string {
277277
return $rule->render($oNextLevel);
278278
});

0 commit comments

Comments
 (0)