Constants

REMPTY

REMPTY = "\0\0\0\0\0"

Properties

$setting_dump_force_quotes

$setting_dump_force_quotes : boolean

Setting this to true will force YAMLDump to enclose any string value in quotes. False by default.

Type

boolean

$setting_use_syck_is_possible

$setting_use_syck_is_possible : boolean

Setting this to true will forse YAMLLoad to use syck_load function when possible. False by default.

Type

boolean

$_nodeId

$_nodeId : 

Type

$_dumpIndent

$_dumpIndent : 

Type

$_dumpWordWrap

$_dumpWordWrap : 

Type

$_containsGroupAnchor

$_containsGroupAnchor : 

Type

$_containsGroupAlias

$_containsGroupAlias : 

Type

$path

$path : 

Type

$result

$result : 

Type

$LiteralPlaceHolder

$LiteralPlaceHolder : 

Type

$SavedGroups

$SavedGroups : 

Type

$indent

$indent : 

Type

$delayedPath

$delayedPath : array

Path modifier that should be applied after adding current element.

Type

array

Methods

load()

load(string  $input) : array

Load a valid YAML string to Spyc.

Parameters

string $input

Returns

array

loadFile()

loadFile(string  $file) : array

Load a valid YAML file to Spyc.

Parameters

string $file

Returns

array

YAMLLoad()

YAMLLoad(string  $input) : array

Load YAML into a PHP array statically

The load method, when supplied with a YAML stream (string or file), will do its best to convert YAML in a file into a PHP array. Pretty simple. Usage: $array = Spyc::YAMLLoad('lucky.yaml'); print_r($array);

Parameters

string $input

Path of YAML file or string containing YAML

Returns

array

YAMLLoadString()

YAMLLoadString(string  $input) : array

Load a string of YAML into a PHP array statically

The load method, when supplied with a YAML string, will do its best to convert YAML in a string into a PHP array. Pretty simple.

Note: use this function if you don't want files from the file system loaded and processed as YAML. This is of interest to people concerned about security whose input is from a string.

Usage: $array = Spyc::YAMLLoadString("---\n0: hello world\n"); print_r($array);

Parameters

string $input

String containing YAML

Returns

array

YAMLDump()

YAMLDump(array  $array, integer  $indent = false, integer  $wordwrap = false, integer  $no_opening_dashes = false) : string

Dump YAML from PHP array statically

The dump method, when supplied with an array, will do its best to convert the array into friendly YAML. Pretty simple. Feel free to save the returned string as nothing.yaml and pass it around.

Oh, and you can decide how big the indent is and what the wordwrap for folding is. Pretty cool -- just pass in 'false' for either if you want to use the default.

Indent's default is 2 spaces, wordwrap's default is 40 characters. And you can turn off wordwrap by passing in 0.

Parameters

array $array

PHP array

integer $indent

Pass in false to use the default, which is 2

integer $wordwrap

Pass in 0 for no wordwrap, false for default (40)

integer $no_opening_dashes

Do not start YAML file with "---\n"

Returns

string

dump()

dump(array  $array, integer  $indent = false, integer  $wordwrap = false,   $no_opening_dashes = false) : string

Dump PHP array to YAML

The dump method, when supplied with an array, will do its best to convert the array into friendly YAML. Pretty simple. Feel free to save the returned string as tasteful.yaml and pass it around.

Oh, and you can decide how big the indent is and what the wordwrap for folding is. Pretty cool -- just pass in 'false' for either if you want to use the default.

Indent's default is 2 spaces, wordwrap's default is 40 characters. And you can turn off wordwrap by passing in 0.

Parameters

array $array

PHP array

integer $indent

Pass in false to use the default, which is 2

integer $wordwrap

Pass in 0 for no wordwrap, false for default (40)

$no_opening_dashes

Returns

string

revertLiteralPlaceHolder()

revertLiteralPlaceHolder(  $lineArray,   $literalBlock) 

Parameters

$lineArray
$literalBlock

_yamlize()

_yamlize(  $key,   $value,   $indent,   $previous_key = -1,   $first_key,   $source_array = null) : string

Attempts to convert a key / value array item to YAML

Parameters

$key

The name of the key

$value

The value of the item

$indent

The indent of the current node

$previous_key
$first_key
$source_array

Returns

string

_yamlizeArray()

_yamlizeArray(  $array,   $indent) : string

Attempts to convert an array to YAML

Parameters

$array

The array you want to convert

$indent

The indent of the current level

Returns

string

_dumpNode()

