addVisitor(new PhpParser\NodeVisitor\NameResolver); foreach ($files as $file) { if (strpos($file, ' Code $code\n"; } else { if (!file_exists($file)) { die("File $file does not exist.\n"); } $code = file_get_contents($file); echo "====> File $file:\n"; } try { $stmts = $parser->parse($code); } catch (PhpParser\Error $e) { die("==> Parse Error: {$e->getMessage()}\n"); } foreach ($operations as $operation) { if ('dump' === $operation) { echo "==> Node dump:\n"; echo $dumper->dump($stmts), "\n"; } elseif ('pretty-print' === $operation) { echo "==> Pretty print:\n"; echo $prettyPrinter->prettyPrintFile($stmts), "\n"; } elseif ('serialize-xml' === $operation) { echo "==> Serialized XML:\n"; echo $serializer->serialize($stmts), "\n"; } elseif ('var-dump' === $operation) { echo "==> var_dump():\n"; var_dump($stmts); } elseif ('resolve-names' === $operation) { echo "==> Resolved names.\n"; $stmts = $traverser->traverse($stmts); } } } function showHelp($error) { die($error . "\n\n" . <<