You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 this
Empty body of class, interface, trait, enum or function must be abbreviated as {} and placed on the same line as the previous symbol, separated by a single space.
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 diff and a clean git blame as well.
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)
Reacted by Christoph Wurst, Benjamin Gaussorgues and Ferdinand Thiessen
Activity
juliusknorr commentedon Aug 24, 2023
What do you think @ChristophWurst @nickvergessen @come-nc to pick some people ;)
nickvergessen commentedon Aug 24, 2023
Yeah, doing that one wrong very often as well, also in all the stub-files
I'd be okay.
Can we allow both patterns? Or would you break/disallow
{\n}?juliusknorr commentedon Aug 24, 2023
I couldn't find a way to allow both but prefer this one.
come-nc commentedon Aug 28, 2023
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:
And this is less clean:
What I would be more interested in is PHP-CS-Fixer/PHP-CS-Fixer#6325 , for the same reason of having a clean
diffand a cleangit blameas well.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)
ChristophWurst commentedon Sep 5, 2023
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.