Skip to content

[Yaml] Tweaked the DUMP_NULL_AS_TILDE explanation #12090

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 6, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions components/yaml.rst
Original file line number Diff line number Diff line change
Expand Up @@ -375,17 +375,17 @@ objects, they are automatically transformed into YAML tags::
$dumped = Yaml::dump($data);
// $dumped = '!my_tag { foo: bar }'

Dumping null
~~~~~~~~~~~~
Dumping Null Values
~~~~~~~~~~~~~~~~~~~

``null`` values will be represented with ``null`` by default::
The official YAML specification uses both ``null`` and ``~`` to represent null
values. This component uses ``null`` by default when dumping null values but
you can dump them as ``~`` with the ``DUMP_NULL_AS_TILDE`` flag::

$dumped = Yaml::dump(array('foo' => null));
$dumped = Yaml::dump(['foo' => null]);
// foo: null

You can represent them with ``~`` by using the ``DUMP_NULL_AS_TILDE`` flag::

$dumped = Yaml::dump(array('foo' => null), 2, 4, Yaml::DUMP_NULL_AS_TILDE);
$dumped = Yaml::dump(['foo' => null], 2, 4, Yaml::DUMP_NULL_AS_TILDE);
// foo: ~

.. versionadded:: 4.4
Expand Down