-
Notifications
You must be signed in to change notification settings - Fork 1
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
Proposal: enable single_line_empty_body rule #14
Comments
What do you think @ChristophWurst @nickvergessen @come-nc to pick some people ;) |
Yeah, doing that one wrong very often as well, also in all the stub-files I'd be okay. |
I couldn't find a way to allow both but prefer this one. |
I’m used to the "Before" state and I do that on purpose. I like having the closing tag always on its own line and not having to change that when removing the last line in a constructor. It’s all about clean diff for me, I like when diffs look like: diff --git a/lib/private/Security/Bruteforce/Backend/DatabaseBackend.php b/lib/private/Security/Bruteforce/Backend/DatabaseBackend.php
index 04f2a7b6397..8d6726bea6e 100644
--- a/lib/private/Security/Bruteforce/Backend/DatabaseBackend.php
+++ b/lib/private/Security/Bruteforce/Backend/DatabaseBackend.php
@@ -33,6 +33,7 @@ class DatabaseBackend implements IBackend {
public function __construct(
private IDBConnection $db,
) {
+ $this->thing = "init";
}
/** And this is less clean: diff --git a/lib/private/Security/Bruteforce/Backend/DatabaseBackend.php b/lib/private/Security/Bruteforce/Backend/DatabaseBackend.php
index 1304a36af47..8d6726bea6e 100644
--- a/lib/private/Security/Bruteforce/Backend/DatabaseBackend.php
+++ b/lib/private/Security/Bruteforce/Backend/DatabaseBackend.php
@@ -32,7 +32,9 @@ class DatabaseBackend implements IBackend {
public function __construct(
private IDBConnection $db,
- ) {}
+ ) {
+ $this->thing = "init";
+ }
/**
* {@inheritDoc} What I would be more interested in is PHP-CS-Fixer/PHP-CS-Fixer#6325 , for the same reason of having a clean All that said, I’m not a strong no on this, if it pleases people and is handled by the cs-fixer I will change habits, I have the pre-commit tool setup anyway. (Also we’ll need nextcloud/server#39271 first before doing other changes to codestyle config) |
I'm fine with either. Single line makes the code more compact but I also get @come-nc's idea of clean diffs for removed/added constructor statements. |
Using more and more constructor property promotion with PHP 8.0 now, I more often end up having empty contructor bodies and the current ruleset requires to always have the opening and closing curly braces in new lines.
Might be personal preference which just triggers me a lot, but my suggestion would be to switch on the
single_line_empty_body
rule to allow for a more compact way of writing thishttps://cs.symfony.com/doc/rules/basic/single_line_empty_body.html
Before
After
The text was updated successfully, but these errors were encountered: