Skip to content

Commit 1be476c

Browse files
committed
Feat: Require comparisons to be strict (fixes #90)
1 parent 0551ba6 commit 1be476c

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

ecs.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
use PhpCsFixer\Fixer\Semicolon\NoSinglelineWhitespaceBeforeSemicolonsFixer;
123123
use PhpCsFixer\Fixer\Semicolon\SpaceAfterSemicolonFixer;
124124
use PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer;
125+
use PhpCsFixer\Fixer\Strict\StrictComparisonFixer;
125126
use PhpCsFixer\Fixer\Strict\StrictParamFixer;
126127
use PhpCsFixer\Fixer\StringNotation\SingleQuoteFixer;
127128
use PhpCsFixer\Fixer\Whitespace\BlankLineBeforeStatementFixer;
@@ -358,6 +359,8 @@
358359
DeclareStrictTypesFixer::class,
359360
// Functions should be used with `$strict` param set to `true`
360361
StrictParamFixer::class,
362+
// Comparisons should be strict, `===` or `!==` must be used for comparisons
363+
StrictComparisonFixer::class,
361364
// Convert double quotes to single quotes for simple strings
362365
SingleQuoteFixer::class,
363366
// Remove extra spaces in a nullable typehint

tests/Integration/Fixtures/Basic.correct.php.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ class Basic
1414
$lambdaWithUnusedImport = function () { return 'foo'; };
1515
// NoUselessSprintfFixer
1616
$uselessSprintf = 'bar';
17-
// SingleSpaceAfterConstructFixer
18-
if ($a == $b) {
17+
// SingleSpaceAfterConstructFixer, StrictComparisonFixer
18+
if ($a === $b || $bazLength !== 3) {
1919
return true;
2020
}
2121

tests/Integration/Fixtures/Basic.wrong.php.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ class Basic
1313
$lambdaWithUnusedImport = function () use ($fooBar) { return 'foo'; };
1414
// NoUselessSprintfFixer
1515
$uselessSprintf = sprintf('bar');
16-
// SingleSpaceAfterConstructFixer
17-
if ($a == $b) { return true; }
16+
// SingleSpaceAfterConstructFixer, StrictComparisonFixer
17+
if ($a == $b || $bazLength != 3) { return true; }
1818
return false; // BlankLineBeforeStatementFixer
1919
}
2020

0 commit comments

Comments
 (0)