1
0
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:
orklah 2021-10-16 00:15:17 +02:00
parent 1aad830392
commit 56c73142d6
2 changed files with 12 additions and 1 deletions

View File

@ -399,7 +399,7 @@ class ReturnTypeAnalyzer
|| ($classlike_storage && $classlike_storage->final) || ($classlike_storage && $classlike_storage->final)
); );
if (!$inferred_return_type_parts if (!$inferred_return_type->isNever()
&& !$inferred_yield_types && !$inferred_yield_types
&& (!$function_like_storage || !$function_like_storage->has_yield) && (!$function_like_storage || !$function_like_storage->has_yield)
) { ) {

View File

@ -967,6 +967,17 @@ class ReturnTypeTest extends TestCase
exit(1); exit(1);
});' });'
], ],
'ExitInBothBranches' => [
'<?php
function never_returns(int $a) : bool
{
if ($a == 1) {
throw new \Exception("one");
} else {
exit(0);
}
}'
],
]; ];
} }