Documentation

Multiple
in package
implements Parser

Table of Contents

Interfaces

Parser

Properties

$parsers  : array<string|int, Parser>

Methods

__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>

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).


        
On this page

Search results