phabel/test/dump.php

24 lines
517 B
PHP
Raw Normal View History

2020-08-09 15:14:32 +02:00
<?php
2020-09-05 20:52:54 +02:00
/**
* Dump AST of file.
*
* @author Daniil Gentili <daniil@daniil.it>
* @license MIT
*/
2020-08-09 15:14:32 +02:00
use PhpParser\ParserFactory;
2020-08-30 16:58:59 +02:00
use PhpParser\PrettyPrinter\Standard;
2020-08-09 15:14:32 +02:00
require 'vendor/autoload.php';
if ($argc < 2) {
echo("Usage: {$argv[0]} file.php\n");
die(1);
}
$parser = (new ParserFactory)->create(ParserFactory::PREFER_PHP7);
2020-08-30 16:58:59 +02:00
//$parser = (new ParserFactory)->create(ParserFactory::ONLY_PHP5);
2020-08-09 15:14:32 +02:00
2020-08-30 16:58:59 +02:00
\var_dump($a = $parser->parse(\file_get_contents($argv[1])));
2020-09-01 14:31:23 +02:00
\var_dumP((new Standard())->prettyPrint($a));