Skip to content

Commit 409ec02

Browse files
committed
Tweaks
1 parent 068abee commit 409ec02

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

components/yaml.rst

+13-9
Original file line numberDiff line numberDiff line change
@@ -453,15 +453,19 @@ By default, digit-only array keys are dumped as integers. You can use the
453453
Dumping Double Quotes on Values
454454
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
455455

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"
456+
By default, only unsafe string values are enclosed in double quotes (for example,
457+
if they are reserved words or contain newlines and spaces). Use the
458+
``DUMP_FORCE_DOUBLE_QUOTES_ON_VALUES`` flag to add double quotes to all string values::
459+
460+
$dumped = Yaml::dump([
461+
'foo' => 'bar', 'some foo' => 'some bar', 'x' => 3.14, 'y' => true, 'z' => null,
462+
]);
463+
// foo: bar, 'some foo': 'some bar', x: 3.14, 'y': true, z: null
464+
465+
$dumped = Yaml::dump([
466+
'foo' => 'bar', 'some foo' => 'some bar', 'x' => 3.14, 'y' => true, 'z' => null,
467+
], 2, 4, Yaml::DUMP_FORCE_DOUBLE_QUOTES_ON_VALUES);
468+
// "foo": "bar", "some foo": "some bar", "x": 3.14, "y": true, "z": null
465469

466470
.. versionadded:: 7.3
467471

0 commit comments

Comments
 (0)