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/3] 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/3] 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/3] 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