Skip to content

Commit b4e4fbc

Browse files
committed
Autofix all autofixable PSR-12 code style issues
These changes were all automatically done by PHP_CodeSniffer, and there are no manual changes.
1 parent 2a2a167 commit b4e4fbc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+5097
-4672
lines changed

lib/Sabberworm/CSS/CSSList/AtRuleBlockList.php

Lines changed: 60 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -7,64 +7,70 @@
77
/**
88
* A BlockList constructed by an unknown @-rule. @media rules are rendered into AtRuleBlockList objects.
99
*/
10-
class AtRuleBlockList extends CSSBlockList implements AtRule {
11-
/**
12-
* @var string
13-
*/
14-
private $sType;
10+
class AtRuleBlockList extends CSSBlockList implements AtRule
11+
{
12+
/**
13+
* @var string
14+
*/
15+
private $sType;
1516

16-
/**
17-
* @var string
18-
*/
19-
private $sArgs;
17+
/**
18+
* @var string
19+
*/
20+
private $sArgs;
2021

21-
/**
22-
* @param string $sType
23-
* @param string $sArgs
24-
* @param int $iLineNo
25-
*/
26-
public function __construct($sType, $sArgs = '', $iLineNo = 0) {
27-
parent::__construct($iLineNo);
28-
$this->sType = $sType;
29-
$this->sArgs = $sArgs;
30-
}
22+
/**
23+
* @param string $sType
24+
* @param string $sArgs
25+
* @param int $iLineNo
26+
*/
27+
public function __construct($sType, $sArgs = '', $iLineNo = 0)
28+
{
29+
parent::__construct($iLineNo);
30+
$this->sType = $sType;
31+
$this->sArgs = $sArgs;
32+
}
3133

32-
/**
33-
* @return string
34-
*/
35-
public function atRuleName() {
36-
return $this->sType;
37-
}
34+
/**
35+
* @return string
36+
*/
37+
public function atRuleName()
38+
{
39+
return $this->sType;
40+
}
3841

39-
/**
40-
* @return string
41-
*/
42-
public function atRuleArgs() {
43-
return $this->sArgs;
44-
}
42+
/**
43+
* @return string
44+
*/
45+
public function atRuleArgs()
46+
{
47+
return $this->sArgs;
48+
}
4549

46-
public function __toString() {
47-
return $this->render(new \Sabberworm\CSS\OutputFormat());
48-
}
50+
public function __toString()
51+
{
52+
return $this->render(new \Sabberworm\CSS\OutputFormat());
53+
}
4954

50-
/**
51-
* @return string
52-
*/
53-
public function render(\Sabberworm\CSS\OutputFormat $oOutputFormat) {
54-
$sArgs = $this->sArgs;
55-
if($sArgs) {
56-
$sArgs = ' ' . $sArgs;
57-
}
58-
$sResult = $oOutputFormat->sBeforeAtRuleBlock;
59-
$sResult .= "@{$this->sType}$sArgs{$oOutputFormat->spaceBeforeOpeningBrace()}{";
60-
$sResult .= parent::render($oOutputFormat);
61-
$sResult .= '}';
62-
$sResult .= $oOutputFormat->sAfterAtRuleBlock;
63-
return $sResult;
64-
}
55+
/**
56+
* @return string
57+
*/
58+
public function render(\Sabberworm\CSS\OutputFormat $oOutputFormat)
59+
{
60+
$sArgs = $this->sArgs;
61+
if ($sArgs) {
62+
$sArgs = ' ' . $sArgs;
63+
}
64+
$sResult = $oOutputFormat->sBeforeAtRuleBlock;
65+
$sResult .= "@{$this->sType}$sArgs{$oOutputFormat->spaceBeforeOpeningBrace()}{";
66+
$sResult .= parent::render($oOutputFormat);
67+
$sResult .= '}';
68+
$sResult .= $oOutputFormat->sAfterAtRuleBlock;
69+
return $sResult;
70+
}
6571

66-
public function isRootList() {
67-
return false;
68-
}
69-
70-
}
72+
public function isRootList()
73+
{
74+
return false;
75+
}
76+
}

lib/Sabberworm/CSS/CSSList/CSSBlockList.php

