Skip to content

Commit 900ae71

Browse files
committed
Handle "never" type as non float
1 parent ff92658 commit 900ae71

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/FloatTypeHelper.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use PHPStan\Type\FloatType;
88
use PHPStan\Type\MixedType;
9+
use PHPStan\Type\NeverType;
910
use PHPStan\Type\Type;
1011

1112
/** @internal class is only for internal tooling use: do not import it in your own projects */
@@ -17,6 +18,10 @@ public static function isFloat(Type $type): bool
1718
return false;
1819
}
1920

21+
if ($type instanceof NeverType) {
22+
return false;
23+
}
24+
2025
return ! (new FloatType())->isSuperTypeOf($type)->no();
2126
}
2227
}

tests/asset/function.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,11 @@ function doBar(): string
2222
{
2323

2424
}
25+
26+
/**
27+
* @return never
28+
*/
29+
function withNever()
30+
{
31+
throw new \RuntimeException();
32+
}

tests/asset/method.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,11 @@ public function doBar(): string
2626

2727
}
2828

29+
/**
30+
* @return never
31+
*/
32+
public function withNever()
33+
{
34+
throw new \RuntimeException();
35+
}
2936
}

0 commit comments

Comments
 (0)