Skip to content

Commit 2a39e5a

Browse files
committed
hrtime(true) returns benevolent union type
1 parent 83d15e3 commit 2a39e5a

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/Type/Php/HrtimeFunctionReturnTypeExtension.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use PHPStan\Type\IntegerType;
1313
use PHPStan\Type\Type;
1414
use PHPStan\Type\TypeCombinator;
15+
use PHPStan\Type\TypeUtils;
1516

1617
class HrtimeFunctionReturnTypeExtension implements \PHPStan\Type\DynamicFunctionReturnTypeExtension
1718
{
@@ -24,7 +25,7 @@ public function isFunctionSupported(FunctionReflection $functionReflection): boo
2425
public function getTypeFromFunctionCall(FunctionReflection $functionReflection, FuncCall $functionCall, Scope $scope): Type
2526
{
2627
$arrayType = new ConstantArrayType([new ConstantIntegerType(0), new ConstantIntegerType(1)], [new IntegerType(), new IntegerType()], 2);
27-
$numberType = TypeCombinator::union(new IntegerType(), new FloatType());
28+
$numberType = TypeUtils::toBenevolentUnion(TypeCombinator::union(new IntegerType(), new FloatType()));
2829

2930
if (count($functionCall->args) < 1) {
3031
return $arrayType;

tests/PHPStan/Analyser/NodeScopeResolverTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9523,7 +9523,7 @@ public function dataPhp73Functions(): array
95239523
'$hrtime2',
95249524
],
95259525
[
9526-
'float|int',
9526+
'(float|int)',
95279527
'$hrtime3',
95289528
],
95299529
[

0 commit comments

Comments
 (0)