class sfYamlParser (View source)

sfYamlParser parses YAML strings to convert them to PHP arrays.

Properties

protected $offset
protected $lines
protected $currentLineNb
protected $currentLine
protected $refs

Methods

__construct(integer $offset = 0)

Constructor

mixed
parse(string $value)

Parses a YAML string to a PHP value.

integer
getRealCurrentLineNb()

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

integer
getCurrentLineIndentation()

Returns the current line indentation.

string
getNextEmbedBlock(integer $indentation = null)

Returns the next embed block of YAML.

moveToNextLine()

Moves the parser to the next line.

moveToPreviousLine()

Moves the parser to the previous line.

mixed
parseValue(string $value)

Parses a YAML value.

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

Parses a folded scalar.

Boolean
isNextLineIndented()

Returns true if the next line is indented.

Boolean
isCurrentLineEmpty()

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

Boolean
isCurrentLineBlank()

Returns true if the current line is blank.

Boolean
isCurrentLineComment()

Returns true if the current line is a comment line.

string
cleanup(string $value)

Cleanups a YAML string to be parsed.

Details

__construct(integer $offset = 0)

Constructor

Parameters

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

mixed parse(string $value)

Parses a YAML string to a PHP value.

Parameters

string $value A YAML string

Return Value

mixed A PHP value

Exceptions

InvalidArgumentException If the YAML is not valid

protected integer getRealCurrentLineNb()

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

Return Value

integer The current line number

protected integer getCurrentLineIndentation()

Returns the current line indentation.

Return Value

integer The current line indentation

protected string getNextEmbedBlock(integer $indentation = null)

Returns the next embed block of YAML.

Parameters

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

Return Value

string A YAML string

protected moveToNextLine()

Moves the parser to the next line.

protected moveToPreviousLine()

Moves the parser to the previous line.

protected mixed parseValue(string $value)

Parses a YAML value.

Parameters

string $value A YAML value

Return Value

mixed A PHP value

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

Parses a folded scalar.

Parameters

string $separator The separator that was used to begin this folded scalar (| or >)
string $indicator The indicator that was used to begin this folded scalar (+ or -)
integer $indentation The indentation that was used to begin this folded scalar

Return Value

string The text value

protected Boolean isNextLineIndented()

Returns true if the next line is indented.

Return Value

Boolean Returns true if the next line is indented, false otherwise

protected Boolean isCurrentLineEmpty()

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

Return Value

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

protected Boolean isCurrentLineBlank()

Returns true if the current line is blank.

Return Value

Boolean Returns true if the current line is blank, false otherwise

protected Boolean isCurrentLineComment()

Returns true if the current line is a comment line.

Return Value

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

protected string cleanup(string $value)

Cleanups a YAML string to be parsed.

Parameters

string $value The input YAML string

Return Value

string A cleaned up YAML string