Skip to content

Commit ee9d357

Browse files
[Config] Fix XML dump when node example is an array
1 parent 2f62c4a commit ee9d357

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ private function writeNode(NodeInterface $node, int $depth = 0, bool $root = fal
147147
}
148148

149149
if ($child instanceof BaseNode && $example = $child->getExample()) {
150-
$comments[] = 'Example: '.$example;
150+
$comments[] = 'Example: '.(\is_array($example) ? implode(', ', $example) : $example);
151151
}
152152

153153
if ($child->isRequired()) {

src/Symfony/Component/Config/Tests/Definition/Dumper/XmlReferenceDumperTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ private function getConfigurationAsString()
4242
<!-- scalar-deprecated-with-message: Deprecated (Since vendor/package 1.1: Deprecation custom message for "scalar_deprecated_with_message" at "acme_root") -->
4343
<!-- enum-with-default: One of "this"; "that" -->
4444
<!-- enum: One of "this"; "that" -->
45+
<!-- variable: Example: foo, bar -->
4546
<config
4647
boolean="true"
4748
scalar-empty=""
@@ -57,6 +58,7 @@ private function getConfigurationAsString()
5758
node-with-a-looong-name=""
5859
enum-with-default="this"
5960
enum=""
61+
variable=""
6062
custom-node="true"
6163
>
6264

src/Symfony/Component/Config/Tests/Definition/Dumper/YamlReferenceDumperTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ enum: ~ # One of "this"; "that"
114114
# which should be indented
115115
child3: ~ # Example: 'example setting'
116116
scalar_prototyped: []
117+
variable:
118+
119+
# Examples:
120+
- foo
121+
- bar
117122
parameters:
118123
119124
# Prototype: Parameter name

src/Symfony/Component/Config/Tests/Fixtures/Configuration/ExampleConfiguration.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ public function getConfigTreeBuilder(): TreeBuilder
5858
->arrayNode('scalar_prototyped')
5959
->prototype('scalar')->end()
6060
->end()
61+
->variableNode('variable')
62+
->example(['foo', 'bar'])
63+
->end()
6164
->arrayNode('parameters')
6265
->useAttributeAsKey('name')
6366
->prototype('scalar')->info('Parameter name')->end()

0 commit comments

Comments
 (0)