class Parser (View source)

Parser parses YAML strings to convert them to PHP arrays.

Constants

TAG_PATTERN

BLOCK_SCALAR_HEADER_PATTERN

Methods

__construct()

No description

mixed
parse(string $value, int $flags = 0)

Parses a YAML string to a PHP value.

static 
pregMatch($pattern, $subject, $matches = null, $flags = 0, $offset = 0)

A local wrapper for preg_match which will throw a ParseException if there is an internal error in the PCRE engine.

Details

__construct()

mixed parse(string $value, int $flags = 0)

Parses a YAML string to a PHP value.

Parameters

string $value A YAML string
int $flags A bit field of PARSE_* constants to customize the YAML parser behavior

Return Value

mixed A PHP value

Exceptions

ParseException If the YAML is not valid

static pregMatch($pattern, $subject, $matches = null, $flags = 0, $offset = 0)

A local wrapper for preg_match which will throw a ParseException if there is an internal error in the PCRE engine.

This avoids us needing to check for "false" every time PCRE is used in the YAML engine

DRUSH FORK: Renamed from preg_match to pregMatch. Not what I would have preferred, but easier / cleaner than customizing phpcs to not flag this one warning.

Parameters

$pattern
$subject
$matches
$flags
$offset

Exceptions

ParseException on a PCRE internal error

See also

preg_last_error()