Merge "add IGNORE INDEX option to mysql database handler"
[lhc/web/wiklou.git] / maintenance / findDeprecated.php
index 9022292..94b7fb4 100644 (file)
@@ -53,7 +53,7 @@ class DeprecatedInterfaceFinder extends FileAwareNodeVisitor {
 
        private $currentClass = null;
 
-       private $foundNodes = array();
+       private $foundNodes = [];
 
        public function getFoundNodes() {
                // Sort results by version, then by filename, then by name.
@@ -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
@@ -105,12 +108,12 @@ class DeprecatedInterfaceFinder extends FileAwareNodeVisitor {
                                $name = $node->name;
                        }
 
-                       $this->foundNodes[ $version ][] = array(
+                       $this->foundNodes[ $version ][] = [
                                'filename' => $node->filename,
                                'line'     => $node->getLine(),
                                'name'     => $name,
                                'hard'     => $this->isHardDeprecated( $node ),
-                       );
+                       ];
                }
 
                return $retVal;
@@ -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 );
@@ -158,7 +161,7 @@ class FindDeprecated extends Maintenance {
                        }
 
                        $finder->setCurrentFile( substr( $file->getPathname(), strlen( $IP ) + 1 ) );
-                       $nodes = $parser->parse( $code, array( 'throwOnError' => false ) );
+                       $nodes = $parser->parse( $code, [ 'throwOnError' => false ] );
                        $traverser->traverse( $nodes );
 
                        if ( $i % $chunkSize === 0 ) {