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