1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

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
This commit is contained in:
Jack Bentley 2020-12-06 22:28:19 +00:00 committed by GitHub
parent cd576f8e02
commit 7fe8e5a1cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;
}