Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1f6f693

Browse files
committed
bug #39336 [Config] YamlReferenceDumper: No default value required for VariableNode with array example (Nyholm)
This PR was merged into the 4.4 branch. Discussion ---------- [Config] YamlReferenceDumper: No default value required for VariableNode with array example | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | | Tickets | | License | MIT | Doc PR | This will fix #39328 in a better way. A `VariableNode` may have an array as value and also a default value as "null". (Like the workflow component). When we dump the config, we generate invalid yaml: ``` workflows: enabled: false workflows: # Prototype name: # Select which Transition events should be dispatched for this Workflow events_to_dispatch: null # Examples: - workflow.enter - workflow.transition ``` With this PR, we will remove the `null` default value from the dumped config. #SymfonyHackday Commits ------- 9104fd4 [Config] YamlReferenceDumper: No default value required for VariableNode with array example
2 parents 21ef411 + 9104fd4 commit 1f6f693

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Symfony\Component\Config\Definition\NodeInterface;
1818
use Symfony\Component\Config\Definition\PrototypedArrayNode;
1919
use Symfony\Component\Config\Definition\ScalarNode;
20+
use Symfony\Component\Config\Definition\VariableNode;
2021
use Symfony\Component\Yaml\Inline;
2122

2223
/**
@@ -95,6 +96,9 @@ private function writeNode(NodeInterface $node, NodeInterface $parentNode = null
9596
} elseif ($node instanceof EnumNode) {
9697
$comments[] = 'One of '.implode('; ', array_map('json_encode', $node->getValues()));
9798
$default = $node->hasDefaultValue() ? Inline::dump($node->getDefaultValue()) : '~';
99+
} elseif (VariableNode::class === get_class($node) && \is_array($example)) {
100+
// If there is an array example, we are sure we dont need to print a default value
101+
$default = '';
98102
} else {
99103
$default = '~';
100104

0 commit comments

Comments
 (0)