From 817d1cf3fe9f3e3141bcb7f0a5734d2714ecdf78 Mon Sep 17 00:00:00 2001 From: Matt Brown Date: Tue, 16 Mar 2021 13:40:16 -0400 Subject: [PATCH] Fix #5408 - avoid nullref when parser param cannot be found --- src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php b/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php index ba8269dc4dc..d94725aaa6b 100644 --- a/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php @@ -1034,7 +1034,7 @@ private function processParams( $context->vars_in_scope['$' . $function_param->name]->by_ref = true; } - $parser_param = $this->function->getParams()[$offset]; + $parser_param = $this->function->getParams()[$offset] ?? null; if ($function_param->location) { $statements_analyzer->registerVariable( @@ -1045,7 +1045,7 @@ private function processParams( } if (!$function_param->type_location || !$function_param->location) { - if ($parser_param->default) { + if ($parser_param && $parser_param->default) { ExpressionAnalyzer::analyze($statements_analyzer, $parser_param->default, $context); } @@ -1098,7 +1098,7 @@ private function processParams( } } - if ($parser_param->default) { + if ($parser_param && $parser_param->default) { ExpressionAnalyzer::analyze($statements_analyzer, $parser_param->default, $context); $default_type = $statements_analyzer->node_data->getType($parser_param->default);