Parser
    
            
            in package
            
        
    
    
    
Parser parses YAML strings to convert them to PHP arrays.
Tags
Table of Contents
Constants
- BLOCK_SCALAR_HEADER_PATTERN = '(?P<separator>\||>)(?P<modifiers>\+|\-|\d+|\+\d+|\-\d+|\d+\+|\d+\-)?(?P<comments> +#.*)?'
 - REFERENCE_PATTERN = '#^&(?P<ref>[^ ]++) *+(?P<value>.*)#u'
 - TAG_PATTERN = '(?P<tag>![\w!.\/:-]+)'
 
Properties
- $currentLine : mixed
 - $currentLineNb : mixed
 - $filename : mixed
 - $lines : mixed
 - $locallySkippedLineNumbers : mixed
 - $numberOfParsedLines : mixed
 - $offset : mixed
 - $refs : mixed
 - $refsBeingParsed : mixed
 - $skippedLineNumbers : mixed
 - $totalNumberOfLines : mixed
 
Methods
- parse() : mixed
 - Parses a YAML string to a PHP value.
 - parseFile() : mixed
 - Parses a YAML file into a PHP value.
 - cleanup() : string
 - Cleanups a YAML string to be parsed.
 - consumeWhitespaces() : bool
 - doParse() : mixed
 - getCurrentLineIndentation() : int
 - Returns the current line indentation.
 - getLineTag() : string|null
 - getNextEmbedBlock() : string
 - Returns the next embed block of YAML.
 - hasMoreLines() : bool
 - isCurrentLineBlank() : bool
 - Returns true if the current line is blank.
 - isCurrentLineComment() : bool
 - Returns true if the current line is a comment line.
 - isCurrentLineEmpty() : bool
 - Returns true if the current line is blank or if it is a comment line.
 - isCurrentLineLastLineInDocument() : bool
 - isNextLineIndented() : bool
 - Returns true if the next line is indented.
 - isNextLineUnIndentedCollection() : bool
 - Returns true if the next line starts unindented collection.
 - isStringUnIndentedCollectionItem() : bool
 - Returns true if the string is un-indented collection item.
 - lexInlineMapping() : string
 - lexInlineQuotedString() : string
 - lexInlineSequence() : string
 - lexInlineStructure() : string
 - lexUnquotedString() : string
 - moveToNextLine() : bool
 - Moves the parser to the next line.
 - moveToPreviousLine() : bool
 - Moves the parser to the previous line.
 - parseBlock() : mixed
 - parseBlockScalar() : string
 - Parses a block scalar.
 - parseValue() : mixed
 - Parses a YAML value.
 - trimTag() : string
 - Trim the tag on top of the value.
 
Constants
BLOCK_SCALAR_HEADER_PATTERN
    public
        mixed
    BLOCK_SCALAR_HEADER_PATTERN
    = '(?P<separator>\||>)(?P<modifiers>\+|\-|\d+|\+\d+|\-\d+|\d+\+|\d+\-)?(?P<comments> +#.*)?'
    
    
    
    
REFERENCE_PATTERN
    public
        mixed
    REFERENCE_PATTERN
    = '#^&(?P<ref>[^ ]++) *+(?P<value>.*)#u'
    
    
    
    
TAG_PATTERN
    public
        mixed
    TAG_PATTERN
    = '(?P<tag>![\w!.\/:-]+)'
    
    
    
    
Properties
$currentLine
    private
        mixed
    $currentLine
     = ''
    
    
    
    
$currentLineNb
    private
        mixed
    $currentLineNb
     = -1
    
    
    
    
$filename
    private
        mixed
    $filename
    
    
    
    
    
$lines
    private
        mixed
    $lines
     = []
    
    
    
    
$locallySkippedLineNumbers
    private
        mixed
    $locallySkippedLineNumbers
     = []
    
    
    
    
$numberOfParsedLines
    private
        mixed
    $numberOfParsedLines
     = 0
    
    
    
    
$offset
    private
        mixed
    $offset
     = 0
    
    
    
    
$refs
    private
        mixed
    $refs
     = []
    
    
    
    
$refsBeingParsed
    private
        mixed
    $refsBeingParsed
     = []
    
    
    
    
$skippedLineNumbers
    private
        mixed
    $skippedLineNumbers
     = []
    
    
    
    
$totalNumberOfLines
    private
        mixed
    $totalNumberOfLines
    
    
    
    
    
Methods
parse()
Parses a YAML string to a PHP value.
    public
                    parse(string $value[, int $flags = 0 ]) : mixed
    Parameters
- $value : string
 - 
                    
A YAML string
 - $flags : int = 0
 - 
                    
A bit field of PARSE_* constants to customize the YAML parser behavior
 
Tags
Return values
mixed —A PHP value
parseFile()
Parses a YAML file into a PHP value.
    public
                    parseFile(string $filename[, int $flags = 0 ]) : mixed
    Parameters
- $filename : string
 - 
                    
The path to the YAML file to be parsed
 - $flags : int = 0
 - 
                    
A bit field of PARSE_* constants to customize the YAML parser behavior
 
