Skip to content

Commit 0642f2b

Browse files
authored
[CLEANUP] Avoid Hungarian notation in DeclarationBlock (#1002)
Also fix some variable name collisions. Part of #756
1 parent b3abf1a commit 0642f2b

File tree

2 files changed

+24
-30
lines changed

2 files changed

+24
-30
lines changed

config/phpstan-baseline.neon

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -318,12 +318,6 @@ parameters:
318318
count: 1
319319
path: ../src/RuleSet/DeclarationBlock.php
320320

321-
-
322-
message: '#^Foreach overwrites \$mSelector with its value variable\.$#'
323-
identifier: foreach.valueOverwrite
324-
count: 1
325-
path: ../src/RuleSet/DeclarationBlock.php
326-
327321
-
328322
message: '#^Loose comparison via "\!\=" is not allowed\.$#'
329323
identifier: notEqual.notAllowed

src/RuleSet/DeclarationBlock.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class DeclarationBlock extends RuleSet
2727
/**
2828
* @var array<int, Selector|string>
2929
*/
30-
private $aSelectors = [];
30+
private $selectors = [];
3131

3232
/**
3333
* @param CSSList|null $list
@@ -76,38 +76,38 @@ public static function parse(ParserState $parserState, $list = null)
7676
}
7777

7878
/**
79-
* @param array<int, Selector|string>|string $mSelector
79+
* @param array<int, Selector|string>|string $selectors
8080
* @param CSSList|null $list
8181
*
8282
* @throws UnexpectedTokenException
8383
*/
84-
public function setSelectors($mSelector, $list = null): void
84+
public function setSelectors($selectors, $list = null): void
8585
{
86-
if (\is_array($mSelector)) {
87-
$this->aSelectors = $mSelector;
86+
if (\is_array($selectors)) {
87+
$this->selectors = $selectors;
8888
} else {
89-
$this->aSelectors = \explode(',', $mSelector);
89+
$this->selectors = \explode(',', $selectors);
9090
}
91-
foreach ($this->aSelectors as $key => $mSelector) {
92-
if (!($mSelector instanceof Selector)) {
91+
foreach ($this->selectors as $key => $selector) {
92+
if (!($selector instanceof Selector)) {
9393
if ($list === null || !($list instanceof KeyFrame)) {
94-
if (!Selector::isValid($mSelector)) {
94+
if (!Selector::isValid($selector)) {
9595
throw new UnexpectedTokenException(
9696
"Selector did not match '" . Selector::SELECTOR_VALIDATION_RX . "'.",
97-
$mSelector,
97+
$selectors,
9898
'custom'
9999
);
100100
}
101-
$this->aSelectors[$key] = new Selector($mSelector);
101+
$this->selectors[$key] = new Selector($selector);
102102
} else {
103-
if (!KeyframeSelector::isValid($mSelector)) {
103+
if (!KeyframeSelector::isValid($selector)) {
104104
throw new UnexpectedTokenException(
105105
"Selector did not match '" . KeyframeSelector::SELECTOR_VALIDATION_RX . "'.",
106-
$mSelector,
106+
$selector,
107107
'custom'
108108
);
109109
}
110-
$this->aSelectors[$key] = new KeyframeSelector($mSelector);
110+
$this->selectors[$key] = new KeyframeSelector($selector);
111111
}
112112
}
113113
}
@@ -116,16 +116,16 @@ public function setSelectors($mSelector, $list = null): void
116116
/**
117117
* Remove one of the selectors of the block.
118118
*
119-
* @param Selector|string $mSelector
119+
* @param Selector|string $selectorToRemove
120120
*/
121-
public function removeSelector($mSelector): bool
121+
public function removeSelector($selectorToRemove): bool
122122
{
123-
if ($mSelector instanceof Selector) {
124-
$mSelector = $mSelector->getSelector();
123+
if ($selectorToRemove instanceof Selector) {
124+
$selectorToRemove = $selectorToRemove->getSelector();
125125
}
126-
foreach ($this->aSelectors as $key => $selector) {
127-
if ($selector->getSelector() === $mSelector) {
128-
unset($this->aSelectors[$key]);
126+
foreach ($this->selectors as $key => $selector) {
127+
if ($selector->getSelector() === $selectorToRemove) {
128+
unset($this->selectors[$key]);
129129
return true;
130130
}
131131
}
@@ -137,7 +137,7 @@ public function removeSelector($mSelector): bool
137137
*/
138138
public function getSelectors()
139139
{
140-
return $this->aSelectors;
140+
return $this->selectors;
141141
}
142142

143143
/**
@@ -154,14 +154,14 @@ public function __toString(): string
154154
public function render(OutputFormat $outputFormat): string
155155
{
156156
$result = $outputFormat->comments($this);
157-
if (\count($this->aSelectors) === 0) {
157+
if (\count($this->selectors) === 0) {
158158
// If all the selectors have been removed, this declaration block becomes invalid
159159
throw new OutputException('Attempt to print declaration block with missing selector', $this->lineNumber);
160160
}
161161
$result .= $outputFormat->sBeforeDeclarationBlock;
162162
$result .= $outputFormat->implode(
163163
$outputFormat->spaceBeforeSelectorSeparator() . ',' . $outputFormat->spaceAfterSelectorSeparator(),
164-
$this->aSelectors
164+
$this->selectors
165165
);
166166
$result .= $outputFormat->sAfterDeclarationBlockSelectors;
167167
$result .= $outputFormat->spaceBeforeOpeningBrace() . '{';

0 commit comments

Comments
 (0)