From: Tim Starling Date: Mon, 15 Aug 2016 06:00:27 +0000 (+1000) Subject: Upgrade PhpParser to 2.1 and update findDeprecated.php X-Git-Tag: 1.31.0-rc.0~6060 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=317ad7ab99a4cc8f2f88540a3142d4e148a1fa3c Upgrade PhpParser to 2.1 and update findDeprecated.php 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 --- diff --git a/composer.json b/composer.json index 9bd0fa1f07..90f706328a 100644 --- a/composer.json +++ b/composer.json @@ -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" diff --git a/maintenance/findDeprecated.php b/maintenance/findDeprecated.php index bc1b34aa67..94b7fb4429 100644 --- a/maintenance/findDeprecated.php +++ b/maintenance/findDeprecated.php @@ -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 );