From 35fc84cdbb143e3a7229b06bcdee7d96109ca049 Mon Sep 17 00:00:00 2001 From: Jack Bentley Date: Sun, 6 Dec 2020 22:28:19 +0000 Subject: [PATCH] Fix functions being resolved to other functions (#4793) Fixes #4750 Reusing the $function_id variable causes an incorrect global function to be added at line 654 --- .../Reflector/FunctionLikeNodeScanner.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php b/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php index 3923e7b2a..887292f6a 100644 --- a/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php +++ b/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php @@ -524,11 +524,11 @@ class FunctionLikeNodeScanner && $function_stmt->expr->expr instanceof PhpParser\Node\Expr\FuncCall && $function_stmt->expr->expr->name instanceof PhpParser\Node\Name ) { - $function_id = implode('\\', $function_stmt->expr->expr->name->parts); + $inner_function_id = implode('\\', $function_stmt->expr->expr->name->parts); - if ($function_id === 'func_get_arg' - || $function_id === 'func_get_args' - || $function_id === 'func_num_args' + if ($inner_function_id === 'func_get_arg' + || $inner_function_id === 'func_get_args' + || $inner_function_id === 'func_num_args' ) { $storage->variadic = true; } @@ -538,11 +538,11 @@ class FunctionLikeNodeScanner && $function_stmt->cond->left->left instanceof PhpParser\Node\Expr\FuncCall && $function_stmt->cond->left->left->name instanceof PhpParser\Node\Name ) { - $function_id = implode('\\', $function_stmt->cond->left->left->name->parts); + $inner_function_id = implode('\\', $function_stmt->cond->left->left->name->parts); - if ($function_id === 'func_get_arg' - || $function_id === 'func_get_args' - || $function_id === 'func_num_args' + if ($inner_function_id === 'func_get_arg' + || $inner_function_id === 'func_get_args' + || $inner_function_id === 'func_num_args' ) { $storage->variadic = true; }