mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
don't emit InvalidReturnType when return type was inferred to never
This commit is contained in:
parent
1aad830392
commit
56c73142d6
@ -399,7 +399,7 @@ class ReturnTypeAnalyzer
|
||||
|| ($classlike_storage && $classlike_storage->final)
|
||||
);
|
||||
|
||||
if (!$inferred_return_type_parts
|
||||
if (!$inferred_return_type->isNever()
|
||||
&& !$inferred_yield_types
|
||||
&& (!$function_like_storage || !$function_like_storage->has_yield)
|
||||
) {
|
||||
|
@ -967,6 +967,17 @@ class ReturnTypeTest extends TestCase
|
||||
exit(1);
|
||||
});'
|
||||
],
|
||||
'ExitInBothBranches' => [
|
||||
'<?php
|
||||
function never_returns(int $a) : bool
|
||||
{
|
||||
if ($a == 1) {
|
||||
throw new \Exception("one");
|
||||
} else {
|
||||
exit(0);
|
||||
}
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user