diff --git a/src/Analyser/TypeSpecifier.php b/src/Analyser/TypeSpecifier.php index fa3a1b4443..2a56f6daa4 100644 --- a/src/Analyser/TypeSpecifier.php +++ b/src/Analyser/TypeSpecifier.php @@ -38,6 +38,7 @@ use PHPStan\Type\ObjectType; use PHPStan\Type\ObjectWithoutClassType; use PHPStan\Type\StaticType; +use PHPStan\Type\StaticTypeFactory; use PHPStan\Type\Type; use PHPStan\Type\TypeCombinator; use PHPStan\Type\TypeTraverser; @@ -652,10 +653,10 @@ public function specifyTypesInCondition( private function handleDefaultTruthyOrFalseyContext(TypeSpecifierContext $context, Expr $expr): SpecifiedTypes { if (!$context->truthy()) { - $type = TypeUtils::truthy(); + $type = StaticTypeFactory::truthy(); return $this->create($expr, $type, TypeSpecifierContext::createFalse()); } elseif (!$context->falsey()) { - $type = TypeUtils::falsey(); + $type = StaticTypeFactory::falsey(); return $this->create($expr, $type, TypeSpecifierContext::createFalse()); } diff --git a/src/Type/MixedType.php b/src/Type/MixedType.php index ce9dba62cb..94ec9e642d 100644 --- a/src/Type/MixedType.php +++ b/src/Type/MixedType.php @@ -262,7 +262,7 @@ function () use ($level): string { public function toBoolean(): BooleanType { - if ($this->subtractedType !== null && TypeUtils::falsey()->equals($this->subtractedType)) { + if ($this->subtractedType !== null && StaticTypeFactory::falsey()->equals($this->subtractedType)) { return new ConstantBooleanType(true); } diff --git a/src/Type/Php/ArrayFilterFunctionReturnTypeReturnTypeExtension.php b/src/Type/Php/ArrayFilterFunctionReturnTypeReturnTypeExtension.php index bc10097b78..ef453bb41e 100644 --- a/src/Type/Php/ArrayFilterFunctionReturnTypeReturnTypeExtension.php +++ b/src/Type/Php/ArrayFilterFunctionReturnTypeReturnTypeExtension.php @@ -15,6 +15,7 @@ use PHPStan\Type\MixedType; use PHPStan\Type\NeverType; use PHPStan\Type\NullType; +use PHPStan\Type\StaticTypeFactory; use PHPStan\Type\Type; use PHPStan\Type\TypeCombinator; use PHPStan\Type\TypeUtils; @@ -77,7 +78,7 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection, public function removeFalsey(Type $type): Type { - $falseyTypes = TypeUtils::falsey(); + $falseyTypes = StaticTypeFactory::falsey(); if ($type instanceof ConstantArrayType) { $keys = $type->getKeyTypes(); diff --git a/src/Type/StaticTypeFactory.php b/src/Type/StaticTypeFactory.php new file mode 100644 index 0000000000..ba99a36130 --- /dev/null +++ b/src/Type/StaticTypeFactory.php @@ -0,0 +1,44 @@ +