X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FfindDeprecated.php;h=94b7fb4429222c1808506e1abc8c14a3542dec55;hb=7737353a9f92b700bfbd435d997b1872ffdb144d;hp=9022292e2f3ade64a366a0c26c95d81ff1b4fa1b;hpb=f132746d2882a8383cb6288325aae048b2b996e3;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/findDeprecated.php b/maintenance/findDeprecated.php index 9022292e2f..94b7fb4429 100644 --- a/maintenance/findDeprecated.php +++ b/maintenance/findDeprecated.php @@ -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 ) {