public function parseFile($path)
    {
        $factory = new ParserFactory();
        $parser  = $factory->create(ParserFactory::PREFER_PHP7);

        try {
            $statements = $parser->parse($this->loadFile($path));
        } catch (Error $e) {
            throw new \RuntimeException(sprintf('Failed to parse %s file due to parse error: %s', $path, $e->getMessage()), 0, $e);
        }
        if ($statements === null) {
            throw new \RuntimeException(sprintf('Failed to parse %s', $path));
        }

        return $statements;
    }
public function parseFile($path)
    {
        $factory = new ParserFactory();
        $parser  = $factory->create(ParserFactory::PREFER_PHP7);

        try {
            $statements = $parser->parse($this->loadFile($path));
        } catch (Error $e) {
            throw new \RuntimeException(sprintf('Failed to parse %s file due to parse error: %s', $path, $e->getMessage()), 0, $e);
        }
        if ($statements === null) {
            throw new \RuntimeException(sprintf('Failed to parse %s', $path));
        }

        return $statements;
    }
public function parseFile ( $ path ) { $ factory = new ParserFactory ( ) ; $ parser = $ factory -> create ( ParserFactory :: PREFER_PHP7 ) ; try { $ statements = $ parser -> parse ( $ this -> loadFile ( $ path ) ) ; } catch ( Error $ e ) { throw new \ RuntimeException ( sprintf ( 'Failed to parse %s file due to parse error: %s' , $ path , $ e -> getMessage ( ) ) , 0 , $ e ) ; } if ( $ statements === null ) { throw new \ RuntimeException ( sprintf ( 'Failed to parse %s' , $ path ) ) ; } return $ statements ; }
Parse a PHP file.

@param string $path File path

@throws \Exception

@return \PhpParser\Node[]
Parse a PHP file .