Lines changed: 92 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -13,95 +13,100 @@
1313
* A CSSBlockList is a CSSList whose DeclarationBlocks are guaranteed to contain valid declaration blocks or at-rules.
1414
* Most CSSLists conform to this category but some at-rules (such as @keyframes) do not.
1515
*/
16-
abstract class CSSBlockList extends CSSList {
17-
public function __construct($iLineNo = 0) {
18-
parent::__construct($iLineNo);
19-
}
16+
abstract class CSSBlockList extends CSSList
17+
{
18+
public function __construct($iLineNo = 0)
19+
{
20+
parent::__construct($iLineNo);
21+
}
2022

21-
protected function allDeclarationBlocks(&$aResult) {
22-
foreach ($this->aContents as $mContent) {
23-
if ($mContent instanceof DeclarationBlock) {
24-
$aResult[] = $mContent;
25-
} else if ($mContent instanceof CSSBlockList) {
26-
$mContent->allDeclarationBlocks($aResult);
27-
}
28-
}
29-
}
23+
protected function allDeclarationBlocks(&$aResult)
24+
{
25+
foreach ($this->aContents as $mContent) {
26+
if ($mContent instanceof DeclarationBlock) {
27+
$aResult[] = $mContent;
28+
} elseif ($mContent instanceof CSSBlockList) {
29+
$mContent->allDeclarationBlocks($aResult);
30+
}
31+
}
32+
}
3033

31-
protected function allRuleSets(&$aResult) {
32-
foreach ($this->aContents as $mContent) {
33-
if ($mContent instanceof RuleSet) {
34-
$aResult[] = $mContent;
35-
} else if ($mContent instanceof CSSBlockList) {
36-
$mContent->allRuleSets($aResult);
37-
}
38-
}
39-
}
34+
protected function allRuleSets(&$aResult)
35+
{
36+
foreach ($this->aContents as $mContent) {
37+
if ($mContent instanceof RuleSet) {
38+
$aResult[] = $mContent;
39+
} elseif ($mContent instanceof CSSBlockList) {
40+
$mContent->allRuleSets($aResult);
41+
}
42+
}
43+
}
4044

41-
protected function allValues($oElement, &$aResult, $sSearchString = null, $bSearchInFunctionArguments = false) {
42-
if ($oElement instanceof CSSBlockList) {
43-
foreach ($oElement->getContents() as $oContent) {
44-
$this->allValues($oContent, $aResult, $sSearchString, $bSearchInFunctionArguments);
45-
}
46-
} else if ($oElement instanceof RuleSet) {
47-
foreach ($oElement->getRules($sSearchString) as $oRule) {
48-
$this->allValues($oRule, $aResult, $sSearchString, $bSearchInFunctionArguments);
49-
}
50-
} else if ($oElement instanceof Rule) {
51-
$this->allValues($oElement->getValue(), $aResult, $sSearchString, $bSearchInFunctionArguments);
52-
} else if ($oElement instanceof ValueList) {
53-
if ($bSearchInFunctionArguments || !($oElement instanceof CSSFunction)) {
54-
foreach ($oElement->getListComponents() as $mComponent) {
55-
$this->allValues($mComponent, $aResult, $sSearchString, $bSearchInFunctionArguments);
56-
}
57-
}
58-
} else {
59-
//Non-List Value or CSSString (CSS identifier)
60-
$aResult[] = $oElement;
61-
}
62-
}
63-
64-
protected function allSelectors(&$aResult, $sSpecificitySearch = null) {
65-
$aDeclarationBlocks = array();
66-
$this->allDeclarationBlocks($aDeclarationBlocks);
67-
foreach ($aDeclarationBlocks as $oBlock) {
68-
foreach ($oBlock->getSelectors() as $oSelector) {
69-
if ($sSpecificitySearch === null) {
70-
$aResult[] = $oSelector;
71-
} else {
72-
$sComparator = '===';
73-
$aSpecificitySearch = explode(' ', $sSpecificitySearch);
74-
$iTargetSpecificity = $aSpecificitySearch[0];
75-
if(count($aSpecificitySearch) > 1) {
76-
$sComparator = $aSpecificitySearch[0];
77-
$iTargetSpecificity = $aSpecificitySearch[1];
78-
}
79-
$iTargetSpecificity = (int)$iTargetSpecificity;
80-
$iSelectorSpecificity = $oSelector->getSpecificity();
81-
$bMatches = false;
82-
switch($sComparator) {
83-
case '<=':
84-
$bMatches = $iSelectorSpecificity <= $iTargetSpecificity;
85-
break;
86-
case '<':
87-
$bMatches = $iSelectorSpecificity < $iTargetSpecificity;
88-
break;
89-
case '>=':
90-
$bMatches = $iSelectorSpecificity >= $iTargetSpecificity;
91-
break;
92-
case '>':
93-
$bMatches = $iSelectorSpecificity > $iTargetSpecificity;
94-
break;
95-
default:
96-
$bMatches = $iSelectorSpecificity === $iTargetSpecificity;
97-
break;
98-
}
99-
if ($bMatches) {
100-
$aResult[] = $oSelector;
101-
}
102-
}
103-
}
104-
}
105-
}
45+
protected function allValues($oElement, &$aResult, $sSearchString = null, $bSearchInFunctionArguments = false)
46+
{
47+
if ($oElement instanceof CSSBlockList) {
48+
foreach ($oElement->getContents() as $oContent) {
49+
$this->allValues($oContent, $aResult, $sSearchString, $bSearchInFunctionArguments);
50+
}
51+
} elseif ($oElement instanceof RuleSet) {
52+
foreach ($oElement->getRules($sSearchString) as $oRule) {
53+
$this->allValues($oRule, $aResult, $sSearchString, $bSearchInFunctionArguments);
54+
}
55+
} elseif ($oElement instanceof Rule) {
56+
$this->allValues($oElement->getValue(), $aResult, $sSearchString, $bSearchInFunctionArguments);
57+
} elseif ($oElement instanceof ValueList) {
58+
if ($bSearchInFunctionArguments || !($oElement instanceof CSSFunction)) {
59+
foreach ($oElement->getListComponents() as $mComponent) {
60+
$this->allValues($mComponent, $aResult, $sSearchString, $bSearchInFunctionArguments);
61+
}
62+
}
63+
} else {
64+
//Non-List Value or CSSString (CSS identifier)
65+
$aResult[] = $oElement;
66+
}
67+
}
10668

69+
protected function allSelectors(&$aResult, $sSpecificitySearch = null)
70+
{
71+
$aDeclarationBlocks = array();
72+
$this->allDeclarationBlocks($aDeclarationBlocks);
73+
foreach ($aDeclarationBlocks as $oBlock) {
74+
foreach ($oBlock->getSelectors() as $oSelector) {
75+
if ($sSpecificitySearch === null) {
76+
$aResult[] = $oSelector;
77+
} else {
78+
$sComparator = '===';
79+
$aSpecificitySearch = explode(' ', $sSpecificitySearch);
80+
$iTargetSpecificity = $aSpecificitySearch[0];
81+
if (count($aSpecificitySearch) > 1) {
82+
$sComparator = $aSpecificitySearch[0];
83+
$iTargetSpecificity = $aSpecificitySearch[1];
84+
}
85+
$iTargetSpecificity = (int)$iTargetSpecificity;
86+
$iSelectorSpecificity = $oSelector->getSpecificity();
87+
$bMatches = false;
88+
switch ($sComparator) {
89+
case '<=':
90+
$bMatches = $iSelectorSpecificity <= $iTargetSpecificity;
91+
break;
92+
case '<':
93+
$bMatches = $iSelectorSpecificity < $iTargetSpecificity;
94+
break;
95+
case '>=':
96+
$bMatches = $iSelectorSpecificity >= $iTargetSpecificity;
97+
break;
98+
case '>':
99+
$bMatches = $iSelectorSpecificity > $iTargetSpecificity;
100+
break;
101+
default:
102+
$bMatches = $iSelectorSpecificity === $iTargetSpecificity;
103+
break;
104+
}
105+
if ($bMatches) {
106+
$aResult[] = $oSelector;
107+
}
108+
}
109+
}
110+
}
111+
}
107112
}

0 commit comments

Comments
 (0)