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
Make single_line_empty_body
fix control structures
#7809
Comments
Currently the rule does not fix control structures at all, I can't reproduce the issue. However, we may want to extend the rule's scope to control structures. |
the current behaviour is:
intended behaviour/format is:
|
Do I understand correctly that your actual request is to extend the scope of the rule to control structures as I suggested? |
Yes. Maybe under an option. |
I don't see the need for an option here, it's also a "body" - the rule's name does not refer to functions, classes or anything particular, so it can also cover |
single_line_empty_body
should fix last catch/finally bodysingle_line_empty_body
fix control structures
To me the rule was first introduced to respect PER standard https://www.php-fig.org/per/coding-style/ So the option seems a requirement or the rule will start doing more than the PER standard. |
IMHO if PER does not specify that, it means either style is valid and the rule can propose the standard 🙂. If PER specifies it at some point, then it may be required to make the rule configurable. If PER have specified it differently for each kind of body, then a config option would be required. |
IMHO the option should be present to a) satisfy PER only, b) satisfy users more, but optionally. |
Doing more than PER specifies is not a violation, hence the config option is superfluous at this point (nice to have, but not required). Also, such an option should not be based on PER/not PER , but on available places where fix can be applied, then it can be configured accordingly in any ruleset. |
I disagree with this as soon as the rule is (or will be) inside the PER Ruleset. When I add the "Foo" ruleset in my php-cs-fixer config, I expect to strictly respect the "Foo" standard without any extra-rules added inside it. So, if we add |
I still think that doing more than described in PER is not against it, it would be if fixer did something that is described as "SHOULD NOT" or "MUST NOT", though. Anyway, the config option is nice to have and as we see here, more than welcome 🙂. |
Bug report
only the last catch/finally body should be fixed as otherwise the formatting will be broken
expected behaviour:
The text was updated successfully, but these errors were encountered: