Parser

class Parser

Parser parses YAML strings to convert them to PHP arrays.

Constants

TAG_PATTERN
BLOCK_SCALAR_HEADER_PATTERN

Methods

__construct()
mixed parseFile(string $filename, int $flags)

Parses a YAML file into a PHP value.

mixed parse(string $value, int $flags)

Parses a YAML string to a PHP value.

int getRealCurrentLineNb()

Returns the current line number (takes the offset into account).

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

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

Details

__construct()

mixed parseFile(string $filename, int $flags)

Parses a YAML file into a PHP value.

Parameters

string $filename The path to the YAML file to be parsed
int $flags A bit field of PARSE_* constants to customize the YAML parser behavior

Return Value

mixed The YAML converted to a PHP value

Exceptions

ParseException If the file could not be read or the YAML is not valid

mixed parse(string $value, int $flags)

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

int getRealCurrentLineNb()

Returns the current line number (takes the offset into account).

Return Value

int The current line number

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

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

Parameters

$pattern
$subject
$matches
$flags
$offset

Exceptions

ParseException on a PCRE internal error

See also

preg_last_error()

© 2004–2017 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/4.0/Symfony/Component/Yaml/Parser.html