Multiple
in package
implements
Parser
Interfaces, Classes, Traits and Enums
Table of Contents
- $parsers : array<string|int, Parser>
- __construct() : mixed
- Create a parser which will try multiple parsers in an order of preference.
- parse() : array<string|int, Stmt>|null
- Parses PHP code into a node tree.
- tryParse() : mixed
Properties
$parsers
private
array<string|int, Parser>
$parsers
List of parsers to try, in order of preference
Methods
__construct()
Create a parser which will try multiple parsers in an order of preference.
public
__construct(array<string|int, Parser> $parsers) : mixed
Parsers will be invoked in the order they're provided to the constructor. If one of the parsers runs without throwing, it's output is returned. Otherwise the exception that the first parser generated is thrown.
Parameters
- $parsers : array<string|int, Parser>
Return values
mixed —parse()
Parses PHP code into a node tree.
public
parse(string $code[, ErrorHandler $errorHandler = null ]) : array<string|int, Stmt>|null
Parameters
- $code : string
-
The source code to parse
- $errorHandler : ErrorHandler = null
-
Error handler to use for lexer/parser errors, defaults to ErrorHandler\Throwing.
Return values
array<string|int, Stmt>|null —Array of statements (or null non-throwing error handler is used and the parser was unable to recover from an error).
tryParse()
private
tryParse(Parser $parser, ErrorHandler $errorHandler, mixed $code) : mixed
Parameters
- $parser : Parser
- $errorHandler : ErrorHandler
- $code : mixed