Skip to content

Commit db61867

Browse files
committed
[BE] ConstantLooseComparisonRule
1 parent d22c481 commit db61867

File tree

6 files changed

+5
-12
lines changed

6 files changed

+5
-12
lines changed

changelog-2.0.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Major new features 🚀
2727
* Check vprintf/vsprintf arguments against placeholder count (level 0) ([#3126](https://github.com/phpstan/phpstan-src/pull/3126)), thanks @staabm!
2828
* Report useless return values of function calls like `var_export` without `$return=true` (level 0) ([#3225](https://github.com/phpstan/phpstan-src/pull/3225)), #11320, thanks @staabm!
2929
* Rule for `call_user_func()` (level 5) ([#2479](https://github.com/phpstan/phpstan-src/pull/2479)), thanks @staabm!
30+
* ConstantLooseComparisonRule - level 4 (https://github.com/phpstan/phpstan-src/commit/6ebf2361a3c831dd105a815521889428c295dc9f)
3031
* Check array functions which require stringish values (level 5) ([#3132](https://github.com/phpstan/phpstan-src/pull/3132)), #11141, #5848, #3694, #11111, thanks @schlndh!
3132
* Check variance of template types in properties (level 2) ([#2314](https://github.com/phpstan/phpstan-src/pull/2314)), thanks @jiripudil!
3233
* ArrayUnpackingRule (level 3) ([#856](https://github.com/phpstan/phpstan-src/pull/856)), thanks @canvural!
@@ -64,7 +65,6 @@ Bleeding edge (TODO move to other sections)
6465

6566
* Report useless `array_filter()` calls ([#1077](https://github.com/phpstan/phpstan-src/pull/1077)), #6840, thanks @leongersen!
6667
* Rules for checking direct calls to `__construct()` (level 2) ([#1208](https://github.com/phpstan/phpstan-src/pull/1208)), #7022, thanks @muno92!
67-
* ConstantLooseComparisonRule - level 4 (https://github.com/phpstan/phpstan-src/commit/6ebf2361a3c831dd105a815521889428c295dc9f)
6868
* Support `@readonly` property and `@immutable` class PHPDoc ([#1295](https://github.com/phpstan/phpstan-src/pull/1295), [#1335](https://github.com/phpstan/phpstan-src/pull/1335)), #4082, thanks @herndlm!
6969
* Move IllegalConstructorMethodCallRule and IllegalConstructorStaticCallRule to phpstan-strict-rules (https://github.com/phpstan/phpstan-src/commit/124b30f98c182193187be0b9c2e151e477429b7a, https://github.com/phpstan/phpstan-strict-rules/commit/0c82c96f2a55d8b91bbc7ee6512c94f68a206b43)
7070
* Add `@readonly` rule that disallows default values ([#1391](https://github.com/phpstan/phpstan-src/pull/1391)), thanks @herndlm!

conf/bleedingEdge.neon

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ parameters:
66

77
arrayFilter: true
88
arrayValues: true
9-
looseComparison: true
109
readOnlyByPhpDoc: true
1110
pure: true
1211
requireFileExists: true

conf/config.level4.neon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ rules:
2121
- PHPStan\Rules\Traits\NotAnalysedTraitRule
2222

2323
conditionalTags:
24-
PHPStan\Rules\Comparison\ConstantLooseComparisonRule:
25-
phpstan.rules.rule: %featureToggles.looseComparison%
2624
PHPStan\Rules\DeadCode\CallToConstructorStatementWithoutImpurePointsRule:
2725
phpstan.rules.rule: %featureToggles.pure%
2826
PHPStan\Rules\DeadCode\PossiblyPureNewCollector:
@@ -220,6 +218,8 @@ services:
220218
treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain%
221219
reportAlwaysTrueInLastCondition: %reportAlwaysTrueInLastCondition%
222220
treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain%
221+
tags:
222+
- phpstan.rules.rule
223223

224224
-
225225
class: PHPStan\Rules\Comparison\TernaryOperatorConstantConditionRule

conf/config.neon

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ parameters:
2727
arrayFilter: false
2828
arrayValues: false
2929
illegalConstructorMethodCall: false
30-
looseComparison: false
3130
readOnlyByPhpDoc: false
3231
stricterFunctionMap: false
3332
pure: false
@@ -862,7 +861,6 @@ services:
862861
class: PHPStan\Rules\Comparison\ConstantConditionRuleHelper
863862
arguments:
864863
treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain%
865-
looseComparisonRuleEnabled: %featureToggles.looseComparison%
866864

867865
-
868866
class: PHPStan\Rules\Comparison\ImpossibleCheckTypeHelper

conf/parametersSchema.neon

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ parametersSchema:
3333
arrayFilter: bool(),
3434
arrayValues: bool(),
3535
illegalConstructorMethodCall: bool(),
36-
looseComparison: bool(),
3736
readOnlyByPhpDoc: bool()
3837
stricterFunctionMap: bool()
3938
pure: bool()

src/Rules/Comparison/ConstantConditionRuleHelper.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ final class ConstantConditionRuleHelper
1414
public function __construct(
1515
private ImpossibleCheckTypeHelper $impossibleCheckTypeHelper,
1616
private bool $treatPhpDocTypesAsCertain,
17-
private bool $looseComparisonRuleEnabled,
1817
)
1918
{
2019
}
@@ -32,10 +31,8 @@ public function shouldReportAlwaysTrueByDefault(Expr $expr): bool
3231
public function shouldSkip(Scope $scope, Expr $expr): bool
3332
{
3433
if (
35-
$this->looseComparisonRuleEnabled
36-
&& ($expr instanceof Expr\BinaryOp\Equal
37-
|| $expr instanceof Expr\BinaryOp\NotEqual
38-
)
34+
$expr instanceof Expr\BinaryOp\Equal
35+
|| $expr instanceof Expr\BinaryOp\NotEqual
3936
) {
4037
return true;
4138
}

0 commit comments

Comments
 (0)