Skip to content

Commit afc47ed

Browse files
committed
minor symfony#54326 [Yaml] prefix examples with # (tacman)
This PR was squashed before being merged into the 7.0 branch. Discussion ---------- [Yaml] prefix examples with # | Q | A | ------------- | --- | Branch? | 7.0 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #symfony#54154 | License | MIT As mentioned in the issue, the yaml before wasn't valid, as the examples were dumped as an array in the yaml. This simply comments the examples. Commits ------- fd95a8f [Yaml] prefix examples with #
2 parents ed617c8 + fd95a8f commit afc47ed

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ private function writeNode(NodeInterface $node, ?NodeInterface $parentNode = nul
170170

171171
$this->writeLine('# '.$message.':', $depth * 4 + 4);
172172

173-
$this->writeArray(array_map(Inline::dump(...), $example), $depth + 1);
173+
$this->writeArray(array_map(Inline::dump(...), $example), $depth + 1, true);
174174
}
175175

176176
if ($children) {
@@ -191,7 +191,7 @@ private function writeLine(string $text, int $indent = 0): void
191191
$this->reference .= sprintf($format, $text)."\n";
192192
}
193193

194-
private function writeArray(array $array, int $depth): void
194+
private function writeArray(array $array, int $depth, bool $asComment = false): void
195195
{
196196
$isIndexed = array_is_list($array);
197197

@@ -201,11 +201,12 @@ private function writeArray(array $array, int $depth): void
201201
} else {
202202
$val = $value;
203203
}
204+
$prefix = $asComment ? '# ' : '';
204205

205206
if ($isIndexed) {
206-
$this->writeLine('- '.$val, $depth * 4);
207+
$this->writeLine($prefix.'- '.$val, $depth * 4);
207208
} else {
208-
$this->writeLine(sprintf('%-20s %s', $key.':', $val), $depth * 4);
209+
$this->writeLine($prefix.sprintf('%-20s %s', $key.':', $val), $depth * 4);
209210
}
210211

211212
if (\is_array($value)) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ enum: ~ # One of "this"; "that"; Symfony\Component\Config\Tests\
117117
variable:
118118
119119
# Examples:
120-
- foo
121-
- bar
120+
# - foo
121+
# - bar
122122
parameters:
123123
124124
# Prototype: Parameter name

0 commit comments

Comments
 (0)