YAML
YAML
Lightweight YAML parser for simple key/value and list structures.
class YAMLMethods
__construct
Creates a YAML parser instance.
public __construct(): voidparseFile
Parses a YAML file into an array structure.
public parseFile(string $filename): array|falseReturns: array|false
Parameters
| Parameter | Type | Description |
|---|---|---|
$filename | string | filename to read and parse |
parse
Parses YAML text content into an array structure.
public parse(string $content): arrayReturns: array
Parameters
| Parameter | Type | Description |
|---|---|---|
$content | string | YAML content to parse |
dump
Dumps an array structure into block-style YAML text.
public dump(array $data): stringReturns: string
Covers the subset needed to round-trip a plain data structure (nested maps/sequences of scalars) — the mirror image of what Hazaar\Parser\YAML::parse understands, plus enough scalar quoting rules to stay unambiguous (strings that would otherwise read as a bool/null/number, or that contain YAML-significant characters, are quoted; everything else is left bare for readability).
Parameters
| Parameter | Type | Description |
|---|---|---|
$data | array | the array structure to dump |
dumpLines
private dumpLines(array $data, int $level): arrayReturns: array
Parameters
| Parameter | Type | Description |
|---|---|---|
$data | array | |
$level | int |
dumpMappingEntry
private dumpMappingEntry(string $key, mixed $value, int $level): arrayReturns: array
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string | |
$value | mixed | |
$level | int |
dumpSequenceItem
private dumpSequenceItem(mixed $value, int $level): arrayReturns: array
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | mixed | |
$level | int |
scalar
Renders a single scalar value (or array key) as YAML text, quoting only when necessary to
private scalar(mixed $value): stringReturns: string
keep it unambiguous.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | mixed |
quoteIfNeeded
private quoteIfNeeded(string $str): stringReturns: string
Parameters
| Parameter | Type | Description |
|---|---|---|
$str | string |
parseSection
Parses a YAML section recursively into the target parent array.
private parseSection(array $iter, array $parent, int $level, array $indents): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$iter | array | line iterator by reference |
$parent | array | parent output node being populated |
$level | int | current nesting level |
$indents | array | indentation history by level |
Generated by Hazaar API Doc Generator on Fri, 04 Sep 2026 23:32:16 +0000