Skip to content

Commit 941c051

Browse files
GromNaNfabpot
authored andcommitted
[Config] Fix generated comment for multiline "info"
1 parent a1228e4 commit 941c051

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

src/Symfony/Component/Config/Builder/ConfigBuilderGenerator.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -413,39 +413,39 @@ private function getComment(BaseNode $node): string
413413
{
414414
$comment = '';
415415
if ('' !== $info = (string) $node->getInfo()) {
416-
$comment .= ' * '.$info."\n";
416+
$comment .= $info."\n";
417417
}
418418

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

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

428428
if ($node instanceof EnumNode) {
429-
$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";
429+
$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";
430430
} else {
431431
$parameterTypes = $this->getParameterTypes($node);
432-
$comment .= ' * @param ParamConfigurator|'.implode('|', $parameterTypes).' $value'."\n";
432+
$comment .= '@param ParamConfigurator|'.implode('|', $parameterTypes).' $value'."\n";
433433
}
434434
} else {
435435
foreach ((array) ($node->getExample() ?? []) as $example) {
436-
$comment .= ' * @example '.json_encode($example)."\n";
436+
$comment .= '@example '.json_encode($example)."\n";
437437
}
438438

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

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

448-
return $comment;
448+
return $comment ? ' * '.str_replace("\n", "\n * ", rtrim($comment, "\n"))."\n" : '';
449449
}
450450

451451
/**

src/Symfony/Component/Config/Tests/Builder/Fixtures/NodeInitialValues.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,13 @@ public function getConfigTreeBuilder(): TreeBuilder
3838
->arrayPrototype()
3939
->fixXmlConfig('option')
4040
->children()
41-
->scalarNode('dsn')->end()
41+
->scalarNode('dsn')
42+
->info(<<<'INFO'
43+
The DSN to use. This is a required option.
44+
The info is used to describe the DSN,
45+
it can be multi-line.
46+
INFO)
47+
->end()
4248
->scalarNode('serializer')->defaultNull()->end()
4349
->arrayNode('options')
4450
->normalizeKeys(false)

src/Symfony/Component/Config/Tests/Builder/Fixtures/NodeInitialValues/Symfony/Config/NodeInitialValues/Messenger/TransportsConfig.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ class TransportsConfig
1616
private $_usedProperties = [];
1717

1818
/**
19+
* The DSN to use. This is a required option.
20+
* The info is used to describe the DSN,
21+
* it can be multi-line.
1922
* @default null
2023
* @param ParamConfigurator|mixed $value
2124
* @return $this

0 commit comments

Comments
 (0)