$parsers
$parsers : array<mixed,\PhpParser\Parser>
$parsers : array<mixed,\PhpParser\Parser>
__construct(array<mixed,\PhpParser\Parser> $parsers)
Create a parser which will try multiple parsers in an order of preference.
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.
array<mixed,\PhpParser\Parser> | $parsers |
parse(string $code, \PhpParser\ErrorHandler $errorHandler = null) : array<mixed,\PhpParser\Node>|null
Parses PHP code into a node tree.
string | $code | The source code to parse |
\PhpParser\ErrorHandler | $errorHandler | Error handler to use for lexer/parser errors, defaults to ErrorHandler\Throwing. |
Array of statements (or null if the 'throwOnError' option is disabled and the parser was unable to recover from an error).
tryParse(\PhpParser\Parser $parser, \PhpParser\ErrorHandler $errorHandler, $code)
\PhpParser\Parser | $parser | |
\PhpParser\ErrorHandler | $errorHandler | |
$code |