Skip to content
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

Proposal: Always add trailing comma #41

Open
susnux opened this issue Nov 12, 2024 · 1 comment
Open

Proposal: Always add trailing comma #41

susnux opened this issue Nov 12, 2024 · 1 comment
Labels
enhancement New feature or request question Further information is requested

Comments

@susnux
Copy link

susnux commented Nov 12, 2024

I think it makes sense to adjust our config for trailing_comma_in_multiline.

Currently we only enforce trailing commas in parameters, this is great to make git diff cleaner when adding new parameters.
But the same also applies to the function call, arrays and match in general.

So how about changing it to 'trailing_comma_in_multiline' => ['elements' => ['arguments', 'arrays', 'match', 'parameters']].

Caused code changes

doSomething(
    $first,
-    $second
+    $second,
);
return match($something) {
    1 => 'one',
-   2 => 'two'
+   2 => 'two',
};
$arr = [
    1,
-   2
+   2,
];

Reason

This would allow all those cases to benefit from smaller diff on new array members / arguments.

Before:

$arr = [
    1,
-   2
+   2,
+   3
];

After:

$arr = [
    1,
    2,
+   3,
];
@susnux susnux added enhancement New feature or request question Further information is requested labels Nov 12, 2024
@ChristophWurst
Copy link
Member

Hesitant 👍. Some people do this consistently already. For the rest cs fixer will complain more often, but I guess it's something people can get used to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants