From 25693a0bd1e83969de6c3a440fb9f2cfac63a2fd Mon Sep 17 00:00:00 2001 From: Oscar Otero Date: Mon, 11 Nov 2019 15:08:47 +0100 Subject: [PATCH] Fixed function name scanning #1 --- src/PhpNodeVisitor.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/PhpNodeVisitor.php b/src/PhpNodeVisitor.php index 3019d13..19e15f1 100644 --- a/src/PhpNodeVisitor.php +++ b/src/PhpNodeVisitor.php @@ -6,6 +6,7 @@ use PhpParser\Comment; use PhpParser\Node; use PhpParser\Node\Expr\FuncCall; +use PhpParser\Node\Name; use PhpParser\NodeVisitor; class PhpNodeVisitor implements NodeVisitor @@ -28,9 +29,9 @@ public function beforeTraverse(array $nodes) public function enterNode(Node $node) { if ($node instanceof FuncCall) { - $name = $node->name->getLast(); + $name = ($node->name instanceof Name) ? $node->name->getLast() : null; - if ($this->validFunctions === null || in_array($name, $this->validFunctions)) { + if ($name && ($this->validFunctions === null || in_array($name, $this->validFunctions))) { $this->functions[] = $this->createFunction($node); }