@@ -113,7 +113,10 @@ public function __construct($debug, OutputInterface $output, $basedir, $namespac
113113 parent ::__construct ($ debug , $ output , $ basedir , $ namespace , $ titania , $ opendir );
114114
115115 $ this ->fileTypeFull = Type::TYPE_PHP ;
116- $ this ->parser = (new ParserFactory )->create (ParserFactory::PREFER_PHP7 );
116+ $ factory = new ParserFactory ();
117+ $ this ->parser = method_exists ($ factory , 'createForNewestSupportedVersion ' )
118+ ? $ factory ->createForNewestSupportedVersion ()
119+ : $ factory ->create (ParserFactory::PREFER_PHP7 );
117120 }
118121
119122 /**
@@ -335,7 +338,7 @@ private function checkInDefined(If_ $node)
335338
336339 if ($ cond instanceof BooleanNot
337340 && $ cond ->expr instanceof FuncCall
338- && $ cond ->expr ->name -> getFirst () === 'defined '
341+ && ( method_exists ( $ cond ->expr ->name , ' getFirst ' ) ? $ cond -> expr -> name -> getFirst () : $ cond -> expr -> name -> toString () ) === 'defined '
339342 && $ cond ->expr ->args [0 ]->value ->value === 'IN_PHPBB '
340343 )
341344 {
@@ -375,7 +378,7 @@ private function validateFunctionNames(Node $node)
375378 }
376379 else if (isset ($ node ->expr ) && $ node ->expr instanceof FuncCall && $ node ->expr ->name instanceof Name)
377380 {
378- $ name = $ node ->expr ->name -> getFirst ();
381+ $ name = method_exists ( $ node ->expr ->name , ' getFirst ' ) ? $ node -> expr -> name -> getFirst () : $ node -> expr -> name -> toString ();
379382 }
380383
381384 if ($ name !== null )
@@ -475,7 +478,7 @@ private function getMethodName(Node $node)
475478 }
476479 else if ($ node ->name instanceof Node \Name)
477480 {
478- return $ node ->name -> getFirst ();
481+ return method_exists ( $ node ->name , ' getFirst ' ) ? $ node -> name -> getFirst () : $ node -> name -> toString ();
479482 }
480483 else
481484 {
0 commit comments