Skip to content

[Config] Fix generated comment for multiline "info" #60400

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 14, 2025

Conversation

GromNaN
Copy link
Member

@GromNaN GromNaN commented May 11, 2025

Q A
Branch? 6.4
Bug fix? yes
New feature? no
Deprecations? no
Issues Fix #60317
License MIT

Instead of fixing the multiline comment formatting only for the "info" part, the * is now prepended to every line of the generated comment block.
nette/code-generator uses almost the same transformation: https://github.com/nette/php-generator/blob/42806049a7774a2bd316c958f5dcf01c6b5c56fa/src/PhpGenerator/Helpers.php#L60

}

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

@@ -413,39 +413,43 @@ 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";

@alexandre-daubois
Copy link
Member

Could we edit existing fixtures to cover this (like src/Symfony/Component/Config/Tests/Builder/Fixtures/AddToList.php or any of the same folder) ?

@GromNaN
Copy link
Member Author

GromNaN commented May 12, 2025

Thanks @alexandre-daubois, I hadn't found where to test.

@fabpot
Copy link
Member

fabpot commented May 14, 2025

Thank you @GromNaN.

@fabpot fabpot merged commit 7a69d61 into symfony:6.4 May 14, 2025
6 checks passed
@GromNaN GromNaN deleted the gh-60317 branch May 14, 2025 11:07
This was referenced May 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants