X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=vendor%2Fnikic%2Fphp-parser%2Fbin%2Fphp-parse;h=5dd01ba17972c9564ee7c518eada3b787cc2f3e0;hb=4e1bfbf98b844da83b18aca92ef00f11a4735806;hp=1760e758d5b985ed86282ce066fdc541f0d5c9a9;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/vendor/nikic/php-parser/bin/php-parse b/vendor/nikic/php-parser/bin/php-parse index 1760e758d..5dd01ba17 100755 --- a/vendor/nikic/php-parser/bin/php-parse +++ b/vendor/nikic/php-parser/bin/php-parse @@ -26,9 +26,9 @@ if (empty($files)) { showHelp("Must specify at least one file."); } -$lexer = new PhpParser\Lexer\Emulative(array('usedAttributes' => array( +$lexer = new PhpParser\Lexer\Emulative(['usedAttributes' => [ 'startLine', 'endLine', 'startFilePos', 'endFilePos', 'comments' -))); +]]); $parser = (new PhpParser\ParserFactory)->create( PhpParser\ParserFactory::PREFER_PHP7, $lexer @@ -38,7 +38,6 @@ $dumper = new PhpParser\NodeDumper([ 'dumpPositions' => $attributes['with-positions'], ]); $prettyPrinter = new PhpParser\PrettyPrinter\Standard; -$serializer = new PhpParser\Serializer\XML; $traverser = new PhpParser\NodeTraverser(); $traverser->addVisitor(new PhpParser\NodeVisitor\NameResolver); @@ -82,9 +81,9 @@ foreach ($files as $file) { } 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 ('json-dump' === $operation) { + echo "==> JSON dump:\n"; + echo json_encode($stmts, JSON_PRETTY_PRINT), "\n"; } elseif ('var-dump' === $operation) { echo "==> var_dump():\n"; var_dump($stmts); @@ -116,7 +115,7 @@ Operations is a list of the following options (--dump by default): -d, --dump Dump nodes using NodeDumper -p, --pretty-print Pretty print file using PrettyPrinter\Standard - --serialize-xml Serialize nodes using Serializer\XML + -j, --json-dump Print json_encode() result --var-dump var_dump() nodes (for exact structure) -N, --resolve-names Resolve names using NodeVisitor\NameResolver -c, --with-column-info Show column-numbers for errors (if available) @@ -135,13 +134,13 @@ OUTPUT } function parseArgs($args) { - $operations = array(); - $files = array(); - $attributes = array( + $operations = []; + $files = []; + $attributes = [ 'with-column-info' => false, 'with-positions' => false, 'with-recovery' => false, - ); + ]; array_shift($args); $parseOptions = true; @@ -160,8 +159,9 @@ function parseArgs($args) { case '-p': $operations[] = 'pretty-print'; break; - case '--serialize-xml': - $operations[] = 'serialize-xml'; + case '--json-dump': + case '-j': + $operations[] = 'json-dump'; break; case '--var-dump': $operations[] = 'var-dump'; @@ -198,5 +198,5 @@ function parseArgs($args) { } } - return array($operations, $files, $attributes); + return [$operations, $files, $attributes]; }