Parser.php 765 B

123456789101112131415161718192021222324
  1. <?php declare(strict_types=1);
  2. namespace PhpParser;
  3. interface Parser {
  4. /**
  5. * Parses PHP code into a node tree.
  6. *
  7. * @param string $code The source code to parse
  8. * @param ErrorHandler|null $errorHandler Error handler to use for lexer/parser errors, defaults
  9. * to ErrorHandler\Throwing.
  10. *
  11. * @return Node\Stmt[]|null Array of statements (or null non-throwing error handler is used and
  12. * the parser was unable to recover from an error).
  13. */
  14. public function parse(string $code, ?ErrorHandler $errorHandler = null): ?array;
  15. /**
  16. * Return tokens for the last parse.
  17. *
  18. * @return Token[]
  19. */
  20. public function getTokens(): array;
  21. }