From caae8218e13f617551b34cbc16b43dcab1cc8f6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Wed, 18 Sep 2024 12:24:16 +0200 Subject: [PATCH 1/8] feat: Add rule for having one promoted property per line in constructor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- composer.json | 3 ++- src/Config.php | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 7e825f1..f0e2091 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,8 @@ "type": "library", "require": { "php": "^7.3|^8.0", - "php-cs-fixer/shim": "^3.17" + "php-cs-fixer/shim": "^3.17", + "kubawerlos/php-cs-fixer-custom-fixers": "^3.22" }, "license": "MIT", "authors": [ diff --git a/src/Config.php b/src/Config.php index 73b9baf..b41ba3a 100644 --- a/src/Config.php +++ b/src/Config.php @@ -10,6 +10,7 @@ class Config extends Base { public function __construct($name = 'default') { parent::__construct($name); $this->setIndent("\t"); + $this->registerCustomFixers(new PhpCsFixerCustomFixers\Fixers()); } public function getRules() : array { @@ -72,6 +73,7 @@ public function getRules() : array { 'elements' => ['property', 'method', 'const'] ], 'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false], + PhpCsFixerCustomFixers\Fixer\MultilinePromotedPropertiesFixer::name() => true, ]; } } From 7266f847ae894311db0e5e23f28aaae5da8045a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Wed, 18 Sep 2024 12:43:49 +0200 Subject: [PATCH 2/8] fix: Add missing use and add rule for trailing comma on multiline parameters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- src/Config.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Config.php b/src/Config.php index b41ba3a..f4db60b 100644 --- a/src/Config.php +++ b/src/Config.php @@ -5,6 +5,7 @@ namespace Nextcloud\CodingStandard; use PhpCsFixer\Config as Base; +use PhpCsFixerCustomFixers; class Config extends Base { public function __construct($name = 'default') { @@ -68,6 +69,7 @@ public function getRules() : array { 'single_line_after_imports' => true, 'single_quote' => ['strings_containing_single_quote_chars' => false], 'switch_case_space' => true, + 'trailing_comma_in_multiline' => ['elements' => ['parameters']], 'types_spaces' => ['space' => 'none', 'space_multiple_catch' => 'none'], 'visibility_required' => [ 'elements' => ['property', 'method', 'const'] From fe1d17f9a25eb8caaa701f3dd304af32a619fac0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Wed, 18 Sep 2024 12:45:45 +0200 Subject: [PATCH 3/8] chore: prepare changelog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1cb95fa..e02c3fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ # Changelog All notable changes to this project will be documented in this file. +## 1.2.4 - TBA + +### Changed +* `trailing_comma_in_multiline`: Add a trailing comma to multline function parameters +* `MultilinePromotedPropertiesFixer`: Break promoted properties on multiple lines + ## 1.2.3 - 2024-08-23 ### Changed * `cast_spaces`: No space between cast and variable From abb6d364e5afcc6951d9af0ee8394b85da013b33 Mon Sep 17 00:00:00 2001 From: provokateurin Date: Wed, 18 Sep 2024 13:02:54 +0200 Subject: [PATCH 4/8] feat: Add blank lines before returns and after control statements Signed-off-by: provokateurin --- CHANGELOG.md | 4 +++- composer.json | 3 ++- src/Config.php | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e02c3fd..454d89b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,13 @@ # Changelog All notable changes to this project will be documented in this file. -## 1.2.4 - TBA +## 1.3.0 - TBA ### Changed * `trailing_comma_in_multiline`: Add a trailing comma to multline function parameters * `MultilinePromotedPropertiesFixer`: Break promoted properties on multiple lines +* `ErickSkrauch/blank_line_before_return`: Add a blank line before each return +* `ErickSkrauch/line_break_after_statements`: Add a blank line after all control statements ## 1.2.3 - 2024-08-23 ### Changed diff --git a/composer.json b/composer.json index f0e2091..f8ac7ca 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,8 @@ "require": { "php": "^7.3|^8.0", "php-cs-fixer/shim": "^3.17", - "kubawerlos/php-cs-fixer-custom-fixers": "^3.22" + "kubawerlos/php-cs-fixer-custom-fixers": "^3.22", + "erickskrauch/php-cs-fixer-custom-fixers": "^1.3" }, "license": "MIT", "authors": [ diff --git a/src/Config.php b/src/Config.php index f4db60b..6895b89 100644 --- a/src/Config.php +++ b/src/Config.php @@ -12,6 +12,7 @@ public function __construct($name = 'default') { parent::__construct($name); $this->setIndent("\t"); $this->registerCustomFixers(new PhpCsFixerCustomFixers\Fixers()); + $this->registerCustomFixers(new \ErickSkrauch\PhpCsFixer\Fixers()); } public function getRules() : array { @@ -76,6 +77,8 @@ public function getRules() : array { ], 'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false], PhpCsFixerCustomFixers\Fixer\MultilinePromotedPropertiesFixer::name() => true, + 'ErickSkrauch/blank_line_before_return' => true, + 'ErickSkrauch/line_break_after_statements' => true, ]; } } From d150d95d491d26346476d7803e2db1bd60c894eb Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Wed, 18 Sep 2024 13:24:15 +0200 Subject: [PATCH 5/8] style: add concat_space and nullable_type_declaration Ref https://github.com/nextcloud/coding-standard/issues/29 Ref https://github.com/nextcloud/coding-standard/issues/30 Signed-off-by: Daniel Kesselberg --- CHANGELOG.md | 2 ++ src/Config.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 454d89b..c0ca863 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ All notable changes to this project will be documented in this file. * `MultilinePromotedPropertiesFixer`: Break promoted properties on multiple lines * `ErickSkrauch/blank_line_before_return`: Add a blank line before each return * `ErickSkrauch/line_break_after_statements`: Add a blank line after all control statements +* `concat_space`: Concatenation should be spaced +* `nullable_type_declaration`: Changes `DateTimeInterface|null` to `?DateTimeInterface` ## 1.2.3 - 2024-08-23 ### Changed diff --git a/src/Config.php b/src/Config.php index 6895b89..9bf8947 100644 --- a/src/Config.php +++ b/src/Config.php @@ -28,6 +28,7 @@ public function getRules() : array { 'blank_line_after_namespace' => true, 'blank_line_after_opening_tag' => true, 'cast_spaces' => ['space' => 'none'], + 'concat_space' => ['spacing' => 'one'], 'curly_braces_position' => [ 'classes_opening_brace' => 'same_line', 'functions_opening_brace' => 'same_line', @@ -56,6 +57,7 @@ public function getRules() : array { 'no_trailing_whitespace_in_comment' => true, 'no_unused_imports' => true, 'nullable_type_declaration_for_default_null_value' => true, + 'nullable_type_declaration' => ['syntax' => 'question_mark'], 'ordered_imports' => [ 'imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'alpha' From 56b57803d127dfa75cebeb7651377083a0dee21a Mon Sep 17 00:00:00 2001 From: provokateurin Date: Wed, 18 Sep 2024 17:43:50 +0200 Subject: [PATCH 6/8] chore(release): v1.3.0 Signed-off-by: provokateurin --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0ca863..f1c17d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,7 @@ # Changelog All notable changes to this project will be documented in this file. -## 1.3.0 - TBA - +## 1.3.0 - 2024-09-18 ### Changed * `trailing_comma_in_multiline`: Add a trailing comma to multline function parameters * `MultilinePromotedPropertiesFixer`: Break promoted properties on multiple lines From acbb837b526bbd604e206fdf11a597ca81a502d7 Mon Sep 17 00:00:00 2001 From: provokateurin Date: Thu, 19 Sep 2024 10:51:49 +0200 Subject: [PATCH 7/8] Revert "feat: Add blank lines before returns and after control statements" This reverts commit abb6d364e5afcc6951d9af0ee8394b85da013b33. Signed-off-by: provokateurin --- CHANGELOG.md | 4 ++++ composer.json | 3 +-- src/Config.php | 3 --- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1c17d5..730ee57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog All notable changes to this project will be documented in this file. +## 1.3.1 - TBA +### Fixed +* Removed misbehaving `ErickSkrauch/blank_line_before_return` and `ErickSkrauch/line_break_after_statements` rules + ## 1.3.0 - 2024-09-18 ### Changed * `trailing_comma_in_multiline`: Add a trailing comma to multline function parameters diff --git a/composer.json b/composer.json index f8ac7ca..f0e2091 100644 --- a/composer.json +++ b/composer.json @@ -5,8 +5,7 @@ "require": { "php": "^7.3|^8.0", "php-cs-fixer/shim": "^3.17", - "kubawerlos/php-cs-fixer-custom-fixers": "^3.22", - "erickskrauch/php-cs-fixer-custom-fixers": "^1.3" + "kubawerlos/php-cs-fixer-custom-fixers": "^3.22" }, "license": "MIT", "authors": [ diff --git a/src/Config.php b/src/Config.php index 9bf8947..8acf85d 100644 --- a/src/Config.php +++ b/src/Config.php @@ -12,7 +12,6 @@ public function __construct($name = 'default') { parent::__construct($name); $this->setIndent("\t"); $this->registerCustomFixers(new PhpCsFixerCustomFixers\Fixers()); - $this->registerCustomFixers(new \ErickSkrauch\PhpCsFixer\Fixers()); } public function getRules() : array { @@ -79,8 +78,6 @@ public function getRules() : array { ], 'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false], PhpCsFixerCustomFixers\Fixer\MultilinePromotedPropertiesFixer::name() => true, - 'ErickSkrauch/blank_line_before_return' => true, - 'ErickSkrauch/line_break_after_statements' => true, ]; } } From 046865f0b91e4ff5784a189a51050857450aad30 Mon Sep 17 00:00:00 2001 From: provokateurin Date: Thu, 19 Sep 2024 10:53:55 +0200 Subject: [PATCH 8/8] chore(release): v1.3.1 Signed-off-by: provokateurin --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 730ee57..62c2a85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # Changelog All notable changes to this project will be documented in this file. -## 1.3.1 - TBA +## 1.3.1 - 2024-09-19 ### Fixed * Removed misbehaving `ErickSkrauch/blank_line_before_return` and `ErickSkrauch/line_break_after_statements` rules