From 68cf0cfd6b33b6c3c48026c41da18286edbca43f Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Thu, 1 Aug 2019 08:14:09 +0200 Subject: [PATCH] [Yaml] Dump null as tilde --- components/yaml.rst | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/components/yaml.rst b/components/yaml.rst index c3f355ab1da..bc6a4bc3634 100644 --- a/components/yaml.rst +++ b/components/yaml.rst @@ -375,6 +375,23 @@ objects, they are automatically transformed into YAML tags:: $dumped = Yaml::dump($data); // $dumped = '!my_tag { foo: bar }' +Dumping null +~~~~~~~~~~~~ + +``null`` values will be represented with ``null`` by default:: + + $dumped = Yaml::dump(array('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); + // foo: ~ + +.. versionadded:: 4.4 + + The flag to dump ``null`` as ``~`` was introduced in Symfony 4.4. + Syntax Validation ~~~~~~~~~~~~~~~~~