Skip to content

Commit fd7bad3

Browse files
staabmondrejmirtes
authored andcommitted
Cleanup instanceof ConstantBooleanType checks
1 parent a063119 commit fd7bad3

File tree

3 files changed

+2
-13
lines changed

3 files changed

+2
-13
lines changed

phpstan-baseline.neon

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,11 +1307,6 @@ parameters:
13071307
count: 1
13081308
path: src/Type/Php/ArrayCombineFunctionReturnTypeExtension.php
13091309

1310-
-
1311-
message: "#^Doing instanceof PHPStan\\\\Type\\\\Constant\\\\ConstantBooleanType is error\\-prone and deprecated\\. Use Type\\:\\:isTrue\\(\\) or Type\\:\\:isFalse\\(\\) instead\\.$#"
1312-
count: 1
1313-
path: src/Type/Php/ArrayFilterFunctionReturnTypeHelper.php
1314-
13151310
-
13161311
message: "#^Doing instanceof PHPStan\\\\Type\\\\Constant\\\\ConstantStringType is error\\-prone and deprecated\\. Use Type\\:\\:getConstantStrings\\(\\) instead\\.$#"
13171312
count: 1
@@ -1322,11 +1317,6 @@ parameters:
13221317
count: 4
13231318
path: src/Type/Php/ArrayMergeFunctionDynamicReturnTypeExtension.php
13241319

1325-
-
1326-
message: "#^Doing instanceof PHPStan\\\\Type\\\\Constant\\\\ConstantBooleanType is error\\-prone and deprecated\\. Use Type\\:\\:isTrue\\(\\) or Type\\:\\:isFalse\\(\\) instead\\.$#"
1327-
count: 1
1328-
path: src/Type/Php/ArraySearchFunctionDynamicReturnTypeExtension.php
1329-
13301320
-
13311321
message: "#^Doing instanceof PHPStan\\\\Type\\\\ConstantScalarType is error\\-prone and deprecated\\. Use Type\\:\\:isConstantScalarValue\\(\\) or Type\\:\\:getConstantScalarTypes\\(\\) or Type\\:\\:getConstantScalarValues\\(\\) instead\\.$#"
13321322
count: 16

src/Type/Php/ArrayFilterFunctionReturnTypeHelper.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
use PHPStan\Type\BenevolentUnionType;
2222
use PHPStan\Type\Constant\ConstantArrayType;
2323
use PHPStan\Type\Constant\ConstantArrayTypeBuilder;
24-
use PHPStan\Type\Constant\ConstantBooleanType;
2524
use PHPStan\Type\Constant\ConstantIntegerType;
2625
use PHPStan\Type\ErrorType;
2726
use PHPStan\Type\MixedType;
@@ -255,7 +254,7 @@ private function processKeyAndItemType(MutatingScope $scope, Type $keyType, Type
255254
return [
256255
$keyVarName !== null ? $scope->getVariableType($keyVarName) : $keyType,
257256
$itemVarName !== null ? $scope->getVariableType($itemVarName) : $itemType,
258-
!$booleanResult instanceof ConstantBooleanType,
257+
!$booleanResult->isTrue()->yes(),
259258
];
260259
}
261260

src/Type/Php/ArraySearchFunctionDynamicReturnTypeExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
4343
}
4444

4545
$strictArgType = $scope->getType($functionCall->getArgs()[2]->value);
46-
if (!$strictArgType instanceof ConstantBooleanType || $strictArgType->getValue() === false) {
46+
if (!$strictArgType->isTrue()->yes()) {
4747
return TypeCombinator::union($haystackArgType->getIterableKeyType(), new ConstantBooleanType(false));
4848
}
4949

0 commit comments

Comments
 (0)