Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/Symfony/Component/Config/Builder/ConfigBuilderGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,39 +413,39 @@ private function getComment(BaseNode $node): string
{
$comment = '';
if ('' !== $info = (string) $node->getInfo()) {
$comment .= ' * '.$info."\n";
$comment .= $info."\n";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want a smaller fix applied only to the $info part, it would be:

$comment .= ' * '.str_replace("\n", "\n * ", $info)."\n";

}

if (!$node instanceof ArrayNode) {
foreach ((array) ($node->getExample() ?? []) as $example) {
$comment .= ' * @example '.$example."\n";
$comment .= '@example '.$example."\n";
}

if ('' !== $default = $node->getDefaultValue()) {
$comment .= ' * @default '.(null === $default ? 'null' : var_export($default, true))."\n";
$comment .= '@default '.(null === $default ? 'null' : var_export($default, true))."\n";
}

if ($node instanceof EnumNode) {
$comment .= sprintf(' * @param ParamConfigurator|%s $value', implode('|', array_unique(array_map(fn ($a) => !$a instanceof \UnitEnum ? var_export($a, true) : '\\'.ltrim(var_export($a, true), '\\'), $node->getValues()))))."\n";
$comment .= sprintf('@param ParamConfigurator|%s $value', implode('|', array_unique(array_map(fn ($a) => !$a instanceof \UnitEnum ? var_export($a, true) : '\\'.ltrim(var_export($a, true), '\\'), $node->getValues()))))."\n";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When up-merging into 7.2, a backslash is added before sprintf by 6ce530c#diff-2aaa94a5e0cdde514853eddaf724fb3724c0501ddc5285af115bc1fe9c04d7ce

} else {
$parameterTypes = $this->getParameterTypes($node);
$comment .= ' * @param ParamConfigurator|'.implode('|', $parameterTypes).' $value'."\n";
$comment .= '@param ParamConfigurator|'.implode('|', $parameterTypes).' $value'."\n";
}
} else {
foreach ((array) ($node->getExample() ?? []) as $example) {
$comment .= ' * @example '.json_encode($example)."\n";
$comment .= '@example '.json_encode($example)."\n";
}

if ($node->hasDefaultValue() && [] != $default = $node->getDefaultValue()) {
$comment .= ' * @default '.json_encode($default)."\n";
$comment .= '@default '.json_encode($default)."\n";
}
}

if ($node->isDeprecated()) {
$comment .= ' * @deprecated '.$node->getDeprecation($node->getName(), $node->getParent()->getName())['message']."\n";
$comment .= '@deprecated '.$node->getDeprecation($node->getName(), $node->getParent()->getName())['message']."\n";
}

return $comment;
return $comment ? ' * '.str_replace("\n", "\n * ", rtrim($comment, "\n"))."\n" : '';
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@ public function getConfigTreeBuilder(): TreeBuilder
->arrayPrototype()
->fixXmlConfig('option')
->children()
->scalarNode('dsn')->end()
->scalarNode('dsn')
->info(<<<'INFO'
The DSN to use. This is a required option.
The info is used to describe the DSN,
it can be multi-line.
INFO)
->end()
->scalarNode('serializer')->defaultNull()->end()
->arrayNode('options')
->normalizeKeys(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class TransportsConfig
private $_usedProperties = [];

/**
* The DSN to use. This is a required option.
* The info is used to describe the DSN,
* it can be multi-line.
* @default null
* @param ParamConfigurator|mixed $value
* @return $this
Expand Down