-
-
Notifications
You must be signed in to change notification settings - Fork 89
Description
Setting the scene
PHP 8.0 introduced support for attributes via the #[...]
syntax. At this moment, neither PHPCS itself, nor PHPCSExtra contain any sniffs to handle the formatting of attributes.
The PER Coding Standard from FIG, since PER 2.0, outlines a set of rules for attribute formatting to comply with, so using those rules as a starting point would allow for creating an initial set of sniffs to address attribute formatting.
The PER rule
The attribute arguments MUST follow the same rules as defined for multiline function calls.
The rules for (multiline) function calls are covered in https://www.php-fig.org/per/coding-style/#47-method-and-function-calls
The action
The above rules should probably be covered via pre-existing function call sniffs.
It will need investigating which sniff(s) should handle this and whether these sniffs already handle attribute instantiations or not.
This includes checking things like whether the indentation of multi-line attribute instantiations is checked by the function call sniffs or the ScopeIndent
sniff, whether parameters should be on one line or multiple lines is handled by the sniff etc.
The initial outcome should be a list of sniff names with what part of the PER multi-line function call rules are handled by each and whether those rules are also (correctly) applied for attribute class instantiations.
The next step after that would be updating the sniffs where needed.
Please note: the initial investigation and the sniff updates do not have to be done by the same contributor. These are separate tasks.