Skip to content

Commit 068abee

Browse files
committed
minor #20758 [Yaml] Add the Yaml::DUMP_FORCE_DOUBLE_QUOTES_ON_VALUES flag to enforce double quotes around string values (alamirault)
This PR was merged into the 7.3 branch. Discussion ---------- [Yaml] Add the `Yaml::DUMP_FORCE_DOUBLE_QUOTES_ON_VALUES` flag to enforce double quotes around string values Fix #20734 Commits ------- 152d436 [Yaml] Add the Yaml::DUMP_FORCE_DOUBLE_QUOTES_ON_VALUES flag to enforce double quotes around string values
2 parents 612aead + 152d436 commit 068abee

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)