Skip to content

sniff for attributes being multiline #1202

@joachim-n

Description

@joachim-n

Is your feature request related to a problem?

AFAICT there's no sniffs currently for attribute formatting.

It would be useful to have a sniff that detects (and fixes!) attributes not being multiline.

Describe the solution you'd like

For example:

#[MyAttribute(id: 'alpha', label: new TranslatableMarkup('Alpha'), locked: FALSE)]

should be this:

#[MyAttribute(
  id: 'alpha', 
  label: new TranslatableMarkup('Alpha'), 
  locked: FALSE,
)]

Does an attribute creation count as an object creation such as new Foo(1, 2, 3)? And do either of them count as a function call? I can see that FunctionCallSignatureSniff has a method isMultiLineCall(). Would this be the right place to start?

Additional context (optional)

  • [x ] I have read the Contribution Guidelines and this is not a support question.
  • [?] I intend to create a pull request to implement this feature. -- Not sure I know enough about the internals of PHPCS!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions