1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00

Fix #5408 - avoid nullref when parser param cannot be found

This commit is contained in:
Matt Brown 2021-03-16 13:40:16 -04:00
parent dd4d970a37
commit 817d1cf3fe

View File

@ -1034,7 +1034,7 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer
$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 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer
}
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 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer
}
}
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);