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
feat: StatementIndentationFixer - introduce stick_comment_to_next_continuous_control_statement config #7624
Conversation
… continuous control statement (PHP-CS-Fixer#7384)"
…tinuous_control_statement config
|
||
- `@Symfony <./../../ruleSets/Symfony.rst>`_ with config: | ||
|
||
``['stick_comment_to_next_continuous_control_statement' => true]`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this turned out to be too agressive - #7497 - and should therefore be not by default in any ruleset
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why any ruleset? If Symfony's standard is like this, then it's OK to have it enabled. If you don't like this and you're using Symfony or PhpCsFixer standard as a base for your ruleset, then you need to re-configure this particular rule 🙂.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. The Symfony or PhpCsFixer standards are too aggresive in cases where comments are at the places mentioned in the issue, search https://github.com/roundcube/roundcubemail codebase for "7497", there are dozens places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So don't use these rulesets 🤷♂️? These are opinionated sets, you either accept how they work or prepare your own configuration. And just to remind, I don't like this behaviour at all because I believe it's impossible to determine the intent (where the comment belongs to) and from a logical point of view such comments should be intended just like everything inside the braces. But it was done on purpose to move it one step left, and now it can be configurable - leaving the same behaviour as default. It's the decision of rulesets' owners, not something you can argue with 🙂.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PHP CS Fixer is not reformatter, thus it should reformat to one, current?, indent, but allow the other valid/meaningful one too. I would say that would be better than hard/project wide configuration option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reformatting is part of Fixer responsibility. Actually, quite a huge part of it - anything related to whitespaces or phpdocs can be understood as reformatting.
With previous complain that the change was too aggressive, we disable it by default for rule itself and allow everyone to opt-in, if they want to use it.
Same time, any community creating their standard has a freedom to decide where the comments should be placed. And it is that implemented rules are following existing standard, not that standard is adjusted to created rules. With that, if someone was already following Sf standards, they shall already have following each rules, even those without existing Fixer rules.
Any standard/rule can be called "too aggressive" by those who do not want to follow given rule. Happily, you can not only disable the rule now, but also configure it to your needs.
…tinuous_control_statement config (PHP-CS-Fixer#7624)
closes #7497