Skip to content

Commit 25693a0

Browse files
committed
Fixed function name scanning #1
1 parent a95e51a commit 25693a0

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/PhpNodeVisitor.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use PhpParser\Comment;
77
use PhpParser\Node;
88
use PhpParser\Node\Expr\FuncCall;
9+
use PhpParser\Node\Name;
910
use PhpParser\NodeVisitor;
1011

1112
class PhpNodeVisitor implements NodeVisitor
@@ -28,9 +29,9 @@ public function beforeTraverse(array $nodes)
2829
public function enterNode(Node $node)
2930
{
3031
if ($node instanceof FuncCall) {
31-
$name = $node->name->getLast();
32+
$name = ($node->name instanceof Name) ? $node->name->getLast() : null;
3233

33-
if ($this->validFunctions === null || in_array($name, $this->validFunctions)) {
34+
if ($name && ($this->validFunctions === null || in_array($name, $this->validFunctions))) {
3435
$this->functions[] = $this->createFunction($node);
3536
}
3637

0 commit comments

Comments
 (0)