Skip to content

Commit

Permalink
Fixed function name scanning #1
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Nov 11, 2019
1 parent a95e51a commit 25693a0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/PhpNodeVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}

Expand Down

0 comments on commit 25693a0

Please sign in to comment.