Inheritance: extends GrumPHP\Parser\ParseError
Example #1
0
 /**
  * @param SplFileInfo $file
  *
  * @return ParseErrorsCollection
  */
 public function parse(SplFileInfo $file)
 {
     $errors = new ParseErrorsCollection();
     $context = new ParserContext($file, $errors);
     $parser = $this->parserFactory->createFromOptions($this->parserOptions);
     $traverser = $this->traverserFactory->createForTaskContext($this->parserOptions, $context);
     try {
         $code = $this->filesystem->readFromFileInfo($file);
         $stmts = $parser->parse($code);
         $traverser->traverse($stmts);
     } catch (Error $e) {
         $errors->add(PhpParserError::fromParseException($e, $file->getRealPath()));
     }
     return $errors;
 }