Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New rule: Interface implemenations split across lines #8009

Open
2 tasks done
janisint opened this issue May 14, 2024 · 2 comments
Open
2 tasks done

New rule: Interface implemenations split across lines #8009

janisint opened this issue May 14, 2024 · 2 comments
Labels
contribution welcome Core team is looking for a contribution kind/feature request topic/whitespace Indentation, spacing, new lines

Comments

@janisint
Copy link

Feature request

When a class implements multiple interfaces, it can quickly become unreadable.

That's why the PSR-2 section 4.1. Extends and Implements states that you MAY split the list of implements across lines:

class MyClass implements 
    SomeInterface,
    SecondInterface,
    ThirdInterface
{
}

I would appreciate if there was a PHP-CS-Fixer rule that does the multi-line split automatically.

Ideally with a given threshold (amount of implemented interfaces) as to where it changes from single-line to multi-line.

Let me know your thoughts about it.

Link to Discussion where feature request was formed

No response

Contribution Checks

  • I have verified if this feature request was already discussed
  • I am familiar with "Feature or bug?"
@janisint janisint added kind/feature request status/to verify issue needs to be confirmed or analysed to continue labels May 14, 2024
@keradus
Copy link
Member

keradus commented Jun 1, 2024

Hi and thanks for your request.

Is this part of a standard or used by a bigger (F)OSS community? For us that is a condition to add a rule to this project. Otherwise, you can create a custom fixer and use that in your projects. Thanks for understanding.

@janisint
Copy link
Author

janisint commented Jun 3, 2024

Hi, thanks for your response.

Yes, this is part of a standard. As initially stated, PSR-12 (the Php Standard Recommendations which most open source PHP projects follow) suggest you either have all your implemented interfaces in one line, or you may split them on separate lines.

Therefore, I think it would make sense for PHP-CS-Fixer to support this standard and provide the 'split across lines' option.

@Wirone Wirone added contribution welcome Core team is looking for a contribution topic/whitespace Indentation, spacing, new lines and removed status/to verify issue needs to be confirmed or analysed to continue labels Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution welcome Core team is looking for a contribution kind/feature request topic/whitespace Indentation, spacing, new lines
Projects
None yet
Development

No branches or pull requests

3 participants