Tags
Return values
mixed —The YAML converted to a PHP value
cleanup()
Cleanups a YAML string to be parsed.
    private
                    cleanup(string $value) : string
    Parameters
- $value : string
 - 
                    
The input YAML string
 
Return values
string —A cleaned up YAML string
consumeWhitespaces()
    private
                    consumeWhitespaces(int &$cursor) : bool
    Parameters
- $cursor : int
 
Return values
booldoParse()
    private
                    doParse(string $value, int $flags) : mixed
    Parameters
- $value : string
 - $flags : int
 
getCurrentLineIndentation()
Returns the current line indentation.
    private
                    getCurrentLineIndentation() : int
    Return values
int —The current line indentation
getLineTag()
    private
                    getLineTag(string $value, int $flags[, bool $nextLineCheck = true ]) : string|null
    Parameters
- $value : string
 - $flags : int
 - $nextLineCheck : bool = true
 
Return values
string|nullgetNextEmbedBlock()
Returns the next embed block of YAML.
    private
                    getNextEmbedBlock([int|null $indentation = null ][, bool $inSequence = false ]) : string
    Parameters
- $indentation : int|null = null
 - 
                    
The indent level at which the block is to be read, or null for default
 - $inSequence : bool = false
 - 
                    
True if the enclosing data structure is a sequence
 
Tags
Return values
string —A YAML string
hasMoreLines()
    private
                    hasMoreLines() : bool
    Return values
boolisCurrentLineBlank()
Returns true if the current line is blank.
    private
                    isCurrentLineBlank() : bool
    Return values
bool —Returns true if the current line is blank, false otherwise
isCurrentLineComment()
Returns true if the current line is a comment line.
    private
                    isCurrentLineComment() : bool
    Return values
bool —Returns true if the current line is a comment line, false otherwise
isCurrentLineEmpty()
Returns true if the current line is blank or if it is a comment line.
    private
                    isCurrentLineEmpty() : bool
    Return values
bool —Returns true if the current line is empty or if it is a comment line, false otherwise
isCurrentLineLastLineInDocument()
    private
                    isCurrentLineLastLineInDocument() : bool
    Return values
boolisNextLineIndented()
Returns true if the next line is indented.
    private
                    isNextLineIndented() : bool
    Return values
bool —Returns true if the next line is indented, false otherwise
isNextLineUnIndentedCollection()
Returns true if the next line starts unindented collection.
    private
                    isNextLineUnIndentedCollection() : bool
    Return values
bool —Returns true if the next line starts unindented collection, false otherwise
isStringUnIndentedCollectionItem()
Returns true if the string is un-indented collection item.
    private
                    isStringUnIndentedCollectionItem() : bool
    Return values
bool —Returns true if the string is un-indented collection item, false otherwise
lexInlineMapping()
    private
                    lexInlineMapping([int &$cursor = 0 ]) : string
    Parameters
- $cursor : int = 0
 
Return values
stringlexInlineQuotedString()
    private
                    lexInlineQuotedString([int &$cursor = 0 ]) : string
    Parameters
- $cursor : int = 0
 
Return values
stringlexInlineSequence()
    private
                    lexInlineSequence([int &$cursor = 0 ]) : string
    Parameters
- $cursor : int = 0
 
Return values
stringlexInlineStructure()
    private
                    lexInlineStructure(int &$cursor, string $closingTag) : string
    Parameters
- $cursor : int
 - $closingTag : string
 
Return values
stringlexUnquotedString()
    private
                    lexUnquotedString(int &$cursor) : string
    Parameters
- $cursor : int
 
Return values
stringmoveToNextLine()
Moves the parser to the next line.
    private
                    moveToNextLine() : bool
    Return values
boolmoveToPreviousLine()
Moves the parser to the previous line.
    private
                    moveToPreviousLine() : bool
    Return values
boolparseBlock()
    private
                    parseBlock(int $offset, string $yaml, int $flags) : mixed
    Parameters
- $offset : int
 - $yaml : string
 - $flags : int
 
parseBlockScalar()
Parses a block scalar.
    private
                    parseBlockScalar(string $style[, string $chomping = '' ][, int $indentation = 0 ]) : string
    Parameters
- $style : string
 - 
                    
The style indicator that was used to begin this block scalar (| or >)
 - $chomping : string = ''
 - 
                    
The chomping indicator that was used to begin this block scalar (+ or -)
 - $indentation : int = 0
 - 
                    
The indentation indicator that was used to begin this block scalar
 
Return values
stringparseValue()
Parses a YAML value.
    private
                    parseValue(string $value, int $flags, string $context) : mixed
    Parameters
- $value : string
 - 
                    
A YAML value
 - $flags : int
 - 
                    
A bit field of PARSE_* constants to customize the YAML parser behavior
 - $context : string
 - 
                    
The parser context (either sequence or mapping)
 
Tags
Return values
mixed —A PHP value
trimTag()
Trim the tag on top of the value.
    private
                    trimTag(string $value) : string
    Prevent values such as "!foo {quz: bar}" to be considered as a mapping block.
Parameters
- $value : string