diff --git a/src/Type/Php/IsNumericFunctionTypeSpecifyingExtension.php b/src/Type/Php/IsNumericFunctionTypeSpecifyingExtension.php index 3b16c1b51b..ccc1691e54 100644 --- a/src/Type/Php/IsNumericFunctionTypeSpecifyingExtension.php +++ b/src/Type/Php/IsNumericFunctionTypeSpecifyingExtension.php @@ -41,14 +41,11 @@ public function specifyTypes(FunctionReflection $functionReflection, FuncCall $n $numericTypes = [ new IntegerType(), new FloatType(), - ]; - - if ($context->truthy()) { - $numericTypes[] = new IntersectionType([ + new IntersectionType([ new StringType(), new AccessoryNumericStringType(), - ]); - } + ]), + ]; return $this->typeSpecifier->create($node->getArgs()[0]->value, new UnionType($numericTypes), $context, false, $scope); } diff --git a/tests/PHPStan/Analyser/TypeSpecifierTest.php b/tests/PHPStan/Analyser/TypeSpecifierTest.php index 5838d222c7..668099e45f 100644 --- a/tests/PHPStan/Analyser/TypeSpecifierTest.php +++ b/tests/PHPStan/Analyser/TypeSpecifierTest.php @@ -102,7 +102,7 @@ public function dataCondition(): array [ $this->createFunctionCall('is_numeric'), ['$foo' => 'float|int|numeric-string'], - ['$foo' => '~float|int'], + ['$foo' => '~float|int|numeric-string'], ], [ $this->createFunctionCall('is_scalar'),