@@ -20,54 +20,54 @@ public function __construct(OutputFormat $outputFormat)
20
20
}
21
21
22
22
/**
23
- * @param non-empty-string $sName
23
+ * @param non-empty-string $name
24
24
*
25
25
* @throws \InvalidArgumentException
26
26
*/
27
- public function space (string $ sName ): string
27
+ public function space (string $ name ): string
28
28
{
29
- switch ($ sName ) {
29
+ switch ($ name ) {
30
30
case 'AfterRuleName ' :
31
- $ sSpaceString = $ this ->outputFormat ->getSpaceAfterRuleName ();
31
+ $ spaceString = $ this ->outputFormat ->getSpaceAfterRuleName ();
32
32
break ;
33
33
case 'BeforeRules ' :
34
- $ sSpaceString = $ this ->outputFormat ->getSpaceBeforeRules ();
34
+ $ spaceString = $ this ->outputFormat ->getSpaceBeforeRules ();
35
35
break ;
36
36
case 'AfterRules ' :
37
- $ sSpaceString = $ this ->outputFormat ->getSpaceAfterRules ();
37
+ $ spaceString = $ this ->outputFormat ->getSpaceAfterRules ();
38
38
break ;
39
39
case 'BetweenRules ' :
40
- $ sSpaceString = $ this ->outputFormat ->getSpaceBetweenRules ();
40
+ $ spaceString = $ this ->outputFormat ->getSpaceBetweenRules ();
41
41
break ;
42
42
case 'BeforeBlocks ' :
43
- $ sSpaceString = $ this ->outputFormat ->getSpaceBeforeBlocks ();
43
+ $ spaceString = $ this ->outputFormat ->getSpaceBeforeBlocks ();
44
44
break ;
45
45
case 'AfterBlocks ' :
46
- $ sSpaceString = $ this ->outputFormat ->getSpaceAfterBlocks ();
46
+ $ spaceString = $ this ->outputFormat ->getSpaceAfterBlocks ();
47
47
break ;
48
48
case 'BetweenBlocks ' :
49
- $ sSpaceString = $ this ->outputFormat ->getSpaceBetweenBlocks ();
49
+ $ spaceString = $ this ->outputFormat ->getSpaceBetweenBlocks ();
50
50
break ;
51
51
case 'BeforeSelectorSeparator ' :
52
- $ sSpaceString = $ this ->outputFormat ->getSpaceBeforeSelectorSeparator ();
52
+ $ spaceString = $ this ->outputFormat ->getSpaceBeforeSelectorSeparator ();
53
53
break ;
54
54
case 'AfterSelectorSeparator ' :
55
- $ sSpaceString = $ this ->outputFormat ->getSpaceAfterSelectorSeparator ();
55
+ $ spaceString = $ this ->outputFormat ->getSpaceAfterSelectorSeparator ();
56
56
break ;
57
57
case 'BeforeOpeningBrace ' :
58
- $ sSpaceString = $ this ->outputFormat ->getSpaceBeforeOpeningBrace ();
58
+ $ spaceString = $ this ->outputFormat ->getSpaceBeforeOpeningBrace ();
59
59
break ;
60
60
case 'BeforeListArgumentSeparator ' :
61
- $ sSpaceString = $ this ->outputFormat ->getSpaceBeforeListArgumentSeparator ();
61
+ $ spaceString = $ this ->outputFormat ->getSpaceBeforeListArgumentSeparator ();
62
62
break ;
63
63
case 'AfterListArgumentSeparator ' :
64
- $ sSpaceString = $ this ->outputFormat ->getSpaceAfterListArgumentSeparator ();
64
+ $ spaceString = $ this ->outputFormat ->getSpaceAfterListArgumentSeparator ();
65
65
break ;
66
66
default :
67
- throw new \InvalidArgumentException ("Unknown space type: $ sName " , 1740049248 );
67
+ throw new \InvalidArgumentException ("Unknown space type: $ name " , 1740049248 );
68
68
}
69
69
70
- return $ this ->prepareSpace ($ sSpaceString );
70
+ return $ this ->prepareSpace ($ spaceString );
71
71
}
72
72
73
73
public function spaceAfterRuleName (): string
@@ -143,62 +143,62 @@ public function spaceBeforeOpeningBrace(): string
143
143
/**
144
144
* Runs the given code, either swallowing or passing exceptions, depending on the `ignoreExceptions` setting.
145
145
*/
146
- public function safely (callable $ cCode ): ?string
146
+ public function safely (callable $ callable ): ?string
147
147
{
148
148
if ($ this ->outputFormat ->getIgnoreExceptions ()) {
149
149
// If output exceptions are ignored, run the code with exception guards
150
150
try {
151
- return $ cCode ();
151
+ return $ callable ();
152
152
} catch (OutputException $ e ) {
153
153
return null ;
154
154
} // Do nothing
155
155
} else {
156
156
// Run the code as-is
157
- return $ cCode ();
157
+ return $ callable ();
158
158
}
159
159
}
160
160
161
161
/**
162
162
* Clone of the `implode` function, but calls `render` with the current output format instead of `__toString()`.
163
163
*
164
- * @param array<array-key, Renderable|string> $aValues
164
+ * @param array<array-key, Renderable|string> $values
165
165
*/
166
- public function implode (string $ sSeparator , array $ aValues , bool $ bIncreaseLevel = false ): string
166
+ public function implode (string $ separator , array $ values , bool $ increaseLevel = false ): string
167
167
{
168
168
$ result = '' ;
169
169
$ outputFormat = $ this ->outputFormat ;
170
- if ($ bIncreaseLevel ) {
170
+ if ($ increaseLevel ) {
171
171
$ outputFormat = $ outputFormat ->nextLevel ();
172
172
}
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 ;
177
177
} else {
178
- $ result .= $ sSeparator ;
178
+ $ result .= $ separator ;
179
179
}
180
- if ($ mValue instanceof Renderable) {
181
- $ result .= $ mValue ->render ($ outputFormat );
180
+ if ($ value instanceof Renderable) {
181
+ $ result .= $ value ->render ($ outputFormat );
182
182
} else {
183
- $ result .= $ mValue ;
183
+ $ result .= $ value ;
184
184
}
185
185
}
186
186
return $ result ;
187
187
}
188
188
189
- public function removeLastSemicolon (string $ sString ): string
189
+ public function removeLastSemicolon (string $ string ): string
190
190
{
191
191
if ($ this ->outputFormat ->getSemicolonAfterLastRule ()) {
192
- return $ sString ;
192
+ return $ string ;
193
193
}
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 ];
197
197
}
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 );
202
202
}
203
203
204
204
public function comments (Commentable $ commentable ): string
@@ -209,18 +209,18 @@ public function comments(Commentable $commentable): string
209
209
210
210
$ result = '' ;
211
211
$ comments = $ commentable ->getComments ();
212
- $ iLastCommentIndex = \count ($ comments ) - 1 ;
212
+ $ lastCommentIndex = \count ($ comments ) - 1 ;
213
213
214
214
foreach ($ comments as $ i => $ comment ) {
215
215
$ result .= $ comment ->render ($ this ->outputFormat );
216
- $ result .= $ i === $ iLastCommentIndex ? $ this ->spaceAfterBlocks () : $ this ->spaceBetweenBlocks ();
216
+ $ result .= $ i === $ lastCommentIndex ? $ this ->spaceAfterBlocks () : $ this ->spaceBetweenBlocks ();
217
217
}
218
218
return $ result ;
219
219
}
220
220
221
- private function prepareSpace (string $ sSpaceString ): string
221
+ private function prepareSpace (string $ spaceString ): string
222
222
{
223
- return \str_replace ("\n" , "\n" . $ this ->indent (), $ sSpaceString );
223
+ return \str_replace ("\n" , "\n" . $ this ->indent (), $ spaceString );
224
224
}
225
225
226
226
private function indent (): string
0 commit comments