Skip to content

Commit 152d436

Browse files
committed
[Yaml] Add the Yaml::DUMP_FORCE_DOUBLE_QUOTES_ON_VALUES flag to enforce double quotes around string values
1 parent 10051e9 commit 152d436

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
@@ -450,6 +450,23 @@ By default, digit-only array keys are dumped as integers. You can use the
450450
$dumped = Yaml::dump([200 => 'foo'], 2, 4, Yaml::DUMP_NUMERIC_KEY_AS_STRING);
451451
// '200': foo
452452

453+
Dumping Double Quotes on Values
454+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
455+
456+
By default, only unsafe values are double quoted. In some scenarios, quoting
457+
even safe values is encouraged by various inspectors. You can use the
458+
``DUMP_FORCE_DOUBLE_QUOTES_ON_VALUES`` flag to enforce double quotes::
459+
460+
$dumped = Yaml::dump(['foo' => 'bar']);
461+
// foo: bar
462+
463+
$dumped = Yaml::dump(['foo' => 'bar'], 2, 4, Yaml::DUMP_FORCE_DOUBLE_QUOTES_ON_VALUES);
464+
// foo: "bar"
465+
466+
.. versionadded:: 7.3
467+
468+
The ``Yaml::DUMP_FORCE_DOUBLE_QUOTES_ON_VALUES`` flag was introduced in Symfony 7.3.
469+
453470
Dumping Collection of Maps
454471
~~~~~~~~~~~~~~~~~~~~~~~~~~
455472

0 commit comments

Comments
 (0)