class Error (View source)

Error related utilities.

Methods

static array<int,array<int,int|string|null>>
get(array<int|Lexer|Parser> $objs)

Gets the errors of a lexer and a parser.

static string[]
format(array<int,array<int,int|string|null>> $errors, string $format = '#%1$d: %2$s (near "%4$s" at position %5$d)')

Formats the specified errors.

Details

static array<int,array<int,int|string|null>> get(array<int|Lexer|Parser> $objs)

Gets the errors of a lexer and a parser.

Parameters

array<int|Lexer|Parser> $objs

objects from where the errors will be extracted

Return Value

array<int,array<int,int|string|null>>

Each element of the array represents an error. $err[0] holds the error message. $err[1] holds the error code. $err[2] holds the string that caused the issue. $err[3] holds the position of the string. (i.e. [$msg, $code, $str, $pos])

static string[] format(array<int,array<int,int|string|null>> $errors, string $format = '#%1$d: %2$s (near "%4$s" at position %5$d)')

Formats the specified errors.

Parameters

array<int,array<int,int|string|null>> $errors

the errors to be formatted

string $format

The format of an error. '$1$d' is replaced by the position of this error. '$2$s' is replaced by the error message. '$3$d' is replaced by the error code. '$4$s' is replaced by the string that caused the issue. '$5$d' is replaced by the position of the string.

Return Value

string[]