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
[TASK] Use strict equality
One instance is left out, but is covered by #1330.
  • Loading branch information
JakeQZ committed Jul 14, 2025
commit 26f3e993ebbed946a693d4f74b0928f02e68cea7
24 changes: 0 additions & 24 deletions config/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ parameters:
count: 1
path: ../src/CSSList/CSSList.php

-
message: '#^Loose comparison via "\!\=" is not allowed\.$#'
identifier: notEqual.notAllowed
count: 1
path: ../src/CSSList/CSSList.php

-
message: '#^Loose comparison via "\=\=" is not allowed\.$#'
identifier: equal.notAllowed
Expand Down Expand Up @@ -66,30 +60,12 @@ parameters:
count: 1
path: ../src/RuleSet/DeclarationBlock.php

-
message: '#^Loose comparison via "\!\=" is not allowed\.$#'
identifier: notEqual.notAllowed
count: 3
path: ../src/Value/CalcFunction.php

-
message: '#^Cannot call method getSize\(\) on Sabberworm\\CSS\\Value\\Value\|string\.$#'
identifier: method.nonObject
count: 3
path: ../src/Value/Color.php

-
message: '#^Loose comparison via "\=\=" is not allowed\.$#'
identifier: equal.notAllowed
count: 3
path: ../src/Value/Color.php

-
message: '#^Loose comparison via "\!\=" is not allowed\.$#'
identifier: notEqual.notAllowed
count: 1
path: ../src/Value/Size.php

-
message: '#^Parameters should have "float" types as the only types passed to this method$#'
identifier: typePerfect.narrowPublicClassMethodParamType
Expand Down
2 changes: 1 addition & 1 deletion src/CSSList/CSSList.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ private static function parseAtRule(ParserState $parserState): ?CSSListItem
} else {
// Unknown other at rule (font-face or such)
$arguments = \trim($parserState->consumeUntil('{', false, true));
if (\substr_count($arguments, '(') != \substr_count($arguments, ')')) {
if (\substr_count($arguments, '(') !== \substr_count($arguments, ')')) {
if ($parserState->getSettings()->usesLenientParsing()) {
return null;
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/Value/CalcFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static function parse(ParserState $parserState, bool $ignoreCase = false)
{
$operators = ['+', '-', '*', '/'];
$function = $parserState->parseIdentifier();
if ($parserState->peek() != '(') {
if ($parserState->peek() !== '(') {
// Found ; or end of line before an opening bracket
throw new UnexpectedTokenException('(', $parserState->peek(), 'literal', $parserState->currentLine());
} elseif ($function !== 'calc') {
Expand Down Expand Up @@ -59,15 +59,15 @@ public static function parse(ParserState $parserState, bool $ignoreCase = false)
$parserState->consumeWhiteSpace();
continue;
}
if ($lastComponentType != CalcFunction::T_OPERAND) {
if ($lastComponentType !== CalcFunction::T_OPERAND) {
$value = Value::parsePrimitiveValue($parserState);
$calcRuleValueList->addListComponent($value);
$lastComponentType = CalcFunction::T_OPERAND;
} else {
if (\in_array($parserState->peek(), $operators, true)) {
if (($parserState->comes('-') || $parserState->comes('+'))) {
if (
$parserState->peek(1, -1) != ' '
$parserState->peek(1, -1) !== ' '
|| !($parserState->comes('- ')
|| $parserState->comes('+ '))
) {
Expand Down
2 changes: 1 addition & 1 deletion src/Value/Color.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ private function renderAsHex(): string
$this->components['g']->getSize(),
$this->components['b']->getSize()
);
$canUseShortVariant = ($result[0] == $result[1]) && ($result[2] == $result[3]) && ($result[4] == $result[5]);
$canUseShortVariant = ($result[0] === $result[1]) && ($result[2] === $result[3]) && ($result[4] === $result[5]);

return '#' . ($canUseShortVariant ? $result[0] . $result[2] . $result[4] : $result);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Value/Size.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public function isRelative(): bool
if (\in_array($this->unit, self::RELATIVE_SIZE_UNITS, true)) {
return true;
}
if ($this->unit === null && $this->size != 0) {
if ($this->unit === null && $this->size !== 0.0) {
return true;
}
return false;
Expand Down