Skip to content

Commit

Permalink
Fix #5408 - avoid nullref when parser param cannot be found
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Mar 16, 2021
1 parent dd4d970 commit 817d1cf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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);
}

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 817d1cf

Please sign in to comment.