Skip to content
Permalink
Browse files

Fix #2493 - don’t crash when provided function doesn’t exist

  • Loading branch information
muglug committed Dec 21, 2019
1 parent 7e8268f commit 946b4f73e623ecba4905066d8e7fca639d1a5ed3
Showing with 16 additions and 11 deletions.
  1. +16 −11 src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php
@@ -42,6 +42,7 @@
use function extension_loaded;
use function strpos;
use Psalm\Internal\Type\TemplateResult;
use Psalm\Storage\FunctionLikeParameter;

/**
* @internal
@@ -368,20 +369,24 @@ public static function analyze(

if ($function_params === null) {
if (!$in_call_map || $is_stubbed) {
$function_storage = $codebase_functions->getStorage(
$statements_analyzer,
strtolower($function_id)
);
try {
$function_storage = $codebase_functions->getStorage(
$statements_analyzer,
strtolower($function_id)
);

$function_params = $function_storage->params;
$function_params = $function_storage->params;

if (!$is_predefined) {
$defined_constants = $function_storage->defined_constants;
$global_variables = $function_storage->global_variables;
if (!$is_predefined) {
$defined_constants = $function_storage->defined_constants;
$global_variables = $function_storage->global_variables;
}
} catch (\UnexpectedValueException $e) {
$function_params = [
new FunctionLikeParameter('args', false, null, null, null, false, false, true)
];
}
}

if ($in_call_map && !$is_stubbed) {
} else {
$function_callable = \Psalm\Internal\Codebase\CallMap::getCallableFromCallMapById(
$codebase,
$function_id,

0 comments on commit 946b4f7

Please sign in to comment.
You can’t perform that action at this time.