mirror of
https://github.com/phabelio/PHP-Parser.git
synced 2024-11-26 20:14:46 +01:00
Add ability to pass code directly to php-parse.php
This commit is contained in:
parent
88e2d42ba4
commit
16dff7c2e6
@ -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, '<?php') === 0) {
|
||||
$code = $file;
|
||||
echo "====> 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] "<?php code"
|
||||
|
||||
Operations is a list of the following options (--dump by default):
|
||||
|
||||
--dump -d Dump nodes using NodeDumper
|
||||
|
Loading…
Reference in New Issue
Block a user