phel-lang icon indicating copy to clipboard operation
phel-lang copied to clipboard

Add trailing comma in multiline arrays, arguments and parameters

Open JesusValeraDev opened this issue 3 years ago β€’ 0 comments

πŸ“š Description

Since PHP 8.0, it's possible to add trailing comma for multiline arrays, arguments, parameters and closures (RFCΒΉ & RFCΒ²).

It's also possible to add the rule on .php-cs-fixer.dist.php, having this rule, the code will be more standard along the project, also, when we want to add a new parameter to a function/whatever it applies, we will have to update a single line instead of two, eg:

return new FileCompiler(
    $this->getCompilerFacade(),
-    $this->createNamespaceExtractor()
);

# πŸ‘‡πŸΌπŸ‘‡πŸΌπŸ‘‡πŸΌ

return new FileCompiler(
    $this->getCompilerFacade(),
+    $this->createNamespaceExtractor(),
+    $this->otherDependency()
);

# πŸ’‘ will become to

return new FileCompiler(
    $this->getCompilerFacade(),
    $this->createNamespaceExtractor(),
);

# πŸ‘‡πŸΌπŸ‘‡πŸΌπŸ‘‡πŸΌ

return new FileCompiler(
    $this->getCompilerFacade(),
    $this->createNamespaceExtractor(),
+    $this->otherDependency(),
);

JesusValeraDev avatar Jul 26 '22 21:07 JesusValeraDev