diff vendor/nikic/php-parser/bin/php-parse @ 13:5fb285c0d0e3

Update Drupal core to 8.4.7 via Composer. Security update; I *think* we've been lucky to get away with this so far, as we don't support self-registration which seems to be used by the so-called "drupalgeddon 2" attack that 8.4.5 was vulnerable to.
author Chris Cannam
date Mon, 23 Apr 2018 09:33:26 +0100
parents 4c8ae668cc8c
children
line wrap: on
line diff
--- a/vendor/nikic/php-parser/bin/php-parse	Fri Feb 23 15:52:07 2018 +0000
+++ b/vendor/nikic/php-parser/bin/php-parse	Mon Apr 23 09:33:26 2018 +0100
@@ -26,9 +26,9 @@
     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 @@
     '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 @@
         } 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 @@
 
     -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 @@
 }
 
 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 @@
             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 @@
         }
     }
 
-    return array($operations, $files, $attributes);
+    return [$operations, $files, $attributes];
 }