From d1af3419d63ab7fa5236811fa1986fa8445a8afc Mon Sep 17 00:00:00 2001 From: kkmuffme <11071985+kkmuffme@users.noreply.github.com> Date: Wed, 23 Feb 2022 17:16:46 +0100 Subject: [PATCH] fix notices and generator failing on dynamic functions Fix for: $my_function = 'foo_bar'; $my_function(); --- src/NodeVisitor.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/NodeVisitor.php b/src/NodeVisitor.php index f6a672c..2b2ebfc 100644 --- a/src/NodeVisitor.php +++ b/src/NodeVisitor.php @@ -166,6 +166,7 @@ public function enterNode(Node $node) } elseif ( $node instanceof Expression && $node->expr instanceof FuncCall && + $node->expr->name instanceof Name && $node->expr->name->parts[0] === 'define' ) { $this->isInDeclaration = true; @@ -200,6 +201,7 @@ public function leaveNode(Node $node, bool $preserveStack = false) || ( $node instanceof Expression && $node->expr instanceof FuncCall && + $node->expr->name instanceof Name && $node->expr->name->parts[0] === 'define' ) ) { @@ -373,6 +375,7 @@ function (\PhpParser\Node\Const_ $const) { if ( $node instanceof Expression && $node->expr instanceof FuncCall && + $node->expr->name instanceof Name && $node->expr->name->parts[0] === 'define' ) { $fullyQualifiedName = $node->expr->args[0]->value->value;