Skip to main content

Module yaml

Module yaml 

Source
Expand description

yaml_parse() (ext-yaml 2.3 over libyaml 0.2.5) with the default ini settings: timestamps, !!binary and !php/object stay strings.

Documents are split into events by libyaml itself (unsafe-libyaml, the C library translated to Rust), so exactly the same inputs are accepted and refused; the events are turned into PHP values as ext-yaml’s parse.c and detect.c do: YAML 1.1 booleans (yes, off, y), integers in binary, octal (0755), hexadecimal, sexagesimal (1:20) and with _ or , separators, floats whose exponent has a sign, merge keys (<<), and keys converted like array offsets.

PHP: anchors are PHP references. An alias of a node that is still being built (a recursive structure) has no value here: it is refused as an unknown alias.

Nesting deeper than MAX_DEPTH refuses the document, as the other codecs in this crate do. ext-yaml has no limit, and walking an unbounded document recurses until the stack overflows, which aborts the process.

Constants§

MAX_DEPTH
The deepest nesting of mappings and sequences parse reads. A deeper document is refused (None) instead of recursing until the stack overflows. Real configuration files stay far below it. At this depth a release build needs under 768 KB of stack, well inside a 2 MB coroutine.

Functions§

parse
yaml_parse($input): the first document of input as a PHP value, or None where PHP returns false (and warns): a malformed document or an unknown alias, or nesting deeper than MAX_DEPTH. An input without a document is null.