Documentation

Horde_Yaml
in package

Horde YAML parser.

This class can be used to read a YAML file and convert its contents into a PHP array. The native PHP parser supports a limited subsection of the YAML spec, but if the syck extension is present, that will be used for parsing.

Tags
category

Horde

Table of Contents

$allowedClasses  : array<string|int, mixed>
Whitelist of classes that can be instantiated automatically when loading YAML docs that include serialized PHP objects.
$dumpfunc  : callable
Callback used for alternate YAML dumper, typically exported by a faster PHP extension. This function's first argument must accept a mixed variable to be dumped.
$loadfunc  : callable
Callback used for alternate YAML loader, typically exported by a faster PHP extension. This function's first argument must accept a string with YAML content.
dump()  : string
Dumps a PHP array to YAML.
load()  : array<string|int, mixed>
Load a string containing YAML and parse it into a PHP array.
loadFile()  : array<string|int, mixed>
Load a file containing YAML and parse it into a PHP array.
loadStream()  : array<string|int, mixed>
Load YAML from a PHP stream resource.

Properties

$allowedClasses

Whitelist of classes that can be instantiated automatically when loading YAML docs that include serialized PHP objects.

public static array<string|int, mixed> $allowedClasses = array('ArrayObject')

$dumpfunc

Callback used for alternate YAML dumper, typically exported by a faster PHP extension. This function's first argument must accept a mixed variable to be dumped.

public static callable $dumpfunc = 'syck_dump'

$loadfunc

Callback used for alternate YAML loader, typically exported by a faster PHP extension. This function's first argument must accept a string with YAML content.

public static callable $loadfunc = 'syck_load'

Methods

dump()

Dumps a PHP array to YAML.

public static dump(mixed $value[, array<string|int, mixed> $options = array() ]) : string

The dump method, when supplied with an array, will do its best to convert the array into friendly YAML.

Parameters
$value : mixed
$options : array<string|int, mixed> = array()

Options to pass to dumper.

Return values
string

YAML representation of $value.

load()

Load a string containing YAML and parse it into a PHP array.

public static load(string $yaml) : array<string|int, mixed>

Returns an empty array on failure.

Parameters
$yaml : string

String containing YAML

Return values
array<string|int, mixed>

PHP array representation of YAML content

loadFile()

Load a file containing YAML and parse it into a PHP array.

public static loadFile(string $filename) : array<string|int, mixed>

If the file cannot be opened, an exception is thrown. If the file is read but parsing fails, an empty array is returned.

Parameters
$filename : string

Filename to load

Tags
throws
IllegalArgumentException

If $filename is invalid

throws
Horde_Yaml_Exception|RuntimeException

If the file cannot be opened.

Return values
array<string|int, mixed>

PHP array representation of YAML content

loadStream()

Load YAML from a PHP stream resource.

public static loadStream(resource $stream) : array<string|int, mixed>
Parameters
$stream : resource

PHP stream resource

Return values
array<string|int, mixed>

PHP array representation of YAML content

Search results