Skip to content

Commit 3657ed1

Browse files
committed
[CLEANUP] Avoid Hungarian notation for oRule
Part of #756
1 parent 9f5c7dc commit 3657ed1

File tree

4 files changed

+75
-75
lines changed

4 files changed

+75
-75
lines changed

src/CSSList/CSSBlockList.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ protected function allValues(
7373
$this->allValues($oContent, $result, $searchString, $searchInFunctionArguments);
7474
}
7575
} elseif ($element instanceof RuleSet) {
76-
foreach ($element->getRules($searchString) as $oRule) {
77-
$this->allValues($oRule, $result, $searchString, $searchInFunctionArguments);
76+
foreach ($element->getRules($searchString) as $rule) {
77+
$this->allValues($rule, $result, $searchString, $searchInFunctionArguments);
7878
}
7979
} elseif ($element instanceof Rule) {
8080
$this->allValues($element->getValue(), $result, $searchString, $searchInFunctionArguments);

src/Rule/Rule.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,20 +79,20 @@ public function __construct($sRule, $lineNumber = 0, $iColNo = 0)
7979
public static function parse(ParserState $oParserState): Rule
8080
{
8181
$aComments = $oParserState->consumeWhiteSpace();
82-
$oRule = new Rule(
82+
$rule = new Rule(
8383
$oParserState->parseIdentifier(!$oParserState->comes('--')),
8484
$oParserState->currentLine(),
8585
$oParserState->currentColumn()
8686
);
87-
$oRule->setComments($aComments);
88-
$oRule->addComments($oParserState->consumeWhiteSpace());
87+
$rule->setComments($aComments);
88+
$rule->addComments($oParserState->consumeWhiteSpace());
8989
$oParserState->consume(':');
90-
$oValue = Value::parseValue($oParserState, self::listDelimiterForRule($oRule->getRule()));
91-
$oRule->setValue($oValue);
90+
$oValue = Value::parseValue($oParserState, self::listDelimiterForRule($rule->getRule()));
91+
$rule->setValue($oValue);
9292
if ($oParserState->getSettings()->bLenientParsing) {
9393
while ($oParserState->comes('\\')) {
9494
$oParserState->consume('\\');
95-
$oRule->addIeHack($oParserState->consume());
95+
$rule->addIeHack($oParserState->consume());
9696
$oParserState->consumeWhiteSpace();
9797
}
9898
}
@@ -101,7 +101,7 @@ public static function parse(ParserState $oParserState): Rule
101101
$oParserState->consume('!');
102102
$oParserState->consumeWhiteSpace();
103103
$oParserState->consume('important');
104-
$oRule->setIsImportant(true);
104+
$rule->setIsImportant(true);
105105
}
106106
$oParserState->consumeWhiteSpace();
107107
while ($oParserState->comes(';')) {
@@ -110,7 +110,7 @@ public static function parse(ParserState $oParserState): Rule
110110

111111
$oParserState->consumeWhiteSpace();
112112

113-
return $oRule;
113+
return $rule;
114114
}
115115

116116
/**

src/RuleSet/DeclarationBlock.php

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ public function expandBorderShorthand(): void
212212
if (!isset($aRules[$sBorderRule])) {
213213
continue;
214214
}
215-
$oRule = $aRules[$sBorderRule];
216-
$mRuleValue = $oRule->getValue();
215+
$rule = $aRules[$sBorderRule];
216+
$mRuleValue = $rule->getValue();
217217
$aValues = [];
218218
if (!$mRuleValue instanceof RuleValueList) {
219219
$aValues[] = $mRuleValue;
@@ -237,8 +237,8 @@ public function expandBorderShorthand(): void
237237
$sNewRuleName = $sBorderRule . '-style';
238238
}
239239
}
240-
$oNewRule = new Rule($sNewRuleName, $oRule->getLineNo(), $oRule->getColNo());
241-
$oNewRule->setIsImportant($oRule->getIsImportant());
240+
$oNewRule = new Rule($sNewRuleName, $rule->getLineNo(), $rule->getColNo());
241+
$oNewRule->setIsImportant($rule->getIsImportant());
242242
$oNewRule->addValue([$mNewValue]);
243243
$this->addRule($oNewRule);
244244
}
@@ -268,8 +268,8 @@ public function expandDimensionsShorthand(): void
268268
if (!isset($aRules[$sProperty])) {
269269
continue;
270270
}
271-
$oRule = $aRules[$sProperty];
272-
$mRuleValue = $oRule->getValue();
271+
$rule = $aRules[$sProperty];
272+
$mRuleValue = $rule->getValue();
273273
$aValues = [];
274274
if (!$mRuleValue instanceof RuleValueList) {
275275
$aValues[] = $mRuleValue;
@@ -298,8 +298,8 @@ public function expandDimensionsShorthand(): void
298298
break;
299299
}
300300
foreach (['top', 'right', 'bottom', 'left'] as $sPosition) {
301-
$oNewRule = new Rule(\sprintf($sExpanded, $sPosition), $oRule->getLineNo(), $oRule->getColNo());
302-
$oNewRule->setIsImportant($oRule->getIsImportant());
301+
$oNewRule = new Rule(\sprintf($sExpanded, $sPosition), $rule->getLineNo(), $rule->getColNo());
302+
$oNewRule->setIsImportant($rule->getIsImportant());
303303
$oNewRule->addValue(${$sPosition});
304304
$this->addRule($oNewRule);
305305
}
@@ -320,7 +320,7 @@ public function expandFontShorthand(): void
320320
if (!isset($aRules['font'])) {
321321
return;
322322
}
323-
$oRule = $aRules['font'];
323+
$rule = $aRules['font'];
324324
// reset properties to 'normal' per http://www.w3.org/TR/21/fonts.html#font-shorthand
325325
$aFontProperties = [
326326
'font-style' => 'normal',
@@ -329,7 +329,7 @@ public function expandFontShorthand(): void
329329
'font-size' => 'normal',
330330
'line-height' => 'normal',
331331
];
332-
$mRuleValue = $oRule->getValue();
332+
$mRuleValue = $rule->getValue();
333333
$aValues = [];
334334
if (!$mRuleValue instanceof RuleValueList) {
335335
$aValues[] = $mRuleValue;
@@ -366,9 +366,9 @@ public function expandFontShorthand(): void
366366
}
367367
}
368368
foreach ($aFontProperties as $sProperty => $mValue) {
369-
$oNewRule = new Rule($sProperty, $oRule->getLineNo(), $oRule->getColNo());
369+
$oNewRule = new Rule($sProperty, $rule->getLineNo(), $rule->getColNo());
370370
$oNewRule->addValue($mValue);
371-
$oNewRule->setIsImportant($oRule->getIsImportant());
371+
$oNewRule->setIsImportant($rule->getIsImportant());
372372
$this->addRule($oNewRule);
373373
}
374374
$this->removeRule('font');
@@ -389,7 +389,7 @@ public function expandBackgroundShorthand(): void
389389
if (!isset($aRules['background'])) {
390390
return;
391391
}
392-
$oRule = $aRules['background'];
392+
$rule = $aRules['background'];
393393
$aBgProperties = [
394394
'background-color' => ['transparent'],
395395
'background-image' => ['none'],
@@ -400,7 +400,7 @@ public function expandBackgroundShorthand(): void
400400
new Size(0, '%', false, $this->lineNumber),
401401
],
402402
];
403-
$mRuleValue = $oRule->getValue();
403+
$mRuleValue = $rule->getValue();
404404
$aValues = [];
405405
if (!$mRuleValue instanceof RuleValueList) {
406406
$aValues[] = $mRuleValue;
@@ -409,9 +409,9 @@ public function expandBackgroundShorthand(): void
409409
}
410410
if (\count($aValues) == 1 && $aValues[0] == 'inherit') {
411411
foreach ($aBgProperties as $sProperty => $mValue) {
412-
$oNewRule = new Rule($sProperty, $oRule->getLineNo(), $oRule->getColNo());
412+
$oNewRule = new Rule($sProperty, $rule->getLineNo(), $rule->getColNo());
413413
$oNewRule->addValue('inherit');
414-
$oNewRule->setIsImportant($oRule->getIsImportant());
414+
$oNewRule->setIsImportant($rule->getIsImportant());
415415
$this->addRule($oNewRule);
416416
}
417417
$this->removeRule('background');
@@ -444,8 +444,8 @@ public function expandBackgroundShorthand(): void
444444
}
445445
}
446446
foreach ($aBgProperties as $sProperty => $mValue) {
447-
$oNewRule = new Rule($sProperty, $oRule->getLineNo(), $oRule->getColNo());
448-
$oNewRule->setIsImportant($oRule->getIsImportant());
447+
$oNewRule = new Rule($sProperty, $rule->getLineNo(), $rule->getColNo());
448+
$oNewRule->setIsImportant($rule->getIsImportant());
449449
$oNewRule->addValue($mValue);
450450
$this->addRule($oNewRule);
451451
}
@@ -493,8 +493,8 @@ public function expandListStyleShorthand(): void
493493
if (!isset($aRules['list-style'])) {
494494
return;
495495
}
496-
$oRule = $aRules['list-style'];
497-
$mRuleValue = $oRule->getValue();
496+
$rule = $aRules['list-style'];
497+
$mRuleValue = $rule->getValue();
498498
$aValues = [];
499499
if (!$mRuleValue instanceof RuleValueList) {
500500
$aValues[] = $mRuleValue;
@@ -503,9 +503,9 @@ public function expandListStyleShorthand(): void
503503
}
504504
if (\count($aValues) == 1 && $aValues[0] == 'inherit') {
505505
foreach ($aListProperties as $sProperty => $mValue) {
506-
$oNewRule = new Rule($sProperty, $oRule->getLineNo(), $oRule->getColNo());
506+
$oNewRule = new Rule($sProperty, $rule->getLineNo(), $rule->getColNo());
507507
$oNewRule->addValue('inherit');
508-
$oNewRule->setIsImportant($oRule->getIsImportant());
508+
$oNewRule->setIsImportant($rule->getIsImportant());
509509
$this->addRule($oNewRule);
510510
}
511511
$this->removeRule('list-style');
@@ -524,8 +524,8 @@ public function expandListStyleShorthand(): void
524524
}
525525
}
526526
foreach ($aListProperties as $sProperty => $mValue) {
527-
$oNewRule = new Rule($sProperty, $oRule->getLineNo(), $oRule->getColNo());
528-
$oNewRule->setIsImportant($oRule->getIsImportant());
527+
$oNewRule = new Rule($sProperty, $rule->getLineNo(), $rule->getColNo());
528+
$oNewRule->setIsImportant($rule->getIsImportant());
529529
$oNewRule->addValue($mValue);
530530
$this->addRule($oNewRule);
531531
}
@@ -541,15 +541,15 @@ public function expandListStyleShorthand(): void
541541
public function createShorthandProperties(array $aProperties, $sShorthand): void
542542
{
543543
$aRules = $this->getRulesAssoc();
544-
$oRule = null;
544+
$rule = null;
545545
$aNewValues = [];
546546
foreach ($aProperties as $sProperty) {
547547
if (!isset($aRules[$sProperty])) {
548548
continue;
549549
}
550-
$oRule = $aRules[$sProperty];
551-
if (!$oRule->getIsImportant()) {
552-
$mRuleValue = $oRule->getValue();
550+
$rule = $aRules[$sProperty];
551+
if (!$rule->getIsImportant()) {
552+
$mRuleValue = $rule->getValue();
553553
$aValues = [];
554554
if (!$mRuleValue instanceof RuleValueList) {
555555
$aValues[] = $mRuleValue;
@@ -562,8 +562,8 @@ public function createShorthandProperties(array $aProperties, $sShorthand): void
562562
$this->removeRule($sProperty);
563563
}
564564
}
565-
if ($aNewValues !== [] && $oRule instanceof Rule) {
566-
$oNewRule = new Rule($sShorthand, $oRule->getLineNo(), $oRule->getColNo());
565+
if ($aNewValues !== [] && $rule instanceof Rule) {
566+
$oNewRule = new Rule($sShorthand, $rule->getLineNo(), $rule->getColNo());
567567
foreach ($aNewValues as $mValue) {
568568
$oNewRule->addValue($mValue);
569569
}
@@ -636,19 +636,19 @@ public function createDimensionsShorthand(): void
636636
$aRules = $this->getRulesAssoc();
637637
foreach ($aExpansions as $sProperty => $sExpanded) {
638638
$aFoldable = [];
639-
foreach ($aRules as $sRuleName => $oRule) {
639+
foreach ($aRules as $sRuleName => $rule) {
640640
foreach ($aPositions as $sPosition) {
641641
if ($sRuleName == \sprintf($sExpanded, $sPosition)) {
642-
$aFoldable[$sRuleName] = $oRule;
642+
$aFoldable[$sRuleName] = $rule;
643643
}
644644
}
645645
}
646646
// All four dimensions must be present
647647
if (\count($aFoldable) == 4) {
648648
$aValues = [];
649649
foreach ($aPositions as $sPosition) {
650-
$oRule = $aRules[\sprintf($sExpanded, $sPosition)];
651-
$mRuleValue = $oRule->getValue();
650+
$rule = $aRules[\sprintf($sExpanded, $sPosition)];
651+
$mRuleValue = $rule->getValue();
652652
$aRuleValues = [];
653653
if (!$mRuleValue instanceof RuleValueList) {
654654
$aRuleValues[] = $mRuleValue;
@@ -657,7 +657,7 @@ public function createDimensionsShorthand(): void
657657
}
658658
$aValues[$sPosition] = $aRuleValues;
659659
}
660-
$oNewRule = new Rule($sProperty, $oRule->getLineNo(), $oRule->getColNo());
660+
$oNewRule = new Rule($sProperty, $rule->getLineNo(), $rule->getColNo());
661661
if ((string) $aValues['left'][0] == (string) $aValues['right'][0]) {
662662
if ((string) $aValues['top'][0] == (string) $aValues['bottom'][0]) {
663663
if ((string) $aValues['top'][0] == (string) $aValues['left'][0]) {
@@ -716,8 +716,8 @@ public function createFontShorthand(): void
716716
unset($oOldRule);
717717
foreach (['font-style', 'font-variant', 'font-weight'] as $sProperty) {
718718
if (isset($aRules[$sProperty])) {
719-
$oRule = $aRules[$sProperty];
720-
$mRuleValue = $oRule->getValue();
719+
$rule = $aRules[$sProperty];
720+
$mRuleValue = $rule->getValue();
721721
$aValues = [];
722722
if (!$mRuleValue instanceof RuleValueList) {
723723
$aValues[] = $mRuleValue;
@@ -730,8 +730,8 @@ public function createFontShorthand(): void
730730
}
731731
}
732732
// Get the font-size value
733-
$oRule = $aRules['font-size'];
734-
$mRuleValue = $oRule->getValue();
733+
$rule = $aRules['font-size'];
734+
$mRuleValue = $rule->getValue();
735735
$aFSValues = [];
736736
if (!$mRuleValue instanceof RuleValueList) {
737737
$aFSValues[] = $mRuleValue;
@@ -740,8 +740,8 @@ public function createFontShorthand(): void
740740
}
741741
// But wait to know if we have line-height to add it
742742
if (isset($aRules['line-height'])) {
743-
$oRule = $aRules['line-height'];
744-
$mRuleValue = $oRule->getValue();
743+
$rule = $aRules['line-height'];
744+
$mRuleValue = $rule->getValue();
745745
$aLHValues = [];
746746
if (!$mRuleValue instanceof RuleValueList) {
747747
$aLHValues[] = $mRuleValue;
@@ -757,8 +757,8 @@ public function createFontShorthand(): void
757757
} else {
758758
$oNewRule->addValue($aFSValues[0]);
759759
}
760-
$oRule = $aRules['font-family'];
761-
$mRuleValue = $oRule->getValue();
760+
$rule = $aRules['font-family'];
761+
$mRuleValue = $rule->getValue();
762762
$aFFValues = [];
763763
if (!$mRuleValue instanceof RuleValueList) {
764764
$aFFValues[] = $mRuleValue;

0 commit comments

Comments
 (0)