Skip to content

Commit d0b3e9c

Browse files
authored
[TASK] Use strict equality (#1331)
One instance is left out, but is covered by #1330.
1 parent b6b8ecf commit d0b3e9c

File tree

5 files changed

+6
-30
lines changed

5 files changed

+6
-30
lines changed

config/phpstan-baseline.neon

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ parameters:
1212
count: 1
1313
path: ../src/CSSList/CSSList.php
1414

15-
-
16-
message: '#^Loose comparison via "\!\=" is not allowed\.$#'
17-
identifier: notEqual.notAllowed
18-
count: 1
19-
path: ../src/CSSList/CSSList.php
20-
2115
-
2216
message: '#^Loose comparison via "\=\=" is not allowed\.$#'
2317
identifier: equal.notAllowed
@@ -66,30 +60,12 @@ parameters:
6660
count: 1
6761
path: ../src/RuleSet/DeclarationBlock.php
6862

69-
-
70-
message: '#^Loose comparison via "\!\=" is not allowed\.$#'
71-
identifier: notEqual.notAllowed
72-
count: 3
73-
path: ../src/Value/CalcFunction.php
74-
7563
-
7664
message: '#^Cannot call method getSize\(\) on Sabberworm\\CSS\\Value\\Value\|string\.$#'
7765
identifier: method.nonObject
7866
count: 3
7967
path: ../src/Value/Color.php
8068

81-
-
82-
message: '#^Loose comparison via "\=\=" is not allowed\.$#'
83-
identifier: equal.notAllowed
84-
count: 3
85-
path: ../src/Value/Color.php
86-
87-
-
88-
message: '#^Loose comparison via "\!\=" is not allowed\.$#'
89-
identifier: notEqual.notAllowed
90-
count: 1
91-
path: ../src/Value/Size.php
92-
9369
-
9470
message: '#^Parameters should have "float" types as the only types passed to this method$#'
9571
identifier: typePerfect.narrowPublicClassMethodParamType

src/CSSList/CSSList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ private static function parseAtRule(ParserState $parserState): ?CSSListItem
208208
} else {
209209
// Unknown other at rule (font-face or such)
210210
$arguments = \trim($parserState->consumeUntil('{', false, true));
211-
if (\substr_count($arguments, '(') != \substr_count($arguments, ')')) {
211+
if (\substr_count($arguments, '(') !== \substr_count($arguments, ')')) {
212212
if ($parserState->getSettings()->usesLenientParsing()) {
213213
return null;
214214
} else {

src/Value/CalcFunction.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public static function parse(ParserState $parserState, bool $ignoreCase = false)
3030
{
3131
$operators = ['+', '-', '*', '/'];
3232
$function = $parserState->parseIdentifier();
33-
if ($parserState->peek() != '(') {
33+
if ($parserState->peek() !== '(') {
3434
// Found ; or end of line before an opening bracket
3535
throw new UnexpectedTokenException('(', $parserState->peek(), 'literal', $parserState->currentLine());
3636
} elseif ($function !== 'calc') {
@@ -59,15 +59,15 @@ public static function parse(ParserState $parserState, bool $ignoreCase = false)
5959
$parserState->consumeWhiteSpace();
6060
continue;
6161
}
62-
if ($lastComponentType != CalcFunction::T_OPERAND) {
62+
if ($lastComponentType !== CalcFunction::T_OPERAND) {
6363
$value = Value::parsePrimitiveValue($parserState);
6464
$calcRuleValueList->addListComponent($value);
6565
$lastComponentType = CalcFunction::T_OPERAND;
6666
} else {
6767
if (\in_array($parserState->peek(), $operators, true)) {
6868
if (($parserState->comes('-') || $parserState->comes('+'))) {
6969
if (
70-
$parserState->peek(1, -1) != ' '
70+
$parserState->peek(1, -1) !== ' '
7171
|| !($parserState->comes('- ')
7272
|| $parserState->comes('+ '))
7373
) {

src/Value/Color.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ private function renderAsHex(): string
289289
$this->components['g']->getSize(),
290290
$this->components['b']->getSize()
291291
);
292-
$canUseShortVariant = ($result[0] == $result[1]) && ($result[2] == $result[3]) && ($result[4] == $result[5]);
292+
$canUseShortVariant = ($result[0] === $result[1]) && ($result[2] === $result[3]) && ($result[4] === $result[5]);
293293

294294
return '#' . ($canUseShortVariant ? $result[0] . $result[2] . $result[4] : $result);
295295
}

src/Value/Size.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public function isRelative(): bool
189189
if (\in_array($this->unit, self::RELATIVE_SIZE_UNITS, true)) {
190190
return true;
191191
}
192-
if ($this->unit === null && $this->size != 0) {
192+
if ($this->unit === null && $this->size !== 0.0) {
193193
return true;
194194
}
195195
return false;

0 commit comments

Comments
 (0)