Parser

Parser parses YAML strings to convert them to PHP arrays.

author

Fabien Potencier

Methods

Constructor

__construct(integer $offset) 

Arguments

$offset

integer

The offset of YAML document (used for line numbers in error messages)

Parses a YAML string to a PHP value.

parse(string $value) : mixed
throws

If the YAML is not valid

Arguments

$value

string

A YAML string

Response

mixed

A PHP value

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

getRealCurrentLineNb() : integer

Response

integer

The current line number

Returns the current line indentation.

getCurrentLineIndentation() : integer

Response

integer

The current line indentation

Returns the next embed block of YAML.

getNextEmbedBlock(integer $indentation = null) : string
throws

When indentation problem are detected

Arguments

$indentation

integer

The indent level at which the block is to be read, or null for default

Response

string

A YAML string

Moves the parser to the next line.

moveToNextLine() : Boolean

Response

Boolean

Moves the parser to the previous line.

moveToPreviousLine() 

Parses a YAML value.

parseValue(string $value) : mixed
throws

When reference does not exist

Arguments

$value

string

A YAML value

Response

mixed

A PHP value

Parses a folded scalar.

parseFoldedScalar(string $separator, string $indicator = '', integer $indentation) : string

Arguments

$separator

string

The separator that was used to begin this folded scalar (| or >)

$indicator

string

The indicator that was used to begin this folded scalar (+ or -)

$indentation

integer

The indentation that was used to begin this folded scalar

Response

string

The text value

Returns true if the next line is indented.

isNextLineIndented() : Boolean

Response

Boolean

Returns true if the next line is indented, false otherwise

Returns true if the current line is blank or if it is a comment line.

isCurrentLineEmpty() : Boolean

Response

Boolean

Returns true if the current line is empty or if it is a comment line, false otherwise

Returns true if the current line is blank.

isCurrentLineBlank() : Boolean

Response

Boolean

Returns true if the current line is blank, false otherwise

Returns true if the current line is a comment line.

isCurrentLineComment() : Boolean

Response

Boolean

Returns true if the current line is a comment line, false otherwise

Cleanups a YAML string to be parsed.

cleanup(string $value) : string

Arguments

$value

string

The input YAML string

Response

string

A cleaned up YAML string

Properties

offset

offset : 

lines

lines : 

currentLineNb

currentLineNb : 

currentLine

currentLine : 

refs

refs :