Skip to content

Commit 11e0ab6

Browse files
herndlmondrejmirtes
authored andcommitted
Remove unnecessary instanceof ConstantBooleanType in loop analysis
1 parent c875e83 commit 11e0ab6

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

phpstan-baseline.neon

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ parameters:
5858

5959
-
6060
message: "#^Doing instanceof PHPStan\\\\Type\\\\Constant\\\\ConstantBooleanType is error\\-prone and deprecated\\. Use Type\\:\\:isTrue\\(\\) or Type\\:\\:isFalse\\(\\) instead\\.$#"
61-
count: 3
61+
count: 2
6262
path: src/Analyser/NodeScopeResolver.php
6363

6464
-

src/Analyser/NodeScopeResolver.php

+1-6
Original file line numberDiff line numberDiff line change
@@ -1320,12 +1320,7 @@ private function processStmtNode(
13201320
$initScope = $condResult->getScope();
13211321
$condResultScope = $condResult->getScope();
13221322
$condTruthiness = ($this->treatPhpDocTypesAsCertain ? $condResultScope->getType($condExpr) : $condResultScope->getNativeType($condExpr))->toBoolean();
1323-
if ($condTruthiness instanceof ConstantBooleanType) {
1324-
$condTruthinessTrinary = TrinaryLogic::createFromBoolean($condTruthiness->getValue());
1325-
} else {
1326-
$condTruthinessTrinary = TrinaryLogic::createMaybe();
1327-
}
1328-
$isIterableAtLeastOnce = $isIterableAtLeastOnce->and($condTruthinessTrinary);
1323+
$isIterableAtLeastOnce = $isIterableAtLeastOnce->and($condTruthiness->isTrue());
13291324
$hasYield = $hasYield || $condResult->hasYield();
13301325
$throwPoints = array_merge($throwPoints, $condResult->getThrowPoints());
13311326
$impurePoints = array_merge($impurePoints, $condResult->getImpurePoints());

0 commit comments

Comments
 (0)