@@ -64,7 +64,7 @@ public function __construct($lineNumber = 0)
64
64
*/
65
65
public static function parseList (ParserState $ parserState , CSSList $ list ): void
66
66
{
67
- $ bIsRoot = $ list instanceof Document;
67
+ $ isRoot = $ list instanceof Document;
68
68
if (\is_string ($ parserState )) {
69
69
$ parserState = new ParserState ($ parserState , Settings::create ());
70
70
}
@@ -93,7 +93,7 @@ public static function parseList(ParserState $parserState, CSSList $list): void
93
93
$ comments = $ parserState ->consumeWhiteSpace ();
94
94
}
95
95
$ list ->addComments ($ comments );
96
- if (!$ bIsRoot && !$ usesLenientParsing ) {
96
+ if (!$ isRoot && !$ usesLenientParsing ) {
97
97
throw new SourceException ('Unexpected end of document ' , $ parserState ->currentLine ());
98
98
}
99
99
}
@@ -107,11 +107,11 @@ public static function parseList(ParserState $parserState, CSSList $list): void
107
107
*/
108
108
private static function parseListItem (ParserState $ parserState , CSSList $ list )
109
109
{
110
- $ bIsRoot = $ list instanceof Document;
110
+ $ isRoot = $ list instanceof Document;
111
111
if ($ parserState ->comes ('@ ' )) {
112
- $ oAtRule = self ::parseAtRule ($ parserState );
113
- if ($ oAtRule instanceof Charset) {
114
- if (!$ bIsRoot ) {
112
+ $ atRule = self ::parseAtRule ($ parserState );
113
+ if ($ atRule instanceof Charset) {
114
+ if (!$ isRoot ) {
115
115
throw new UnexpectedTokenException (
116
116
'@charset may only occur in root document ' ,
117
117
'' ,
@@ -127,11 +127,11 @@ private static function parseListItem(ParserState $parserState, CSSList $list)
127
127
$ parserState ->currentLine ()
128
128
);
129
129
}
130
- $ parserState ->setCharset ($ oAtRule ->getCharset ());
130
+ $ parserState ->setCharset ($ atRule ->getCharset ());
131
131
}
132
- return $ oAtRule ;
132
+ return $ atRule ;
133
133
} elseif ($ parserState ->comes ('} ' )) {
134
- if ($ bIsRoot ) {
134
+ if ($ isRoot ) {
135
135
if ($ parserState ->getSettings ()->bLenientParsing ) {
136
136
return DeclarationBlock::parse ($ parserState );
137
137
} else {
@@ -157,7 +157,7 @@ private static function parseAtRule(ParserState $parserState)
157
157
{
158
158
$ parserState ->consume ('@ ' );
159
159
$ identifier = $ parserState ->parseIdentifier ();
160
- $ iIdentifierLineNum = $ parserState ->currentLine ();
160
+ $ identifierLineNumber = $ parserState ->currentLine ();
161
161
$ parserState ->consumeWhiteSpace ();
162
162
if ($ identifier === 'import ' ) {
163
163
$ location = URL ::parse ($ parserState );
@@ -170,14 +170,14 @@ private static function parseAtRule(ParserState $parserState)
170
170
}
171
171
}
172
172
$ parserState ->consumeUntil (['; ' , ParserState::EOF ], true , true );
173
- return new Import ($ location , $ mediaQuery , $ iIdentifierLineNum );
173
+ return new Import ($ location , $ mediaQuery , $ identifierLineNumber );
174
174
} elseif ($ identifier === 'charset ' ) {
175
- $ oCharsetString = CSSString::parse ($ parserState );
175
+ $ charsetString = CSSString::parse ($ parserState );
176
176
$ parserState ->consumeWhiteSpace ();
177
177
$ parserState ->consumeUntil (['; ' , ParserState::EOF ], true , true );
178
- return new Charset ($ oCharsetString , $ iIdentifierLineNum );
178
+ return new Charset ($ charsetString , $ identifierLineNumber );
179
179
} elseif (self ::identifierIs ($ identifier , 'keyframes ' )) {
180
- $ result = new KeyFrame ($ iIdentifierLineNum );
180
+ $ result = new KeyFrame ($ identifierLineNumber );
181
181
$ result ->setVendorKeyFrame ($ identifier );
182
182
$ result ->setAnimationName (\trim ($ parserState ->consumeUntil ('{ ' , false , true )));
183
183
CSSList::parseList ($ parserState , $ result );
@@ -187,52 +187,52 @@ private static function parseAtRule(ParserState $parserState)
187
187
return $ result ;
188
188
} elseif ($ identifier === 'namespace ' ) {
189
189
$ sPrefix = null ;
190
- $ mUrl = Value::parsePrimitiveValue ($ parserState );
190
+ $ url = Value::parsePrimitiveValue ($ parserState );
191
191
if (!$ parserState ->comes ('; ' )) {
192
- $ sPrefix = $ mUrl ;
193
- $ mUrl = Value::parsePrimitiveValue ($ parserState );
192
+ $ sPrefix = $ url ;
193
+ $ url = Value::parsePrimitiveValue ($ parserState );
194
194
}
195
195
$ parserState ->consumeUntil (['; ' , ParserState::EOF ], true , true );
196
196
if ($ sPrefix !== null && !\is_string ($ sPrefix )) {
197
- throw new UnexpectedTokenException ('Wrong namespace prefix ' , $ sPrefix , 'custom ' , $ iIdentifierLineNum );
197
+ throw new UnexpectedTokenException ('Wrong namespace prefix ' , $ sPrefix , 'custom ' , $ identifierLineNumber );
198
198
}
199
- if (!($ mUrl instanceof CSSString || $ mUrl instanceof URL )) {
199
+ if (!($ url instanceof CSSString || $ url instanceof URL )) {
200
200
throw new UnexpectedTokenException (
201
201
'Wrong namespace url of invalid type ' ,
202
- $ mUrl ,
202
+ $ url ,
203
203
'custom ' ,
204
- $ iIdentifierLineNum
204
+ $ identifierLineNumber
205
205
);
206
206
}
207
- return new CSSNamespace ($ mUrl , $ sPrefix , $ iIdentifierLineNum );
207
+ return new CSSNamespace ($ url , $ sPrefix , $ identifierLineNumber );
208
208
} else {
209
209
// Unknown other at rule (font-face or such)
210
- $ sArgs = \trim ($ parserState ->consumeUntil ('{ ' , false , true ));
211
- if (\substr_count ($ sArgs , '( ' ) != \substr_count ($ sArgs , ') ' )) {
210
+ $ arguments = \trim ($ parserState ->consumeUntil ('{ ' , false , true ));
211
+ if (\substr_count ($ arguments , '( ' ) != \substr_count ($ arguments , ') ' )) {
212
212
if ($ parserState ->getSettings ()->bLenientParsing ) {
213
213
return null ;
214
214
} else {
215
215
throw new SourceException ('Unmatched brace count in media query ' , $ parserState ->currentLine ());
216
216
}
217
217
}
218
- $ bUseRuleSet = true ;
219
- foreach (\explode ('/ ' , AtRule::BLOCK_RULES ) as $ sBlockRuleName ) {
220
- if (self ::identifierIs ($ identifier , $ sBlockRuleName )) {
221
- $ bUseRuleSet = false ;
218
+ $ useRuleSet = true ;
219
+ foreach (\explode ('/ ' , AtRule::BLOCK_RULES ) as $ blockRuleName ) {
220
+ if (self ::identifierIs ($ identifier , $ blockRuleName )) {
221
+ $ useRuleSet = false ;
222
222
break ;
223
223
}
224
224
}
225
- if ($ bUseRuleSet ) {
226
- $ oAtRule = new AtRuleSet ($ identifier , $ sArgs , $ iIdentifierLineNum );
227
- RuleSet::parseRuleSet ($ parserState , $ oAtRule );
225
+ if ($ useRuleSet ) {
226
+ $ atRule = new AtRuleSet ($ identifier , $ arguments , $ identifierLineNumber );
227
+ RuleSet::parseRuleSet ($ parserState , $ atRule );
228
228
} else {
229
- $ oAtRule = new AtRuleBlockList ($ identifier , $ sArgs , $ iIdentifierLineNum );
230
- CSSList::parseList ($ parserState , $ oAtRule );
229
+ $ atRule = new AtRuleBlockList ($ identifier , $ arguments , $ identifierLineNumber );
230
+ CSSList::parseList ($ parserState , $ atRule );
231
231
if ($ parserState ->comes ('} ' )) {
232
232
$ parserState ->consume ('} ' );
233
233
}
234
234
}
235
- return $ oAtRule ;
235
+ return $ atRule ;
236
236
}
237
237
}
238
238
@@ -242,10 +242,10 @@ private static function parseAtRule(ParserState $parserState)
242
242
*
243
243
* @param string $identifier
244
244
*/
245
- private static function identifierIs ($ identifier , string $ sMatch ): bool
245
+ private static function identifierIs ($ identifier , string $ match ): bool
246
246
{
247
- return (\strcasecmp ($ identifier , $ sMatch ) === 0 )
248
- ?: \preg_match ("/^(- \\w+-)? $ sMatch $/i " , $ identifier ) === 1 ;
247
+ return (\strcasecmp ($ identifier , $ match ) === 0 )
248
+ ?: \preg_match ("/^(- \\w+-)? $ match $/i " , $ identifier ) === 1 ;
249
249
}
250
250
251
251
/**
@@ -279,13 +279,13 @@ public function append($item): void
279
279
/**
280
280
* Splices the list of contents.
281
281
*
282
- * @param int $iOffset
283
- * @param int $iLength
284
- * @param array<int, RuleSet|CSSList|Import|Charset> $mReplacement
282
+ * @param int $offset
283
+ * @param int $length
284
+ * @param array<int, RuleSet|CSSList|Import|Charset> $replacement
285
285
*/
286
- public function splice ($ iOffset , $ iLength = null , $ mReplacement = null ): void
286
+ public function splice ($ offset , $ length = null , $ replacement = null ): void
287
287
{
288
- \array_splice ($ this ->contents , $ iOffset , $ iLength , $ mReplacement );
288
+ \array_splice ($ this ->contents , $ offset , $ length , $ replacement );
289
289
}
290
290
291
291
/**
@@ -360,36 +360,36 @@ public function setContents(array $contents): void
360
360
/**
361
361
* Removes a declaration block from the CSS list if it matches all given selectors.
362
362
*
363
- * @param DeclarationBlock|array<array-key, Selector>|string $mSelector the selectors to match
364
- * @param bool $bRemoveAll whether to stop at the first declaration block found or remove all blocks
363
+ * @param DeclarationBlock|array<array-key, Selector>|string $selectors the selectors to match
364
+ * @param bool $removeAll whether to stop at the first declaration block found or remove all blocks
365
365
*/
366
- public function removeDeclarationBlockBySelector ($ mSelector , $ bRemoveAll = false ): void
366
+ public function removeDeclarationBlockBySelector ($ selectors , $ removeAll = false ): void
367
367
{
368
- if ($ mSelector instanceof DeclarationBlock) {
369
- $ mSelector = $ mSelector ->getSelectors ();
368
+ if ($ selectors instanceof DeclarationBlock) {
369
+ $ selectors = $ selectors ->getSelectors ();
370
370
}
371
- if (!\is_array ($ mSelector )) {
372
- $ mSelector = \explode (', ' , $ mSelector );
371
+ if (!\is_array ($ selectors )) {
372
+ $ selectors = \explode (', ' , $ selectors );
373
373
}
374
- foreach ($ mSelector as $ key => &$ mSel ) {
375
- if (!($ mSel instanceof Selector)) {
376
- if (!Selector::isValid ($ mSel )) {
374
+ foreach ($ selectors as $ key => &$ selector ) {
375
+ if (!($ selector instanceof Selector)) {
376
+ if (!Selector::isValid ($ selector )) {
377
377
throw new UnexpectedTokenException (
378
378
"Selector did not match ' " . Selector::SELECTOR_VALIDATION_RX . "'. " ,
379
- $ mSel ,
379
+ $ selector ,
380
380
'custom '
381
381
);
382
382
}
383
- $ mSel = new Selector ($ mSel );
383
+ $ selector = new Selector ($ selector );
384
384
}
385
385
}
386
386
foreach ($ this ->contents as $ key => $ item ) {
387
387
if (!($ item instanceof DeclarationBlock)) {
388
388
continue ;
389
389
}
390
- if ($ item ->getSelectors () == $ mSelector ) {
390
+ if ($ item ->getSelectors () == $ selectors ) {
391
391
unset($ this ->contents [$ key ]);
392
- if (!$ bRemoveAll ) {
392
+ if (!$ removeAll ) {
393
393
return ;
394
394
}
395
395
}
@@ -406,34 +406,34 @@ public function __toString(): string
406
406
*/
407
407
protected function renderListContents (OutputFormat $ oOutputFormat )
408
408
{
409
- $ sResult = '' ;
410
- $ bIsFirst = true ;
411
- $ oNextLevel = $ oOutputFormat ;
409
+ $ result = '' ;
410
+ $ isFirst = true ;
411
+ $ nextLevelFormat = $ oOutputFormat ;
412
412
if (!$ this ->isRootList ()) {
413
- $ oNextLevel = $ oOutputFormat ->nextLevel ();
413
+ $ nextLevelFormat = $ oOutputFormat ->nextLevel ();
414
414
}
415
415
foreach ($ this ->contents as $ listItem ) {
416
- $ sRendered = $ oOutputFormat ->safely (static function () use ($ oNextLevel , $ listItem ): string {
417
- return $ listItem ->render ($ oNextLevel );
416
+ $ renderedCss = $ oOutputFormat ->safely (static function () use ($ nextLevelFormat , $ listItem ): string {
417
+ return $ listItem ->render ($ nextLevelFormat );
418
418
});
419
- if ($ sRendered === null ) {
419
+ if ($ renderedCss === null ) {
420
420
continue ;
421
421
}
422
- if ($ bIsFirst ) {
423
- $ bIsFirst = false ;
424
- $ sResult .= $ oNextLevel ->spaceBeforeBlocks ();
422
+ if ($ isFirst ) {
423
+ $ isFirst = false ;
424
+ $ result .= $ nextLevelFormat ->spaceBeforeBlocks ();
425
425
} else {
426
- $ sResult .= $ oNextLevel ->spaceBetweenBlocks ();
426
+ $ result .= $ nextLevelFormat ->spaceBetweenBlocks ();
427
427
}
428
- $ sResult .= $ sRendered ;
428
+ $ result .= $ renderedCss ;
429
429
}
430
430
431
- if (!$ bIsFirst ) {
431
+ if (!$ isFirst ) {
432
432
// Had some output
433
- $ sResult .= $ oOutputFormat ->spaceAfterBlocks ();
433
+ $ result .= $ oOutputFormat ->spaceAfterBlocks ();
434
434
}
435
435
436
- return $ sResult ;
436
+ return $ result ;
437
437
}
438
438
439
439
/**
0 commit comments