Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions config/php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
// overwrite the PER2 defaults to restore compatibility with PHP 7.x
'trailing_comma_in_multiline' => ['elements' => ['arrays', 'match']],

// for `in_array` & friends
'strict_param' => true,

'php_unit_construct' => true,
'php_unit_dedicate_assert' => ['target' => 'newest'],
'php_unit_expectation' => ['target' => 'newest'],
Expand Down
4 changes: 2 additions & 2 deletions src/Parsing/ParserState.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ public function consumeUntil($aEnd, $bIncludeEnd = false, $consumeEnd = false, a

while (!$this->isEnd()) {
$char = $this->consume(1);
if (in_array($char, $aEnd)) {
if (in_array($char, $aEnd, true)) {
if ($bIncludeEnd) {
$out .= $char;
} elseif (!$consumeEnd) {
Expand All @@ -386,7 +386,7 @@ public function consumeUntil($aEnd, $bIncludeEnd = false, $consumeEnd = false, a
}
}

if (in_array(self::EOF, $aEnd)) {
if (in_array(self::EOF, $aEnd, true)) {
return $out;
}

Expand Down
25 changes: 12 additions & 13 deletions src/RuleSet/DeclarationBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ public static function parse(ParserState $oParserState, $oList = null)
do {
$aSelectorParts[] = $oParserState->consume(1)
. $oParserState->consumeUntil(['{', '}', '\'', '"'], false, false, $aComments);
if (in_array($oParserState->peek(), ['\'', '"']) && substr(end($aSelectorParts), -1) != "\\") {
if (in_array($oParserState->peek(), ['\'', '"'], true) && substr(end($aSelectorParts), -1) != "\\") {
if ($sStringWrapperChar === false) {
$sStringWrapperChar = $oParserState->peek();
} elseif ($sStringWrapperChar == $oParserState->peek()) {
$sStringWrapperChar = false;
}
}
} while (!in_array($oParserState->peek(), ['{', '}']) || $sStringWrapperChar !== false);
} while (!in_array($oParserState->peek(), ['{', '}'], true) || $sStringWrapperChar !== false);
$oResult->setSelectors(implode('', $aSelectorParts), $oList);
if ($oParserState->comes('{')) {
$oParserState->consume(1);
Expand Down Expand Up @@ -229,7 +229,7 @@ public function expandBorderShorthand(): void
} elseif ($mValue instanceof Color) {
$sNewRuleName = $sBorderRule . "-color";
} else {
if (in_array($mValue, $aBorderSizes)) {
if (in_array($mValue, $aBorderSizes, true)) {
$sNewRuleName = $sBorderRule . "-width";
} else {
$sNewRuleName = $sBorderRule . "-style";
Expand Down Expand Up @@ -338,20 +338,19 @@ public function expandFontShorthand(): void
if (!$mValue instanceof Value) {
$mValue = mb_strtolower($mValue);
}
if (in_array($mValue, ['normal', 'inherit'])) {
if (in_array($mValue, ['normal', 'inherit'], true)) {
foreach (['font-style', 'font-weight', 'font-variant'] as $sProperty) {
if (!isset($aFontProperties[$sProperty])) {
$aFontProperties[$sProperty] = $mValue;
}
}
} elseif (in_array($mValue, ['italic', 'oblique'])) {
} elseif (in_array($mValue, ['italic', 'oblique'], true)) {
$aFontProperties['font-style'] = $mValue;
} elseif ($mValue == 'small-caps') {
$aFontProperties['font-variant'] = $mValue;
} elseif (
in_array($mValue, ['bold', 'bolder', 'lighter'])
|| ($mValue instanceof Size
&& in_array($mValue->getSize(), range(100, 900, 100)))
in_array($mValue, ['bold', 'bolder', 'lighter'], true)
|| ($mValue instanceof Size && in_array($mValue->getSize(), range(100.0, 900.0, 100.0), true))
) {
$aFontProperties['font-weight'] = $mValue;
} elseif ($mValue instanceof RuleValueList && $mValue->getListSeparator() == '/') {
Expand Down Expand Up @@ -425,12 +424,12 @@ public function expandBackgroundShorthand(): void
$aBgProperties['background-image'] = $mValue;
} elseif ($mValue instanceof Color) {
$aBgProperties['background-color'] = $mValue;
} elseif (in_array($mValue, ['scroll', 'fixed'])) {
} elseif (in_array($mValue, ['scroll', 'fixed'], true)) {
$aBgProperties['background-attachment'] = $mValue;
} elseif (in_array($mValue, ['repeat', 'no-repeat', 'repeat-x', 'repeat-y'])) {
} elseif (in_array($mValue, ['repeat', 'no-repeat', 'repeat-x', 'repeat-y'], true)) {
$aBgProperties['background-repeat'] = $mValue;
} elseif (
in_array($mValue, ['left', 'center', 'right', 'top', 'bottom'])
in_array($mValue, ['left', 'center', 'right', 'top', 'bottom'], true)
|| $mValue instanceof Size
) {
if ($iNumBgPos == 0) {
Expand Down Expand Up @@ -516,9 +515,9 @@ public function expandListStyleShorthand(): void
}
if ($mValue instanceof Url) {
$aListProperties['list-style-image'] = $mValue;
} elseif (in_array($mValue, $aListStyleTypes)) {
} elseif (in_array($mValue, $aListStyleTypes, true)) {
$aListProperties['list-style-types'] = $mValue;
} elseif (in_array($mValue, $aListStylePositions)) {
} elseif (in_array($mValue, $aListStylePositions, true)) {
$aListProperties['list-style-position'] = $mValue;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Value/CalcFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static function parse(ParserState $oParserState, bool $bIgnoreCase = fals
if ($oParserState->peek() != '(') {
// Found ; or end of line before an opening bracket
throw new UnexpectedTokenException('(', $oParserState->peek(), 'literal', $oParserState->currentLine());
} elseif (!in_array($sFunction, ['calc', '-moz-calc', '-webkit-calc'])) {
} elseif (!in_array($sFunction, ['calc', '-moz-calc', '-webkit-calc'], true)) {
// Found invalid calc definition. Example calc (...
throw new UnexpectedTokenException('calc', $sFunction, 'literal', $oParserState->currentLine());
}
Expand Down Expand Up @@ -60,7 +60,7 @@ public static function parse(ParserState $oParserState, bool $bIgnoreCase = fals
$oCalcList->addListComponent($oVal);
$iLastComponentType = CalcFunction::T_OPERAND;
} else {
if (in_array($oParserState->peek(), $aOperators)) {
if (in_array($oParserState->peek(), $aOperators, true)) {
if (($oParserState->comes('-') || $oParserState->comes('+'))) {
if (
$oParserState->peek(1, -1) != ' '
Expand Down