Upgrade PhpParser to 2.1 and update findDeprecated.php
authorTim Starling <tstarling@wikimedia.org>
Mon, 15 Aug 2016 06:00:27 +0000 (16:00 +1000)
committerLegoktm <legoktm.wikipedia@gmail.com>
Mon, 15 Aug 2016 23:10:42 +0000 (23:10 +0000)
The old PhpParser had dynamic class_alias() calls in its autoloader
which caused HHVM RepoAuthoritative compilation to fail with a fatal
error. These b/c aliases were removed in 2.0.

Change-Id: I6e2e3412204249a50a5806c33f48f426ab8c4511

composer.json
maintenance/findDeprecated.php

index 9bd0fa1..90f7063 100644 (file)
@@ -48,7 +48,7 @@
                "justinrainbow/json-schema": "~1.6",
                "mediawiki/mediawiki-codesniffer": "0.7.2",
                "monolog/monolog": "~1.18.2",
-               "nikic/php-parser": "1.4.1",
+               "nikic/php-parser": "2.1.0",
                "nmred/kafka-php": "0.1.5",
                "phpunit/phpunit": "4.8.24",
                "wikimedia/avro": "1.7.7"
index bc1b34a..94b7fb4 100644 (file)
@@ -71,6 +71,9 @@ class DeprecatedInterfaceFinder extends FileAwareNodeVisitor {
         * indicating that it is a hard-deprecated interface.
         */
        public function isHardDeprecated( PhpParser\Node $node ) {
+               if ( !$node->stmts ) {
+                       return false;
+               }
                foreach ( $node->stmts as $stmt ) {
                        if (
                                $stmt instanceof PhpParser\Node\Expr\FuncCall
@@ -142,7 +145,7 @@ class FindDeprecated extends Maintenance {
                $files = $this->getFiles();
                $chunkSize = ceil( count( $files ) / 72 );
 
-               $parser = new PhpParser\Parser( new PhpParser\Lexer\Emulative );
+               $parser = ( new PhpParser\ParserFactory )->create( PhpParser\ParserFactory::PREFER_PHP7 );
                $traverser = new PhpParser\NodeTraverser;
                $finder = new DeprecatedInterfaceFinder;
                $traverser->addVisitor( $finder );