_dumpNode(  $key,   $value,   $indent,   $previous_key = -1,   $first_key,   $source_array = null) : string

Returns YAML from a key and a value

Parameters

$key

The name of the key

$value

The value of the item

$indent

The indent of the current node

$previous_key
$first_key
$source_array

Returns

string

_doLiteralBlock()

_doLiteralBlock(  $value,   $indent) : string

Creates a literal block for dumping

Parameters

$value
$indent

int The value of the indent

Returns

string

_doFolding()

_doFolding(  $value,   $indent) : string

Folds a string of text, if necessary

Parameters

$value

The string you wish to fold

$indent

Returns

string

isTrueWord()

isTrueWord(  $value) 

Parameters

$value

isFalseWord()

isFalseWord(  $value) 

Parameters

$value

isNullWord()

isNullWord(  $value) 

Parameters

$value

isTranslationWord()

isTranslationWord(  $value) 

Parameters

$value

coerceValue()

coerceValue(  $value) 

Coerce a string into a native type Reference: http://yaml.org/type/bool.html TODO: Use only words from the YAML spec.

Parameters

$value

The value to coerce

getTranslations()

getTranslations(  $words) 

Given a set of words, perform the appropriate translations on them to match the YAML 1.1 specification for type coercing.

Parameters

$words

The words to translate

__load()

__load(  $input) 

Parameters

$input

__loadString()

__loadString(  $input) 

Parameters

$input

loadWithSource()

loadWithSource(  $Source) 

Parameters

$Source

loadFromSource()

loadFromSource(  $input) 

Parameters

$input

loadFromString()

loadFromString(  $input) 

Parameters

$input

_parseLine()

_parseLine(string  $line) : array

Parses YAML code and returns an array for a node

Parameters

string $line

A line from the YAML file

Returns

array

_toType()

_toType(string  $value) : mixed

Finds the type of the passed value, returns the value as the new type.

Parameters

string $value

Returns

mixed

_inlineEscape()

_inlineEscape(  $inline) : array

Used in inlines to check for more inlines or quoted strings

Parameters

$inline

Returns

array

literalBlockContinues()

literalBlockContinues(  $line,   $lineIndent) 

Parameters

$line
$lineIndent

referenceContentsByAlias()

referenceContentsByAlias(  $alias) 

Parameters

$alias

addArrayInline()

addArrayInline(  $array,   $indent) 

Parameters

$array
$indent

addArray()

addArray(  $incoming_data,   $incoming_indent) 

Parameters

$incoming_data
$incoming_indent

startsLiteralBlock()

startsLiteralBlock(  $line) 

Parameters

$line

greedilyNeedNextLine()

greedilyNeedNextLine(  $line) 

Parameters

$line

addLiteralLine()

addLiteralLine(  $literalBlock,   $line,   $literalBlockStyle,   $indent = -1) 

Parameters

$literalBlock
$line
$literalBlockStyle
$indent

stripIndent()

stripIndent(  $line,   $indent = -1) 

Parameters

$line
$indent

getParentPathByIndent()

getParentPathByIndent(  $indent) 

Parameters

$indent

clearBiggerPathValues()

clearBiggerPathValues(  $indent) 

Parameters

$indent

isComment()

isComment(  $line) 

Parameters

$line

isEmpty()

isEmpty(  $line) 

Parameters

$line

isArrayElement()

isArrayElement(  $line) 

Parameters

$line

isHashElement()

isHashElement(  $line) 

Parameters

$line

isLiteral()

isLiteral(  $line) 

Parameters

$line

unquote()

unquote(  $value) 

Parameters

$value

startsMappedSequence()

startsMappedSequence(  $line) 

Parameters

$line

returnMappedSequence()

returnMappedSequence(  $line) 

Parameters

$line

checkKeysInValue()

checkKeysInValue(  $value) 

Parameters

$value

returnMappedValue()

returnMappedValue(  $line) 

Parameters

$line

startsMappedValue()

startsMappedValue(  $line) 

Parameters

$line

isPlainArray()

isPlainArray(  $line) 

Parameters

$line

returnPlainArray()

returnPlainArray(  $line) 

Parameters

$line

returnKeyValuePair()

returnKeyValuePair(  $line) 

Parameters

$line

returnArrayElement()

returnArrayElement(  $line) 

Parameters

$line

nodeContainsGroup()

nodeContainsGroup(  $line) 

Parameters

$line

addGroup()

addGroup(  $line,   $group) 

Parameters

$line
$group

stripGroup()

stripGroup(  $line,   $group) 

Parameters

$line
$group