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: Add single_line_empty_body
config only_for_constructors
#7962
base: master
Are you sure you want to change the base?
feat: Add single_line_empty_body
config only_for_constructors
#7962
Conversation
single_line_empty_body
config only_for_constructors
single_line_empty_body
config only_for_constructors
Configuration | ||
------------- | ||
|
||
``only_for_constructors`` |
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.
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.
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.
Personally I don't mind if this is part of a bigger community's standard. I just don't like the approach. IMHO it should be an option for configuring places where {}
should be applied (constructor, method signature, loop, try/catch etc), by default all of them should be enabled, with ability to narrow the scope. This particular option is not flexible enough.
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.
I'm challenging the need for proposed option as well as for generic option.
I do not want to have option for sth because "it is technically possible", but because it's a recommended standard.
Until proven differently (with link to example community that will benefit from given configuration), I'm against config for this rule.
Having one approach for given element (eg constructor), but another approach for another element - it's not a standard at all.
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.
It's not a standard as far as I know. It's just how I like it.
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.
Don't fold anything, except a class'
__construct()
, because that looks better with PHP 8's property promotion.I have plenty of empty methods that are overridden in children, or that are overrides of parents. I don't want to fold those, because that looks weird:
(where are the brackets?? am I in an interface?? help!!)
But empty PHP 8 constructors look weird if they're NOT folded:
or
etc.
If the general idea is acceptable, it could be configured differently, with a
context
config option or something. Default is everything: