Skip to content

Proposal: Always add trailing comma #41

Open
@susnux

Description

@susnux

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,
];

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions