diff --git a/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php b/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php index 5b857dfcd..0ea79a46d 100644 --- a/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php @@ -479,7 +479,16 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer } } - $this->examineParamTypes($statements_analyzer, $context, $codebase); + $final_actions = ScopeAnalyzer::getControlActions( + $this->function->getStmts() ?: [], + null, + $codebase->config->exit_functions, + $context->break_types + ); + + if ($final_actions !== [ScopeAnalyzer::ACTION_END]) { + $this->examineParamTypes($statements_analyzer, $context, $codebase); + } foreach ($params as $function_param) { // only complain if there's no type defined by a parent type diff --git a/tests/ReferenceConstraintTest.php b/tests/ReferenceConstraintTest.php index 73f7eb9c0..cee9ed549 100644 --- a/tests/ReferenceConstraintTest.php +++ b/tests/ReferenceConstraintTest.php @@ -157,6 +157,19 @@ class ReferenceConstraintTest extends TestCase addValue($foo["a"]);' ], + 'paramOutArrayDefaultNullWithThrow' => [ + '