X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FfindDeprecated.php;h=94b7fb4429222c1808506e1abc8c14a3542dec55;hb=d24af42ffff087a0824f6e9abefa33cab3e4e835;hp=8c7e242207cb39f3591f5e0f27faed0c1391e354;hpb=23299ca8790bcf1aebcf54e0932b94338e630474;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/findDeprecated.php b/maintenance/findDeprecated.php index 8c7e242207..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; @@ -124,7 +127,7 @@ class DeprecatedInterfaceFinder extends FileAwareNodeVisitor { class FindDeprecated extends Maintenance { public function __construct() { parent::__construct(); - $this->mDescription = 'Find deprecated interfaces'; + $this->addDescription( 'Find deprecated interfaces' ); } public function getFiles() { @@ -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 ) {