1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-03 10:07:52 +01:00

fix return type never for static function calls

This commit is contained in:
kkmuffme 2022-12-16 11:52:41 +01:00
parent 5132de22e0
commit eeb0c06173
2 changed files with 3 additions and 2 deletions

View File

@ -181,7 +181,7 @@ class ReturnTypeAnalyzer
$function_always_exits = $control_actions === [ScopeAnalyzer::ACTION_END]; $function_always_exits = $control_actions === [ScopeAnalyzer::ACTION_END];
$function_returns_implicitly = (bool)array_diff( $function_returns_implicitly = (bool) array_diff(
$control_actions, $control_actions,
[ScopeAnalyzer::ACTION_END, ScopeAnalyzer::ACTION_RETURN] [ScopeAnalyzer::ACTION_END, ScopeAnalyzer::ACTION_RETURN]
); );

View File

@ -89,7 +89,8 @@ class ReturnTypeCollector
break; break;
} }
if ($stmt->expr instanceof PhpParser\Node\Expr\FuncCall) { if ($stmt->expr instanceof PhpParser\Node\Expr\FuncCall
|| $stmt->expr instanceof PhpParser\Node\Expr\StaticCall) {
$stmt_type = $nodes->getType($stmt->expr); $stmt_type = $nodes->getType($stmt->expr);
if ($stmt_type && ($stmt_type->isNever() || $stmt_type->explicit_never)) { if ($stmt_type && ($stmt_type->isNever() || $stmt_type->explicit_never)) {
$return_types[] = Type::getNever(); $return_types[] = Type::getNever();