Skip to content

Commit 2f0e48f

Browse files
authored
[CLEANUP] Avoid Hungarian notation in OutputFormatter (#969)
Part of #756
1 parent 981464c commit 2f0e48f

File tree

1 file changed

+44
-44
lines changed

1 file changed

+44
-44
lines changed

src/OutputFormatter.php

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -20,54 +20,54 @@ public function __construct(OutputFormat $outputFormat)
2020
}
2121

2222
/**
23-
* @param non-empty-string $sName
23+
* @param non-empty-string $name
2424
*
2525
* @throws \InvalidArgumentException
2626
*/
27-
public function space(string $sName): string
27+
public function space(string $name): string
2828
{
29-
switch ($sName) {
29+
switch ($name) {
3030
case 'AfterRuleName':
31-
$sSpaceString = $this->outputFormat->getSpaceAfterRuleName();
31+
$spaceString = $this->outputFormat->getSpaceAfterRuleName();
3232
break;
3333
case 'BeforeRules':
34-
$sSpaceString = $this->outputFormat->getSpaceBeforeRules();
34+
$spaceString = $this->outputFormat->getSpaceBeforeRules();
3535
break;
3636
case 'AfterRules':
37-
$sSpaceString = $this->outputFormat->getSpaceAfterRules();
37+
$spaceString = $this->outputFormat->getSpaceAfterRules();
3838
break;
3939
case 'BetweenRules':
40-
$sSpaceString = $this->outputFormat->getSpaceBetweenRules();
40+
$spaceString = $this->outputFormat->getSpaceBetweenRules();
4141
break;
4242
case 'BeforeBlocks':
43-
$sSpaceString = $this->outputFormat->getSpaceBeforeBlocks();
43+
$spaceString = $this->outputFormat->getSpaceBeforeBlocks();
4444
break;
4545
case 'AfterBlocks':
46-
$sSpaceString = $this->outputFormat->getSpaceAfterBlocks();
46+
$spaceString = $this->outputFormat->getSpaceAfterBlocks();
4747
break;
4848
case 'BetweenBlocks':
49-
$sSpaceString = $this->outputFormat->getSpaceBetweenBlocks();
49+
$spaceString = $this->outputFormat->getSpaceBetweenBlocks();
5050
break;
5151
case 'BeforeSelectorSeparator':
52-
$sSpaceString = $this->outputFormat->getSpaceBeforeSelectorSeparator();
52+
$spaceString = $this->outputFormat->getSpaceBeforeSelectorSeparator();
5353
break;
5454
case 'AfterSelectorSeparator':
55-
$sSpaceString = $this->outputFormat->getSpaceAfterSelectorSeparator();
55+
$spaceString = $this->outputFormat->getSpaceAfterSelectorSeparator();
5656
break;
5757
case 'BeforeOpeningBrace':
58-
$sSpaceString = $this->outputFormat->getSpaceBeforeOpeningBrace();
58+
$spaceString = $this->outputFormat->getSpaceBeforeOpeningBrace();
5959
break;
6060
case 'BeforeListArgumentSeparator':
61-
$sSpaceString = $this->outputFormat->getSpaceBeforeListArgumentSeparator();
61+
$spaceString = $this->outputFormat->getSpaceBeforeListArgumentSeparator();
6262
break;
6363
case 'AfterListArgumentSeparator':
64-
$sSpaceString = $this->outputFormat->getSpaceAfterListArgumentSeparator();
64+
$spaceString = $this->outputFormat->getSpaceAfterListArgumentSeparator();
6565
break;
6666
default:
67-
throw new \InvalidArgumentException("Unknown space type: $sName", 1740049248);
67+
throw new \InvalidArgumentException("Unknown space type: $name", 1740049248);
6868
}
6969

70-
return $this->prepareSpace($sSpaceString);
70+
return $this->prepareSpace($spaceString);
7171
}
7272

7373
public function spaceAfterRuleName(): string
@@ -143,62 +143,62 @@ public function spaceBeforeOpeningBrace(): string
143143
/**
144144
* Runs the given code, either swallowing or passing exceptions, depending on the `ignoreExceptions` setting.
145145
*/
146-
public function safely(callable $cCode): ?string
146+
public function safely(callable $callable): ?string
147147
{
148148
if ($this->outputFormat->getIgnoreExceptions()) {
149149
// If output exceptions are ignored, run the code with exception guards
150150
try {
151-
return $cCode();
151+
return $callable();
152152
} catch (OutputException $e) {
153153
return null;
154154
} // Do nothing
155155
} else {
156156
// Run the code as-is
157-
return $cCode();
157+
return $callable();
158158
}
159159
}
160160

161161
/**
162162
* Clone of the `implode` function, but calls `render` with the current output format instead of `__toString()`.
163163
*
164-
* @param array<array-key, Renderable|string> $aValues
164+
* @param array<array-key, Renderable|string> $values
165165
*/
166-
public function implode(string $sSeparator, array $aValues, bool $bIncreaseLevel = false): string
166+
public function implode(string $separator, array $values, bool $increaseLevel = false): string
167167
{
168168
$result = '';
169169
$outputFormat = $this->outputFormat;
170-
if ($bIncreaseLevel) {
170+
if ($increaseLevel) {
171171
$outputFormat = $outputFormat->nextLevel();
172172
}
173-
$bIsFirst = true;
174-
foreach ($aValues as $mValue) {
175-
if ($bIsFirst) {
176-
$bIsFirst = false;
173+
$isFirst = true;
174+
foreach ($values as $value) {
175+
if ($isFirst) {
176+
$isFirst = false;
177177
} else {
178-
$result .= $sSeparator;
178+
$result .= $separator;
179179
}
180-
if ($mValue instanceof Renderable) {
181-
$result .= $mValue->render($outputFormat);
180+
if ($value instanceof Renderable) {
181+
$result .= $value->render($outputFormat);
182182
} else {
183-
$result .= $mValue;
183+
$result .= $value;
184184
}
185185
}
186186
return $result;
187187
}
188188

189-
public function removeLastSemicolon(string $sString): string
189+
public function removeLastSemicolon(string $string): string
190190
{
191191
if ($this->outputFormat->getSemicolonAfterLastRule()) {
192-
return $sString;
192+
return $string;
193193
}
194-
$sString = \explode(';', $sString);
195-
if (\count($sString) < 2) {
196-
return $sString[0];
194+
$parts = \explode(';', $string);
195+
if (\count($parts) < 2) {
196+
return $parts[0];
197197
}
198-
$sLast = \array_pop($sString);
199-
$sNextToLast = \array_pop($sString);
200-
\array_push($sString, $sNextToLast . $sLast);
201-
return \implode(';', $sString);
198+
$sLast = \array_pop($parts);
199+
$sNextToLast = \array_pop($parts);
200+
\array_push($parts, $sNextToLast . $sLast);
201+
return \implode(';', $parts);
202202
}
203203

204204
public function comments(Commentable $commentable): string
@@ -209,18 +209,18 @@ public function comments(Commentable $commentable): string
209209

210210
$result = '';
211211
$comments = $commentable->getComments();
212-
$iLastCommentIndex = \count($comments) - 1;
212+
$lastCommentIndex = \count($comments) - 1;
213213

214214
foreach ($comments as $i => $comment) {
215215
$result .= $comment->render($this->outputFormat);
216-
$result .= $i === $iLastCommentIndex ? $this->spaceAfterBlocks() : $this->spaceBetweenBlocks();
216+
$result .= $i === $lastCommentIndex ? $this->spaceAfterBlocks() : $this->spaceBetweenBlocks();
217217
}
218218
return $result;
219219
}
220220

221-
private function prepareSpace(string $sSpaceString): string
221+
private function prepareSpace(string $spaceString): string
222222
{
223-
return \str_replace("\n", "\n" . $this->indent(), $sSpaceString);
223+
return \str_replace("\n", "\n" . $this->indent(), $spaceString);
224224
}
225225

226226
private function indent(): string

0 commit comments

Comments
 (0)