Skip to content

Commit 233bb15

Browse files
Merge pull request #31 from nextcloud/enh/break-promoted-properties-on-multiline
feat: Add rule for having one promoted property per line in constructor
2 parents bc9c53a + fe1d17f commit 233bb15

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## 1.2.4 - TBA
5+
6+
### Changed
7+
* `trailing_comma_in_multiline`: Add a trailing comma to multline function parameters
8+
* `MultilinePromotedPropertiesFixer`: Break promoted properties on multiple lines
9+
410
## 1.2.3 - 2024-08-23
511
### Changed
612
* `cast_spaces`: No space between cast and variable

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"type": "library",
55
"require": {
66
"php": "^7.3|^8.0",
7-
"php-cs-fixer/shim": "^3.17"
7+
"php-cs-fixer/shim": "^3.17",
8+
"kubawerlos/php-cs-fixer-custom-fixers": "^3.22"
89
},
910
"license": "MIT",
1011
"authors": [

src/Config.php

+4
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
namespace Nextcloud\CodingStandard;
66

77
use PhpCsFixer\Config as Base;
8+
use PhpCsFixerCustomFixers;
89

910
class Config extends Base {
1011
public function __construct($name = 'default') {
1112
parent::__construct($name);
1213
$this->setIndent("\t");
14+
$this->registerCustomFixers(new PhpCsFixerCustomFixers\Fixers());
1315
}
1416

1517
public function getRules() : array {
@@ -67,11 +69,13 @@ public function getRules() : array {
6769
'single_line_after_imports' => true,
6870
'single_quote' => ['strings_containing_single_quote_chars' => false],
6971
'switch_case_space' => true,
72+
'trailing_comma_in_multiline' => ['elements' => ['parameters']],
7073
'types_spaces' => ['space' => 'none', 'space_multiple_catch' => 'none'],
7174
'visibility_required' => [
7275
'elements' => ['property', 'method', 'const']
7376
],
7477
'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false],
78+
PhpCsFixerCustomFixers\Fixer\MultilinePromotedPropertiesFixer::name() => true,
7579
];
7680
}
7781
}

0 commit comments

Comments
 (0)