I'm working on a project which developed many developers for many years, and as it often happens there is no coding standard.
There are many code blocks which in general is similar but written in a different way. For example:
return $this->render('LibraryItem:list.html.twig',
[
'library_items' => $libraryItems,
]
);
or
return $this->render(
'LibraryItem:list.html.twig',
[
'library_items' => $libraryItems,
]
);
or
return $this->render('LibraryItem:list.html.twig', array(
'library_items' => $libraryItems,
)
);
Now, I'm upgrading the project and introducing PSR-12 Coding Style. For this case, I'm playing with two packages PHPCodeSniffer and PHP-CS-Fixer.
I want to achieve that one of those packages forcing the code blocks described above to the next format:
return $this->render('LibraryItem:list.html.twig', [
'library_items' => $libraryItems,
]);
This is the short, simple and readable format, which is well described in The PSR-2 Meta Document.
Using one or more multi-line arguments (i.e: arrays or anonymous functions) does not constitute splitting the argument list itself, therefore Section 4.6 is not automatically enforced. Arrays and anonymous functions are able to span multiple lines.
The problem is I cannot find appropriate rules that allow me to fix all such blocks automatically with PHPCodeSniffer or PHP-CS-Fixer.