diff --git a/bin/php-parse.php b/bin/php-parse.php index 6041a27..aa74eed 100644 --- a/bin/php-parse.php +++ b/bin/php-parse.php @@ -29,13 +29,18 @@ $traverser = new PhpParser\NodeTraverser(); $traverser->addVisitor(new PhpParser\NodeVisitor\NameResolver); foreach ($files as $file) { - if (!file_exists($file)) { - die("File $file does not exist.\n"); + 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"; } - echo "====> File $file:\n"; - - $code = file_get_contents($file); try { $stmts = $parser->parse($code); } catch (PhpParser\Error $e) { @@ -69,6 +74,10 @@ Usage: php php-parse.php [operations] file1.php [file2.php ...] +The file arguments can also be replaced with a code string: + + php php-parse.php [operations] "