Skip to content

Commit 68cf0cf

Browse files
committed
[Yaml] Dump null as tilde
1 parent 9ad2b07 commit 68cf0cf

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

components/yaml.rst

+17
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,23 @@ objects, they are automatically transformed into YAML tags::
375375
$dumped = Yaml::dump($data);
376376
// $dumped = '!my_tag { foo: bar }'
377377

378+
Dumping null
379+
~~~~~~~~~~~~
380+
381+
``null`` values will be represented with ``null`` by default::
382+
383+
$dumped = Yaml::dump(array('foo' => null));
384+
// foo: null
385+
386+
You can represent them with ``~`` by using the ``DUMP_NULL_AS_TILDE`` flag::
387+
388+
$dumped = Yaml::dump(array('foo' => null), 2, 4, Yaml::DUMP_NULL_AS_TILDE);
389+
// foo: ~
390+
391+
.. versionadded:: 4.4
392+
393+
The flag to dump ``null`` as ``~`` was introduced in Symfony 4.4.
394+
378395
Syntax Validation
379396
~~~~~~~~~~~~~~~~~
380397

0 commit comments

Comments
 (0)