private $currentClass = null;
- private $foundNodes = array();
+ private $foundNodes = [];
public function getFoundNodes() {
// Sort results by version, then by filename, then by name.
* 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
$name = $node->name;
}
- $this->foundNodes[ $version ][] = array(
+ $this->foundNodes[ $version ][] = [
'filename' => $node->filename,
'line' => $node->getLine(),
'name' => $name,
'hard' => $this->isHardDeprecated( $node ),
- );
+ ];
}
return $retVal;
$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 );
}
$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 ) {