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

Fix #3313 - add check for very specific pattern

This commit is contained in:
Brown 2020-05-07 12:30:15 -04:00
parent 18ee440e3f
commit 4295f9525f

View File

@ -1973,11 +1973,25 @@ class ReflectorVisitor extends PhpParser\NodeVisitorAbstract implements PhpParse
foreach ($stmt->stmts as $function_stmt) {
if ($function_stmt instanceof PhpParser\Node\Stmt\Expression
&& $function_stmt->expr instanceof PhpParser\Node\Expr\Assign
&& ($function_stmt->expr->expr instanceof PhpParser\Node\Expr\FuncCall)
&& ($function_stmt->expr->expr->name instanceof PhpParser\Node\Name)
&& $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);
if ($function_id === 'func_get_arg'
|| $function_id === 'func_get_args'
|| $function_id === 'func_num_args'
) {
$storage->variadic = true;
}
} elseif ($function_stmt instanceof PhpParser\Node\Stmt\If_
&& $function_stmt->cond instanceof PhpParser\Node\Expr\BinaryOp
&& $function_stmt->cond->left instanceof PhpParser\Node\Expr\BinaryOp\Equal
&& $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);
if ($function_id === 'func_get_arg'
|| $function_id === 'func_get_args'
|| $function_id === 'func_num_args'