PHP Function YAML Emit
Article about php function yaml_emit
The YAML component is able to convert PHP arrays into YAML files and vice versa. It also dumps PHP arrays into YAML strings with full support for objects and inline level configuration (pretty output). The component offers a real parser which supports a large subset of the YAML specification, just enough to handle your common configuration needs.
Whenever you have a syntax error in your YAML file, the library provides an informative message with the filename and line number where the error occurred, which greatly eases debugging. Moreover, the YAML component has a built-in lint command which can check the syntax of your YAML files.
The YAML component can generate YAML content using the YAML_EMIT_CALLBACK function. The callback function receives two keys: the "tag" key, which represents the YAML tag that has been intercepted, and the "data" key, which is the value of the intercepted object. The data will be encoded as YAML and emitted in place of the intercepted class instance. The YAML_EMIT_CALLBACK also has the option to specify the encoding and linebreak style of the resulting string. The encoding options are YAML_ANY_ENCODING, YAML_UTF8_ENCODING, YAML_UTF16LE_ENCODING and YAML_CR_BREAK, YAML_LN_BREAK and YAML_CRLN_BREAK. This feature was introduced in Symfony 6.3.