diff --git a/lib/PhpParser/NodeFinder.php b/lib/PhpParser/NodeFinder.php index e5aa1165..96c84526 100644 --- a/lib/PhpParser/NodeFinder.php +++ b/lib/PhpParser/NodeFinder.php @@ -15,6 +15,10 @@ class NodeFinder { * @return Node[] Found nodes satisfying the filter callback */ public function find($nodes, callable $filter): array { + if ($nodes === []) { + return []; + } + if (!is_array($nodes)) { $nodes = [$nodes]; } @@ -52,6 +56,10 @@ class NodeFinder { * @return null|Node Found node (or null if none found) */ public function findFirst($nodes, callable $filter): ?Node { + if ($nodes === []) { + return null; + } + if (!is_array($nodes)) { $nodes = [$nodes]; }