From 1d0e5ff9670ca26992885f12d8bb160bc6380c15 Mon Sep 17 00:00:00 2001 From: Ruud Kamphuis Date: Wed, 18 Sep 2024 14:13:08 +0200 Subject: [PATCH] Allow toggling `treatPhpDocTypesAsCertain` tip Fixes phpstan/phpstan#11689 --- conf/config.level4.neon | 19 +++++++++++++++++++ conf/config.level5.neon | 2 ++ conf/config.neon | 2 ++ conf/parametersSchema.neon | 3 +++ .../Classes/ImpossibleInstanceOfRule.php | 5 +++++ .../BooleanAndConstantConditionRule.php | 10 ++++++++++ .../BooleanNotConstantConditionRule.php | 4 ++++ .../BooleanOrConstantConditionRule.php | 10 ++++++++++ .../ConstantLooseComparisonRule.php | 4 ++++ .../DoWhileLoopConstantConditionRule.php | 4 ++++ .../ElseIfConstantConditionRule.php | 4 ++++ .../Comparison/IfConstantConditionRule.php | 4 ++++ .../ImpossibleCheckTypeFunctionCallRule.php | 4 ++++ .../ImpossibleCheckTypeMethodCallRule.php | 4 ++++ ...mpossibleCheckTypeStaticMethodCallRule.php | 4 ++++ .../LogicalXorConstantConditionRule.php | 7 +++++++ ...mparisonOperatorsConstantConditionRule.php | 4 ++++ .../StrictComparisonOfDifferentTypesRule.php | 4 ++++ .../TernaryOperatorConstantConditionRule.php | 4 ++++ .../Comparison/UnreachableIfBranchesRule.php | 4 ++++ .../UnreachableTernaryElseBranchRule.php | 4 ++++ .../WhileLoopAlwaysFalseConditionRule.php | 4 ++++ .../WhileLoopAlwaysTrueConditionRule.php | 4 ++++ src/Rules/Functions/ArrayFilterRule.php | 7 ++++--- src/Rules/Functions/ArrayValuesRule.php | 5 +++-- .../Classes/ImpossibleInstanceOfRuleTest.php | 7 ++++++- .../BooleanAndConstantConditionRuleTest.php | 1 + .../BooleanNotConstantConditionRuleTest.php | 1 + .../BooleanOrConstantConditionRuleTest.php | 1 + .../ConstantLooseComparisonRuleTest.php | 7 ++++++- .../DoWhileLoopConstantConditionRuleTest.php | 1 + .../ElseIfConstantConditionRuleTest.php | 1 + .../IfConstantConditionRuleTest.php | 1 + ...mpossibleCheckTypeFunctionCallRuleTest.php | 1 + ...sibleCheckTypeGenericOverwriteRuleTest.php | 1 + ...sibleCheckTypeMethodCallRuleEqualsTest.php | 1 + .../ImpossibleCheckTypeMethodCallRuleTest.php | 1 + ...sibleCheckTypeStaticMethodCallRuleTest.php | 1 + .../LogicalXorConstantConditionRuleTest.php | 1 + ...isonOperatorsConstantConditionRuleTest.php | 5 ++++- ...rictComparisonOfDifferentTypesRuleTest.php | 7 ++++++- ...rnaryOperatorConstantConditionRuleTest.php | 1 + .../UnreachableIfBranchesRuleTest.php | 1 + .../UnreachableTernaryElseBranchRuleTest.php | 1 + .../WhileLoopAlwaysFalseConditionRuleTest.php | 1 + .../WhileLoopAlwaysTrueConditionRuleTest.php | 1 + .../Rules/Functions/ArrayFilterRuleTest.php | 6 +++++- .../Rules/Functions/ArrayValuesRuleTest.php | 6 +++++- 48 files changed, 174 insertions(+), 11 deletions(-) diff --git a/conf/config.level4.neon b/conf/config.level4.neon index 8f3ecc86bc..7d4441fcf9 100644 --- a/conf/config.level4.neon +++ b/conf/config.level4.neon @@ -67,6 +67,7 @@ services: checkAlwaysTrueInstanceof: %checkAlwaysTrueInstanceof% treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain% reportAlwaysTrueInLastCondition: %reportAlwaysTrueInLastCondition% + treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain% tags: - phpstan.rules.rule @@ -76,6 +77,7 @@ services: treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain% bleedingEdge: %featureToggles.bleedingEdge% reportAlwaysTrueInLastCondition: %reportAlwaysTrueInLastCondition% + treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain% tags: - phpstan.rules.rule @@ -85,6 +87,7 @@ services: treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain% bleedingEdge: %featureToggles.bleedingEdge% reportAlwaysTrueInLastCondition: %reportAlwaysTrueInLastCondition% + treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain% tags: - phpstan.rules.rule @@ -93,6 +96,7 @@ services: arguments: treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain% reportAlwaysTrueInLastCondition: %reportAlwaysTrueInLastCondition% + treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain% tags: - phpstan.rules.rule @@ -149,6 +153,7 @@ services: class: PHPStan\Rules\Comparison\DoWhileLoopConstantConditionRule arguments: treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain% + treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain% tags: - phpstan.rules.rule @@ -157,6 +162,7 @@ services: arguments: treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain% reportAlwaysTrueInLastCondition: %reportAlwaysTrueInLastCondition% + treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain% tags: - phpstan.rules.rule @@ -164,6 +170,7 @@ services: class: PHPStan\Rules\Comparison\IfConstantConditionRule arguments: treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain% + treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain% tags: - phpstan.rules.rule @@ -173,6 +180,7 @@ services: checkAlwaysTrueCheckTypeFunctionCall: %checkAlwaysTrueCheckTypeFunctionCall% treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain% reportAlwaysTrueInLastCondition: %reportAlwaysTrueInLastCondition% + treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain% tags: - phpstan.rules.rule @@ -182,6 +190,7 @@ services: checkAlwaysTrueCheckTypeFunctionCall: %checkAlwaysTrueCheckTypeFunctionCall% treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain% reportAlwaysTrueInLastCondition: %reportAlwaysTrueInLastCondition% + treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain% tags: - phpstan.rules.rule @@ -191,6 +200,7 @@ services: checkAlwaysTrueCheckTypeFunctionCall: %checkAlwaysTrueCheckTypeFunctionCall% treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain% reportAlwaysTrueInLastCondition: %reportAlwaysTrueInLastCondition% + treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain% tags: - phpstan.rules.rule @@ -199,6 +209,7 @@ services: arguments: treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain% reportAlwaysTrueInLastCondition: %reportAlwaysTrueInLastCondition% + treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain% - class: PHPStan\Rules\DeadCode\BetterNoopRule @@ -217,6 +228,7 @@ services: class: PHPStan\Rules\Comparison\NumberComparisonOperatorsConstantConditionRule arguments: treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain% + treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain% tags: - phpstan.rules.rule @@ -226,6 +238,7 @@ services: checkAlwaysTrueStrictComparison: %checkAlwaysTrueStrictComparison% treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain% reportAlwaysTrueInLastCondition: %reportAlwaysTrueInLastCondition% + treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain% tags: - phpstan.rules.rule @@ -235,11 +248,13 @@ services: checkAlwaysTrueLooseComparison: %checkAlwaysTrueLooseComparison% treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain% reportAlwaysTrueInLastCondition: %reportAlwaysTrueInLastCondition% + treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain% - class: PHPStan\Rules\Comparison\TernaryOperatorConstantConditionRule arguments: treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain% + treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain% tags: - phpstan.rules.rule @@ -248,6 +263,7 @@ services: arguments: treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain% disable: %featureToggles.disableUnreachableBranchesRules% + treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain% tags: - phpstan.rules.rule @@ -256,6 +272,7 @@ services: arguments: treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain% disable: %featureToggles.disableUnreachableBranchesRules% + treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain% tags: - phpstan.rules.rule @@ -263,6 +280,7 @@ services: class: PHPStan\Rules\Comparison\WhileLoopAlwaysFalseConditionRule arguments: treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain% + treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain% tags: - phpstan.rules.rule @@ -270,6 +288,7 @@ services: class: PHPStan\Rules\Comparison\WhileLoopAlwaysTrueConditionRule arguments: treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain% + treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain% tags: - phpstan.rules.rule diff --git a/conf/config.level5.neon b/conf/config.level5.neon index 184cee83b8..7b4f758f44 100644 --- a/conf/config.level5.neon +++ b/conf/config.level5.neon @@ -34,11 +34,13 @@ services: class: PHPStan\Rules\Functions\ArrayFilterRule arguments: treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain% + treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain% - class: PHPStan\Rules\Functions\ArrayValuesRule arguments: treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain% + treatPhpDocTypesAsCertainTip: %tips.treatPhpDocTypesAsCertain% - class: PHPStan\Rules\Functions\CallUserFuncRule diff --git a/conf/config.neon b/conf/config.neon index 05a71dbe97..6fa0145f19 100644 --- a/conf/config.neon +++ b/conf/config.neon @@ -161,6 +161,8 @@ parameters: treatPhpDocTypesAsCertain: true usePathConstantsAsConstantString: false rememberPossiblyImpureFunctionValues: true + tips: + treatPhpDocTypesAsCertain: true tipsOfTheDay: true reportMagicMethods: false reportMagicProperties: false diff --git a/conf/parametersSchema.neon b/conf/parametersSchema.neon index 05d6d79f0c..d3359c6867 100644 --- a/conf/parametersSchema.neon +++ b/conf/parametersSchema.neon @@ -129,6 +129,9 @@ parametersSchema: deprecationRulesInstalled: bool() inferPrivatePropertyTypeFromConstructor: bool() + tips: structure([ + treatPhpDocTypesAsCertain: bool() + ]) tipsOfTheDay: bool() reportMaybes: bool() reportMaybesInMethodSignatures: bool() diff --git a/src/Rules/Classes/ImpossibleInstanceOfRule.php b/src/Rules/Classes/ImpossibleInstanceOfRule.php index cf4df676e9..b6d9c84ee3 100644 --- a/src/Rules/Classes/ImpossibleInstanceOfRule.php +++ b/src/Rules/Classes/ImpossibleInstanceOfRule.php @@ -25,6 +25,7 @@ public function __construct( private bool $checkAlwaysTrueInstanceof, private bool $treatPhpDocTypesAsCertain, private bool $reportAlwaysTrueInLastCondition, + private bool $treatPhpDocTypesAsCertainTip, ) { } @@ -71,6 +72,10 @@ public function processNode(Node $node, Scope $scope): array return $ruleErrorBuilder; } + if (!$this->treatPhpDocTypesAsCertainTip) { + return $ruleErrorBuilder; + } + return $ruleErrorBuilder->treatPhpDocTypesAsCertainTip(); }; diff --git a/src/Rules/Comparison/BooleanAndConstantConditionRule.php b/src/Rules/Comparison/BooleanAndConstantConditionRule.php index 8d680e9306..5c05e8ac09 100644 --- a/src/Rules/Comparison/BooleanAndConstantConditionRule.php +++ b/src/Rules/Comparison/BooleanAndConstantConditionRule.php @@ -23,6 +23,7 @@ public function __construct( private bool $treatPhpDocTypesAsCertain, private bool $bleedingEdge, private bool $reportAlwaysTrueInLastCondition, + private bool $treatPhpDocTypesAsCertainTip, ) { } @@ -52,6 +53,9 @@ public function processNode( if ($booleanNativeType instanceof ConstantBooleanType) { return $ruleErrorBuilder; } + if (!$this->treatPhpDocTypesAsCertainTip) { + return $ruleErrorBuilder; + } return $ruleErrorBuilder->treatPhpDocTypesAsCertainTip(); }; @@ -90,6 +94,9 @@ public function processNode( if ($booleanNativeType instanceof ConstantBooleanType) { return $ruleErrorBuilder; } + if (!$this->treatPhpDocTypesAsCertainTip) { + return $ruleErrorBuilder; + } return $ruleErrorBuilder->treatPhpDocTypesAsCertainTip(); }; @@ -122,6 +129,9 @@ public function processNode( if ($booleanNativeType instanceof ConstantBooleanType) { return $ruleErrorBuilder; } + if (!$this->treatPhpDocTypesAsCertainTip) { + return $ruleErrorBuilder; + } return $ruleErrorBuilder->treatPhpDocTypesAsCertainTip(); }; diff --git a/src/Rules/Comparison/BooleanNotConstantConditionRule.php b/src/Rules/Comparison/BooleanNotConstantConditionRule.php index f107804843..2b04d48f80 100644 --- a/src/Rules/Comparison/BooleanNotConstantConditionRule.php +++ b/src/Rules/Comparison/BooleanNotConstantConditionRule.php @@ -20,6 +20,7 @@ public function __construct( private ConstantConditionRuleHelper $helper, private bool $treatPhpDocTypesAsCertain, private bool $reportAlwaysTrueInLastCondition, + private bool $treatPhpDocTypesAsCertainTip, ) { } @@ -45,6 +46,9 @@ public function processNode( if ($booleanNativeType instanceof ConstantBooleanType) { return $ruleErrorBuilder; } + if (!$this->treatPhpDocTypesAsCertainTip) { + return $ruleErrorBuilder; + } return $ruleErrorBuilder->treatPhpDocTypesAsCertainTip(); }; diff --git a/src/Rules/Comparison/BooleanOrConstantConditionRule.php b/src/Rules/Comparison/BooleanOrConstantConditionRule.php index 02f3db6590..f728505cad 100644 --- a/src/Rules/Comparison/BooleanOrConstantConditionRule.php +++ b/src/Rules/Comparison/BooleanOrConstantConditionRule.php @@ -23,6 +23,7 @@ public function __construct( private bool $treatPhpDocTypesAsCertain, private bool $bleedingEdge, private bool $reportAlwaysTrueInLastCondition, + private bool $treatPhpDocTypesAsCertainTip, ) { } @@ -52,6 +53,9 @@ public function processNode( if ($booleanNativeType instanceof ConstantBooleanType) { return $ruleErrorBuilder; } + if (!$this->treatPhpDocTypesAsCertainTip) { + return $ruleErrorBuilder; + } return $ruleErrorBuilder->treatPhpDocTypesAsCertainTip(); }; @@ -90,6 +94,9 @@ public function processNode( if ($booleanNativeType instanceof ConstantBooleanType) { return $ruleErrorBuilder; } + if (!$this->treatPhpDocTypesAsCertainTip) { + return $ruleErrorBuilder; + } return $ruleErrorBuilder->treatPhpDocTypesAsCertainTip(); }; @@ -122,6 +129,9 @@ public function processNode( if ($booleanNativeType instanceof ConstantBooleanType) { return $ruleErrorBuilder; } + if (!$this->treatPhpDocTypesAsCertainTip) { + return $ruleErrorBuilder; + } return $ruleErrorBuilder->treatPhpDocTypesAsCertainTip(); }; diff --git a/src/Rules/Comparison/ConstantLooseComparisonRule.php b/src/Rules/Comparison/ConstantLooseComparisonRule.php index 477210064a..d6fa6c6aac 100644 --- a/src/Rules/Comparison/ConstantLooseComparisonRule.php +++ b/src/Rules/Comparison/ConstantLooseComparisonRule.php @@ -21,6 +21,7 @@ public function __construct( private bool $checkAlwaysTrueLooseComparison, private bool $treatPhpDocTypesAsCertain, private bool $reportAlwaysTrueInLastCondition, + private bool $treatPhpDocTypesAsCertainTip, ) { } @@ -50,6 +51,9 @@ public function processNode(Node $node, Scope $scope): array if ($instanceofTypeWithoutPhpDocs instanceof ConstantBooleanType) { return $ruleErrorBuilder; } + if (!$this->treatPhpDocTypesAsCertainTip) { + return $ruleErrorBuilder; + } return $ruleErrorBuilder->treatPhpDocTypesAsCertainTip(); }; diff --git a/src/Rules/Comparison/DoWhileLoopConstantConditionRule.php b/src/Rules/Comparison/DoWhileLoopConstantConditionRule.php index 3777b5d6e5..9c270afa44 100644 --- a/src/Rules/Comparison/DoWhileLoopConstantConditionRule.php +++ b/src/Rules/Comparison/DoWhileLoopConstantConditionRule.php @@ -22,6 +22,7 @@ final class DoWhileLoopConstantConditionRule implements Rule public function __construct( private ConstantConditionRuleHelper $helper, private bool $treatPhpDocTypesAsCertain, + private bool $treatPhpDocTypesAsCertainTip, ) { } @@ -70,6 +71,9 @@ public function processNode(Node $node, Scope $scope): array if ($booleanNativeType instanceof ConstantBooleanType) { return $ruleErrorBuilder; } + if (!$this->treatPhpDocTypesAsCertainTip) { + return $ruleErrorBuilder; + } return $ruleErrorBuilder->treatPhpDocTypesAsCertainTip(); }; diff --git a/src/Rules/Comparison/ElseIfConstantConditionRule.php b/src/Rules/Comparison/ElseIfConstantConditionRule.php index 80444eb335..a3c0bfab64 100644 --- a/src/Rules/Comparison/ElseIfConstantConditionRule.php +++ b/src/Rules/Comparison/ElseIfConstantConditionRule.php @@ -20,6 +20,7 @@ public function __construct( private ConstantConditionRuleHelper $helper, private bool $treatPhpDocTypesAsCertain, private bool $reportAlwaysTrueInLastCondition, + private bool $treatPhpDocTypesAsCertainTip, ) { } @@ -45,6 +46,9 @@ public function processNode( if ($booleanNativeType instanceof ConstantBooleanType) { return $ruleErrorBuilder; } + if (!$this->treatPhpDocTypesAsCertainTip) { + return $ruleErrorBuilder; + } return $ruleErrorBuilder->treatPhpDocTypesAsCertainTip(); }; diff --git a/src/Rules/Comparison/IfConstantConditionRule.php b/src/Rules/Comparison/IfConstantConditionRule.php index f0eb0e338c..f0d71c3e01 100644 --- a/src/Rules/Comparison/IfConstantConditionRule.php +++ b/src/Rules/Comparison/IfConstantConditionRule.php @@ -18,6 +18,7 @@ final class IfConstantConditionRule implements Rule public function __construct( private ConstantConditionRuleHelper $helper, private bool $treatPhpDocTypesAsCertain, + private bool $treatPhpDocTypesAsCertainTip, ) { } @@ -43,6 +44,9 @@ public function processNode( if ($booleanNativeType instanceof ConstantBooleanType) { return $ruleErrorBuilder; } + if (!$this->treatPhpDocTypesAsCertainTip) { + return $ruleErrorBuilder; + } return $ruleErrorBuilder->treatPhpDocTypesAsCertainTip(); }; diff --git a/src/Rules/Comparison/ImpossibleCheckTypeFunctionCallRule.php b/src/Rules/Comparison/ImpossibleCheckTypeFunctionCallRule.php index a52cc8d718..9033aa3865 100644 --- a/src/Rules/Comparison/ImpossibleCheckTypeFunctionCallRule.php +++ b/src/Rules/Comparison/ImpossibleCheckTypeFunctionCallRule.php @@ -21,6 +21,7 @@ public function __construct( private bool $checkAlwaysTrueCheckTypeFunctionCall, private bool $treatPhpDocTypesAsCertain, private bool $reportAlwaysTrueInLastCondition, + private bool $treatPhpDocTypesAsCertainTip, ) { } @@ -54,6 +55,9 @@ public function processNode(Node $node, Scope $scope): array if ($isAlways !== null) { return $ruleErrorBuilder; } + if (!$this->treatPhpDocTypesAsCertainTip) { + return $ruleErrorBuilder; + } return $ruleErrorBuilder->treatPhpDocTypesAsCertainTip(); }; diff --git a/src/Rules/Comparison/ImpossibleCheckTypeMethodCallRule.php b/src/Rules/Comparison/ImpossibleCheckTypeMethodCallRule.php index 5387a18bfc..7bbcecefd7 100644 --- a/src/Rules/Comparison/ImpossibleCheckTypeMethodCallRule.php +++ b/src/Rules/Comparison/ImpossibleCheckTypeMethodCallRule.php @@ -23,6 +23,7 @@ public function __construct( private bool $checkAlwaysTrueCheckTypeFunctionCall, private bool $treatPhpDocTypesAsCertain, private bool $reportAlwaysTrueInLastCondition, + private bool $treatPhpDocTypesAsCertainTip, ) { } @@ -52,6 +53,9 @@ public function processNode(Node $node, Scope $scope): array if ($isAlways !== null) { return $ruleErrorBuilder; } + if (!$this->treatPhpDocTypesAsCertainTip) { + return $ruleErrorBuilder; + } return $ruleErrorBuilder->treatPhpDocTypesAsCertainTip(); }; diff --git a/src/Rules/Comparison/ImpossibleCheckTypeStaticMethodCallRule.php b/src/Rules/Comparison/ImpossibleCheckTypeStaticMethodCallRule.php index 9ac004779d..df4504cb0e 100644 --- a/src/Rules/Comparison/ImpossibleCheckTypeStaticMethodCallRule.php +++ b/src/Rules/Comparison/ImpossibleCheckTypeStaticMethodCallRule.php @@ -23,6 +23,7 @@ public function __construct( private bool $checkAlwaysTrueCheckTypeFunctionCall, private bool $treatPhpDocTypesAsCertain, private bool $reportAlwaysTrueInLastCondition, + private bool $treatPhpDocTypesAsCertainTip, ) { } @@ -52,6 +53,9 @@ public function processNode(Node $node, Scope $scope): array if ($isAlways !== null) { return $ruleErrorBuilder; } + if (!$this->treatPhpDocTypesAsCertainTip) { + return $ruleErrorBuilder; + } return $ruleErrorBuilder->treatPhpDocTypesAsCertainTip(); }; diff --git a/src/Rules/Comparison/LogicalXorConstantConditionRule.php b/src/Rules/Comparison/LogicalXorConstantConditionRule.php index 971868f1c4..c7531c4196 100644 --- a/src/Rules/Comparison/LogicalXorConstantConditionRule.php +++ b/src/Rules/Comparison/LogicalXorConstantConditionRule.php @@ -21,6 +21,7 @@ public function __construct( private ConstantConditionRuleHelper $helper, private bool $treatPhpDocTypesAsCertain, private bool $reportAlwaysTrueInLastCondition, + private bool $treatPhpDocTypesAsCertainTip, ) { } @@ -44,6 +45,9 @@ public function processNode(Node $node, Scope $scope): array if ($booleanNativeType instanceof ConstantBooleanType) { return $ruleErrorBuilder; } + if (!$this->treatPhpDocTypesAsCertainTip) { + return $ruleErrorBuilder; + } return $ruleErrorBuilder->treatPhpDocTypesAsCertainTip(); }; @@ -77,6 +81,9 @@ public function processNode(Node $node, Scope $scope): array if ($booleanNativeType instanceof ConstantBooleanType) { return $ruleErrorBuilder; } + if (!$this->treatPhpDocTypesAsCertainTip) { + return $ruleErrorBuilder; + } return $ruleErrorBuilder->treatPhpDocTypesAsCertainTip(); }; diff --git a/src/Rules/Comparison/NumberComparisonOperatorsConstantConditionRule.php b/src/Rules/Comparison/NumberComparisonOperatorsConstantConditionRule.php index b208766609..a35a1c740e 100644 --- a/src/Rules/Comparison/NumberComparisonOperatorsConstantConditionRule.php +++ b/src/Rules/Comparison/NumberComparisonOperatorsConstantConditionRule.php @@ -21,6 +21,7 @@ final class NumberComparisonOperatorsConstantConditionRule implements Rule public function __construct( private bool $treatPhpDocTypesAsCertain, + private bool $treatPhpDocTypesAsCertainTip, ) { } @@ -55,6 +56,9 @@ public function processNode( if ($booleanNativeType instanceof ConstantBooleanType) { return $ruleErrorBuilder; } + if (!$this->treatPhpDocTypesAsCertainTip) { + return $ruleErrorBuilder; + } return $ruleErrorBuilder->treatPhpDocTypesAsCertainTip(); }; diff --git a/src/Rules/Comparison/StrictComparisonOfDifferentTypesRule.php b/src/Rules/Comparison/StrictComparisonOfDifferentTypesRule.php index 6780fb91d3..f4ea23258b 100644 --- a/src/Rules/Comparison/StrictComparisonOfDifferentTypesRule.php +++ b/src/Rules/Comparison/StrictComparisonOfDifferentTypesRule.php @@ -21,6 +21,7 @@ public function __construct( private bool $checkAlwaysTrueStrictComparison, private bool $treatPhpDocTypesAsCertain, private bool $reportAlwaysTrueInLastCondition, + private bool $treatPhpDocTypesAsCertainTip, ) { } @@ -53,6 +54,9 @@ public function processNode(Node $node, Scope $scope): array if ($instanceofTypeWithoutPhpDocs instanceof ConstantBooleanType) { return $ruleErrorBuilder; } + if (!$this->treatPhpDocTypesAsCertainTip) { + return $ruleErrorBuilder; + } return $ruleErrorBuilder->treatPhpDocTypesAsCertainTip(); }; diff --git a/src/Rules/Comparison/TernaryOperatorConstantConditionRule.php b/src/Rules/Comparison/TernaryOperatorConstantConditionRule.php index adbe33ac83..10a359ea4b 100644 --- a/src/Rules/Comparison/TernaryOperatorConstantConditionRule.php +++ b/src/Rules/Comparison/TernaryOperatorConstantConditionRule.php @@ -18,6 +18,7 @@ final class TernaryOperatorConstantConditionRule implements Rule public function __construct( private ConstantConditionRuleHelper $helper, private bool $treatPhpDocTypesAsCertain, + private bool $treatPhpDocTypesAsCertainTip, ) { } @@ -43,6 +44,9 @@ public function processNode( if ($booleanNativeType instanceof ConstantBooleanType) { return $ruleErrorBuilder; } + if (!$this->treatPhpDocTypesAsCertainTip) { + return $ruleErrorBuilder; + } return $ruleErrorBuilder->treatPhpDocTypesAsCertainTip(); }; diff --git a/src/Rules/Comparison/UnreachableIfBranchesRule.php b/src/Rules/Comparison/UnreachableIfBranchesRule.php index 7b3682f213..5d6b001e88 100644 --- a/src/Rules/Comparison/UnreachableIfBranchesRule.php +++ b/src/Rules/Comparison/UnreachableIfBranchesRule.php @@ -18,6 +18,7 @@ public function __construct( private ConstantConditionRuleHelper $helper, private bool $treatPhpDocTypesAsCertain, private bool $disable, + private bool $treatPhpDocTypesAsCertainTip, ) { } @@ -48,6 +49,9 @@ public function processNode(Node $node, Scope $scope): array if ($booleanNativeType instanceof ConstantBooleanType) { return $ruleErrorBuilder; } + if (!$this->treatPhpDocTypesAsCertainTip) { + return $ruleErrorBuilder; + } return $ruleErrorBuilder->treatPhpDocTypesAsCertainTip(); }; diff --git a/src/Rules/Comparison/UnreachableTernaryElseBranchRule.php b/src/Rules/Comparison/UnreachableTernaryElseBranchRule.php index 0ce221250b..63ea467ce4 100644 --- a/src/Rules/Comparison/UnreachableTernaryElseBranchRule.php +++ b/src/Rules/Comparison/UnreachableTernaryElseBranchRule.php @@ -18,6 +18,7 @@ public function __construct( private ConstantConditionRuleHelper $helper, private bool $treatPhpDocTypesAsCertain, private bool $disable, + private bool $treatPhpDocTypesAsCertainTip, ) { } @@ -49,6 +50,9 @@ public function processNode(Node $node, Scope $scope): array if ($booleanNativeType instanceof ConstantBooleanType) { return $ruleErrorBuilder; } + if (!$this->treatPhpDocTypesAsCertainTip) { + return $ruleErrorBuilder; + } return $ruleErrorBuilder->treatPhpDocTypesAsCertainTip(); }; diff --git a/src/Rules/Comparison/WhileLoopAlwaysFalseConditionRule.php b/src/Rules/Comparison/WhileLoopAlwaysFalseConditionRule.php index b6eaa9d790..2b9fbdbdac 100644 --- a/src/Rules/Comparison/WhileLoopAlwaysFalseConditionRule.php +++ b/src/Rules/Comparison/WhileLoopAlwaysFalseConditionRule.php @@ -18,6 +18,7 @@ final class WhileLoopAlwaysFalseConditionRule implements Rule public function __construct( private ConstantConditionRuleHelper $helper, private bool $treatPhpDocTypesAsCertain, + private bool $treatPhpDocTypesAsCertainTip, ) { } @@ -43,6 +44,9 @@ public function processNode( if ($booleanNativeType instanceof ConstantBooleanType) { return $ruleErrorBuilder; } + if (!$this->treatPhpDocTypesAsCertainTip) { + return $ruleErrorBuilder; + } return $ruleErrorBuilder->treatPhpDocTypesAsCertainTip(); }; diff --git a/src/Rules/Comparison/WhileLoopAlwaysTrueConditionRule.php b/src/Rules/Comparison/WhileLoopAlwaysTrueConditionRule.php index 68ac27fbf2..74b46b3d69 100644 --- a/src/Rules/Comparison/WhileLoopAlwaysTrueConditionRule.php +++ b/src/Rules/Comparison/WhileLoopAlwaysTrueConditionRule.php @@ -21,6 +21,7 @@ final class WhileLoopAlwaysTrueConditionRule implements Rule public function __construct( private ConstantConditionRuleHelper $helper, private bool $treatPhpDocTypesAsCertain, + private bool $treatPhpDocTypesAsCertainTip, ) { } @@ -70,6 +71,9 @@ public function processNode( if ($booleanNativeType instanceof ConstantBooleanType) { return $ruleErrorBuilder; } + if (!$this->treatPhpDocTypesAsCertainTip) { + return $ruleErrorBuilder; + } return $ruleErrorBuilder->treatPhpDocTypesAsCertainTip(); }; diff --git a/src/Rules/Functions/ArrayFilterRule.php b/src/Rules/Functions/ArrayFilterRule.php index 7eeb304c3d..abcc1e9dc8 100644 --- a/src/Rules/Functions/ArrayFilterRule.php +++ b/src/Rules/Functions/ArrayFilterRule.php @@ -24,6 +24,7 @@ final class ArrayFilterRule implements Rule public function __construct( private ReflectionProvider $reflectionProvider, private bool $treatPhpDocTypesAsCertain, + private bool $treatPhpDocTypesAsCertainTip, ) { } @@ -79,7 +80,7 @@ public function processNode(Node $node, Scope $scope): array ))->identifier('arrayFilter.empty'); if ($this->treatPhpDocTypesAsCertain) { $nativeArrayType = $scope->getNativeType($args[0]->value); - if (!$nativeArrayType->isIterableAtLeastOnce()->no()) { + if ($this->treatPhpDocTypesAsCertainTip && !$nativeArrayType->isIterableAtLeastOnce()->no()) { $errorBuilder->treatPhpDocTypesAsCertainTip(); } } @@ -101,7 +102,7 @@ public function processNode(Node $node, Scope $scope): array if ($this->treatPhpDocTypesAsCertain) { $nativeArrayType = $scope->getNativeType($args[0]->value); $isNativeSuperType = $falsyType->isSuperTypeOf($nativeArrayType->getIterableValueType()); - if (!$isNativeSuperType->no()) { + if ($this->treatPhpDocTypesAsCertainTip && !$isNativeSuperType->no()) { $errorBuilder->treatPhpDocTypesAsCertainTip(); } } @@ -121,7 +122,7 @@ public function processNode(Node $node, Scope $scope): array if ($this->treatPhpDocTypesAsCertain) { $nativeArrayType = $scope->getNativeType($args[0]->value); $isNativeSuperType = $falsyType->isSuperTypeOf($nativeArrayType->getIterableValueType()); - if (!$isNativeSuperType->yes()) { + if ($this->treatPhpDocTypesAsCertainTip && !$isNativeSuperType->yes()) { $errorBuilder->treatPhpDocTypesAsCertainTip(); } } diff --git a/src/Rules/Functions/ArrayValuesRule.php b/src/Rules/Functions/ArrayValuesRule.php index cf058b54a8..2b969a42aa 100644 --- a/src/Rules/Functions/ArrayValuesRule.php +++ b/src/Rules/Functions/ArrayValuesRule.php @@ -24,6 +24,7 @@ final class ArrayValuesRule implements Rule public function __construct( private readonly ReflectionProvider $reflectionProvider, private readonly bool $treatPhpDocTypesAsCertain, + private bool $treatPhpDocTypesAsCertainTip, ) { } @@ -84,7 +85,7 @@ public function processNode(Node $node, Scope $scope): array ))->identifier('arrayValues.empty'); if ($this->treatPhpDocTypesAsCertain) { $nativeArrayType = $scope->getNativeType($args[0]->value); - if (!$nativeArrayType->isIterableAtLeastOnce()->no()) { + if ($this->treatPhpDocTypesAsCertainTip && !$nativeArrayType->isIterableAtLeastOnce()->no()) { $errorBuilder->treatPhpDocTypesAsCertainTip(); } } @@ -102,7 +103,7 @@ public function processNode(Node $node, Scope $scope): array ))->identifier('arrayValues.list'); if ($this->treatPhpDocTypesAsCertain) { $nativeArrayType = $scope->getNativeType($args[0]->value); - if (!$nativeArrayType->isList()->yes()) { + if ($this->treatPhpDocTypesAsCertainTip && !$nativeArrayType->isList()->yes()) { $errorBuilder->treatPhpDocTypesAsCertainTip(); } } diff --git a/tests/PHPStan/Rules/Classes/ImpossibleInstanceOfRuleTest.php b/tests/PHPStan/Rules/Classes/ImpossibleInstanceOfRuleTest.php index 562401245b..fde28cab1a 100644 --- a/tests/PHPStan/Rules/Classes/ImpossibleInstanceOfRuleTest.php +++ b/tests/PHPStan/Rules/Classes/ImpossibleInstanceOfRuleTest.php @@ -20,7 +20,12 @@ class ImpossibleInstanceOfRuleTest extends RuleTestCase protected function getRule(): Rule { - return new ImpossibleInstanceOfRule($this->checkAlwaysTrueInstanceOf, $this->treatPhpDocTypesAsCertain, $this->reportAlwaysTrueInLastCondition); + return new ImpossibleInstanceOfRule( + $this->checkAlwaysTrueInstanceOf, + $this->treatPhpDocTypesAsCertain, + $this->reportAlwaysTrueInLastCondition, + true, + ); } protected function shouldTreatPhpDocTypesAsCertain(): bool diff --git a/tests/PHPStan/Rules/Comparison/BooleanAndConstantConditionRuleTest.php b/tests/PHPStan/Rules/Comparison/BooleanAndConstantConditionRuleTest.php index d8a3d75a45..b0d674c716 100644 --- a/tests/PHPStan/Rules/Comparison/BooleanAndConstantConditionRuleTest.php +++ b/tests/PHPStan/Rules/Comparison/BooleanAndConstantConditionRuleTest.php @@ -34,6 +34,7 @@ protected function getRule(): Rule $this->treatPhpDocTypesAsCertain, $this->bleedingEdge, $this->reportAlwaysTrueInLastCondition, + true, ); } diff --git a/tests/PHPStan/Rules/Comparison/BooleanNotConstantConditionRuleTest.php b/tests/PHPStan/Rules/Comparison/BooleanNotConstantConditionRuleTest.php index 43ecf911a6..f8bb760dcf 100644 --- a/tests/PHPStan/Rules/Comparison/BooleanNotConstantConditionRuleTest.php +++ b/tests/PHPStan/Rules/Comparison/BooleanNotConstantConditionRuleTest.php @@ -32,6 +32,7 @@ protected function getRule(): Rule ), $this->treatPhpDocTypesAsCertain, $this->reportAlwaysTrueInLastCondition, + true, ); } diff --git a/tests/PHPStan/Rules/Comparison/BooleanOrConstantConditionRuleTest.php b/tests/PHPStan/Rules/Comparison/BooleanOrConstantConditionRuleTest.php index ee616efbc5..38092ce153 100644 --- a/tests/PHPStan/Rules/Comparison/BooleanOrConstantConditionRuleTest.php +++ b/tests/PHPStan/Rules/Comparison/BooleanOrConstantConditionRuleTest.php @@ -35,6 +35,7 @@ protected function getRule(): Rule $this->treatPhpDocTypesAsCertain, $this->bleedingEdge, $this->reportAlwaysTrueInLastCondition, + true, ); } diff --git a/tests/PHPStan/Rules/Comparison/ConstantLooseComparisonRuleTest.php b/tests/PHPStan/Rules/Comparison/ConstantLooseComparisonRuleTest.php index f8a0b7d87d..f34dd4876b 100644 --- a/tests/PHPStan/Rules/Comparison/ConstantLooseComparisonRuleTest.php +++ b/tests/PHPStan/Rules/Comparison/ConstantLooseComparisonRuleTest.php @@ -20,7 +20,12 @@ class ConstantLooseComparisonRuleTest extends RuleTestCase protected function getRule(): Rule { - return new ConstantLooseComparisonRule($this->checkAlwaysTrueStrictComparison, $this->treatPhpDocTypesAsCertain, $this->reportAlwaysTrueInLastCondition); + return new ConstantLooseComparisonRule( + $this->checkAlwaysTrueStrictComparison, + $this->treatPhpDocTypesAsCertain, + $this->reportAlwaysTrueInLastCondition, + true, + ); } public function testRule(): void diff --git a/tests/PHPStan/Rules/Comparison/DoWhileLoopConstantConditionRuleTest.php b/tests/PHPStan/Rules/Comparison/DoWhileLoopConstantConditionRuleTest.php index 703c2e5a87..7d05804a46 100644 --- a/tests/PHPStan/Rules/Comparison/DoWhileLoopConstantConditionRuleTest.php +++ b/tests/PHPStan/Rules/Comparison/DoWhileLoopConstantConditionRuleTest.php @@ -28,6 +28,7 @@ protected function getRule(): Rule true, ), $this->treatPhpDocTypesAsCertain, + true, ); } diff --git a/tests/PHPStan/Rules/Comparison/ElseIfConstantConditionRuleTest.php b/tests/PHPStan/Rules/Comparison/ElseIfConstantConditionRuleTest.php index 0643363ef1..bf67146684 100644 --- a/tests/PHPStan/Rules/Comparison/ElseIfConstantConditionRuleTest.php +++ b/tests/PHPStan/Rules/Comparison/ElseIfConstantConditionRuleTest.php @@ -32,6 +32,7 @@ protected function getRule(): Rule ), $this->treatPhpDocTypesAsCertain, $this->reportAlwaysTrueInLastCondition, + true, ); } diff --git a/tests/PHPStan/Rules/Comparison/IfConstantConditionRuleTest.php b/tests/PHPStan/Rules/Comparison/IfConstantConditionRuleTest.php index a7c2629d16..479f5db928 100644 --- a/tests/PHPStan/Rules/Comparison/IfConstantConditionRuleTest.php +++ b/tests/PHPStan/Rules/Comparison/IfConstantConditionRuleTest.php @@ -29,6 +29,7 @@ protected function getRule(): Rule true, ), $this->treatPhpDocTypesAsCertain, + true, ); } diff --git a/tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php b/tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php index 88d9315d84..16529f3a74 100644 --- a/tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php +++ b/tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php @@ -36,6 +36,7 @@ protected function getRule(): Rule $this->checkAlwaysTrueCheckTypeFunctionCall, $this->treatPhpDocTypesAsCertain, $this->reportAlwaysTrueInLastCondition, + true, ); } diff --git a/tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeGenericOverwriteRuleTest.php b/tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeGenericOverwriteRuleTest.php index 9be90b8054..152cbaa4a4 100644 --- a/tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeGenericOverwriteRuleTest.php +++ b/tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeGenericOverwriteRuleTest.php @@ -24,6 +24,7 @@ public function getRule(): Rule true, true, false, + true, ); } diff --git a/tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeMethodCallRuleEqualsTest.php b/tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeMethodCallRuleEqualsTest.php index 3aa4bf0810..79e7dfb00e 100644 --- a/tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeMethodCallRuleEqualsTest.php +++ b/tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeMethodCallRuleEqualsTest.php @@ -24,6 +24,7 @@ public function getRule(): Rule true, true, false, + true, ); } diff --git a/tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeMethodCallRuleTest.php b/tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeMethodCallRuleTest.php index 7a697e6ffa..5f14946fbb 100644 --- a/tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeMethodCallRuleTest.php +++ b/tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeMethodCallRuleTest.php @@ -28,6 +28,7 @@ public function getRule(): Rule true, $this->treatPhpDocTypesAsCertain, $this->reportAlwaysTrueInLastCondition, + true, ); } diff --git a/tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeStaticMethodCallRuleTest.php b/tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeStaticMethodCallRuleTest.php index a93147ab83..b173c04eea 100644 --- a/tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeStaticMethodCallRuleTest.php +++ b/tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeStaticMethodCallRuleTest.php @@ -28,6 +28,7 @@ public function getRule(): Rule true, $this->treatPhpDocTypesAsCertain, $this->reportAlwaysTrueInLastCondition, + true, ); } diff --git a/tests/PHPStan/Rules/Comparison/LogicalXorConstantConditionRuleTest.php b/tests/PHPStan/Rules/Comparison/LogicalXorConstantConditionRuleTest.php index 24080f2e00..7e6c6015ca 100644 --- a/tests/PHPStan/Rules/Comparison/LogicalXorConstantConditionRuleTest.php +++ b/tests/PHPStan/Rules/Comparison/LogicalXorConstantConditionRuleTest.php @@ -31,6 +31,7 @@ protected function getRule(): TRule ), $this->treatPhpDocTypesAsCertain, $this->reportAlwaysTrueInLastCondition, + true, ); } diff --git a/tests/PHPStan/Rules/Comparison/NumberComparisonOperatorsConstantConditionRuleTest.php b/tests/PHPStan/Rules/Comparison/NumberComparisonOperatorsConstantConditionRuleTest.php index 4d89a240be..4d9733a493 100644 --- a/tests/PHPStan/Rules/Comparison/NumberComparisonOperatorsConstantConditionRuleTest.php +++ b/tests/PHPStan/Rules/Comparison/NumberComparisonOperatorsConstantConditionRuleTest.php @@ -16,7 +16,10 @@ class NumberComparisonOperatorsConstantConditionRuleTest extends RuleTestCase protected function getRule(): Rule { - return new NumberComparisonOperatorsConstantConditionRule($this->treatPhpDocTypesAsCertain); + return new NumberComparisonOperatorsConstantConditionRule( + $this->treatPhpDocTypesAsCertain, + true, + ); } public function testBug8277(): void diff --git a/tests/PHPStan/Rules/Comparison/StrictComparisonOfDifferentTypesRuleTest.php b/tests/PHPStan/Rules/Comparison/StrictComparisonOfDifferentTypesRuleTest.php index e1c99901de..2bfd60e993 100644 --- a/tests/PHPStan/Rules/Comparison/StrictComparisonOfDifferentTypesRuleTest.php +++ b/tests/PHPStan/Rules/Comparison/StrictComparisonOfDifferentTypesRuleTest.php @@ -21,7 +21,12 @@ class StrictComparisonOfDifferentTypesRuleTest extends RuleTestCase protected function getRule(): Rule { - return new StrictComparisonOfDifferentTypesRule($this->checkAlwaysTrueStrictComparison, $this->treatPhpDocTypesAsCertain, $this->reportAlwaysTrueInLastCondition); + return new StrictComparisonOfDifferentTypesRule( + $this->checkAlwaysTrueStrictComparison, + $this->treatPhpDocTypesAsCertain, + $this->reportAlwaysTrueInLastCondition, + true, + ); } protected function shouldTreatPhpDocTypesAsCertain(): bool diff --git a/tests/PHPStan/Rules/Comparison/TernaryOperatorConstantConditionRuleTest.php b/tests/PHPStan/Rules/Comparison/TernaryOperatorConstantConditionRuleTest.php index 71fce9241d..fa4a13a729 100644 --- a/tests/PHPStan/Rules/Comparison/TernaryOperatorConstantConditionRuleTest.php +++ b/tests/PHPStan/Rules/Comparison/TernaryOperatorConstantConditionRuleTest.php @@ -28,6 +28,7 @@ protected function getRule(): Rule true, ), $this->treatPhpDocTypesAsCertain, + true, ); } diff --git a/tests/PHPStan/Rules/Comparison/UnreachableIfBranchesRuleTest.php b/tests/PHPStan/Rules/Comparison/UnreachableIfBranchesRuleTest.php index 7843308281..f31bbe5023 100644 --- a/tests/PHPStan/Rules/Comparison/UnreachableIfBranchesRuleTest.php +++ b/tests/PHPStan/Rules/Comparison/UnreachableIfBranchesRuleTest.php @@ -29,6 +29,7 @@ protected function getRule(): Rule ), $this->treatPhpDocTypesAsCertain, false, + true, ); } diff --git a/tests/PHPStan/Rules/Comparison/UnreachableTernaryElseBranchRuleTest.php b/tests/PHPStan/Rules/Comparison/UnreachableTernaryElseBranchRuleTest.php index c145cc7cfa..00175cc6fc 100644 --- a/tests/PHPStan/Rules/Comparison/UnreachableTernaryElseBranchRuleTest.php +++ b/tests/PHPStan/Rules/Comparison/UnreachableTernaryElseBranchRuleTest.php @@ -29,6 +29,7 @@ protected function getRule(): Rule ), $this->treatPhpDocTypesAsCertain, false, + true, ); } diff --git a/tests/PHPStan/Rules/Comparison/WhileLoopAlwaysFalseConditionRuleTest.php b/tests/PHPStan/Rules/Comparison/WhileLoopAlwaysFalseConditionRuleTest.php index 42675f9d8a..349eb489ed 100644 --- a/tests/PHPStan/Rules/Comparison/WhileLoopAlwaysFalseConditionRuleTest.php +++ b/tests/PHPStan/Rules/Comparison/WhileLoopAlwaysFalseConditionRuleTest.php @@ -28,6 +28,7 @@ protected function getRule(): Rule true, ), $this->treatPhpDocTypesAsCertain, + true, ); } diff --git a/tests/PHPStan/Rules/Comparison/WhileLoopAlwaysTrueConditionRuleTest.php b/tests/PHPStan/Rules/Comparison/WhileLoopAlwaysTrueConditionRuleTest.php index e6f158f91a..2be9972f15 100644 --- a/tests/PHPStan/Rules/Comparison/WhileLoopAlwaysTrueConditionRuleTest.php +++ b/tests/PHPStan/Rules/Comparison/WhileLoopAlwaysTrueConditionRuleTest.php @@ -28,6 +28,7 @@ protected function getRule(): Rule true, ), $this->treatPhpDocTypesAsCertain, + true, ); } diff --git a/tests/PHPStan/Rules/Functions/ArrayFilterRuleTest.php b/tests/PHPStan/Rules/Functions/ArrayFilterRuleTest.php index 95ac9ed295..e0a51fc2a8 100644 --- a/tests/PHPStan/Rules/Functions/ArrayFilterRuleTest.php +++ b/tests/PHPStan/Rules/Functions/ArrayFilterRuleTest.php @@ -15,7 +15,11 @@ class ArrayFilterRuleTest extends RuleTestCase protected function getRule(): Rule { - return new ArrayFilterRule($this->createReflectionProvider(), $this->treatPhpDocTypesAsCertain); + return new ArrayFilterRule( + $this->createReflectionProvider(), + $this->treatPhpDocTypesAsCertain, + true, + ); } public function testFile(): void diff --git a/tests/PHPStan/Rules/Functions/ArrayValuesRuleTest.php b/tests/PHPStan/Rules/Functions/ArrayValuesRuleTest.php index c945b1efea..ec6ed43e38 100644 --- a/tests/PHPStan/Rules/Functions/ArrayValuesRuleTest.php +++ b/tests/PHPStan/Rules/Functions/ArrayValuesRuleTest.php @@ -16,7 +16,11 @@ class ArrayValuesRuleTest extends RuleTestCase protected function getRule(): Rule { - return new ArrayValuesRule($this->createReflectionProvider(), $this->treatPhpDocTypesAsCertain); + return new ArrayValuesRule( + $this->createReflectionProvider(), + $this->treatPhpDocTypesAsCertain, + true, + ); } public function testFile(): void