You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/Rules/Comparison/BooleanNotConstantConditionRule.php
+9-6
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,7 @@
4
4
5
5
usePhpParser\Node;
6
6
usePHPStan\Analyser\Scope;
7
+
usePHPStan\Parser\LastConditionVisitor;
7
8
usePHPStan\Rules\Rule;
8
9
usePHPStan\Rules\RuleErrorBuilder;
9
10
usePHPStan\Type\Constant\ConstantBooleanType;
@@ -47,12 +48,14 @@ public function processNode(
47
48
return$ruleErrorBuilder->tip('Because the type is coming from a PHPDoc, you can turn off this check by setting <fg=cyan>treatPhpDocTypesAsCertain: false</> in your <fg=cyan>%configurationFile%</>.');
48
49
};
49
50
50
-
return [
51
-
$addTip(RuleErrorBuilder::message(sprintf(
52
-
'Negated boolean expression is always %s.',
53
-
$exprType->getValue() ? 'false' : 'true',
54
-
)))->line($node->expr->getLine())->build(),
55
-
];
51
+
if ($exprType->getValue() === true || $node->getAttribute(LastConditionVisitor::ATTRIBUTE_NAME) !== true) {
'Because the type is coming from a PHPDoc, you can turn off this check by setting <fg=cyan>treatPhpDocTypesAsCertain: false</> in your <fg=cyan>%configurationFile%</>.',
0 commit comments