From 12bb604aac1f3a00871dc9d99042f7a6d3abea53 Mon Sep 17 00:00:00 2001 From: gr8b Date: Sat, 4 Jan 2025 17:49:29 +0200 Subject: [PATCH] [Yaml] feature #59315 Add compact nested mapping support to Dumper --- components/yaml.rst | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/components/yaml.rst b/components/yaml.rst index 30f715a7a24..c373c98015d 100644 --- a/components/yaml.rst +++ b/components/yaml.rst @@ -440,6 +440,34 @@ By default, digit-only array keys are dumped as integers. You can use the $dumped = Yaml::dump([200 => 'foo'], 2, 4, Yaml::DUMP_NUMERIC_KEY_AS_STRING); // '200': foo +Dumping Collection of Maps +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +By default, the collection of maps uses a hyphen on a separate line as a delimiter. +To use the delimiter line as part of the map dump, use the ``Yaml::DUMP_COMPACT_NESTED_MAPPING`` flag. + +Dump without flag set: + +.. code-block:: yaml + + planets: + - + name: Mercury + distance: 57910000 + - + name: Jupiter + distance: 778500000 + +Dump with ``Yaml::DUMP_COMPACT_NESTED_MAPPING`` flag set: + +.. code-block:: yaml + + planets: + - name: Mercury + distance: 57910000 + - name: Jupiter + distance: 778500000 + Syntax Validation ~~~~~~~~~~~~~~~~~