From d028b50de85d940568639ba18dc4da12e4df70f7 Mon Sep 17 00:00:00 2001 From: Kei Date: Tue, 27 Aug 2024 08:25:13 +0700 Subject: [PATCH 1/3] friendsofphp/php-cs-fixer v3.63 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index a90481c..2cc88a3 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "homepage": "https://github.com/realodix/relax", "require": { "php": "^7.4 || ^8.0", - "friendsofphp/php-cs-fixer": "^3.61", + "friendsofphp/php-cs-fixer": "^3.63", "kubawerlos/php-cs-fixer-custom-fixers": "^3.21", "symfony/console": "^5.4.41 || ^6.0 || ^7.0" }, From cca79006fa86b3c1e98512d1112adb3aa0eb3ff2 Mon Sep 17 00:00:00 2001 From: Kei Date: Tue, 27 Aug 2024 08:25:38 +0700 Subject: [PATCH 2/3] Update `trailing_comma_in_multiline` --- src/RuleSet/Sets/Relax.php | 3 +-- tests/Fixtures/Ruleset/realodixspec_expected.php | 2 +- tests/Fixtures/Ruleset/relax-commonbox_expected.php | 2 +- tests/Fixtures/Ruleset/relax_expected.php | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/RuleSet/Sets/Relax.php b/src/RuleSet/Sets/Relax.php index 050447f..b0ddc72 100644 --- a/src/RuleSet/Sets/Relax.php +++ b/src/RuleSet/Sets/Relax.php @@ -84,8 +84,7 @@ public function mainRules(): array 'ordered_imports' => ['sort_algorithm' => 'alpha', 'imports_order' => ['class', 'function', 'const']], 'single_import_per_statement' => ['group_to_single_imports' => false], 'space_after_semicolon' => ['remove_in_empty_for_expressions' => true], - // TODO: Add 'match' & 'parameters' when PHP 8.0+ is required - 'trailing_comma_in_multiline' => ['elements' => ['arrays', 'arguments']], + 'trailing_comma_in_multiline' => ['elements' => ['arguments', 'array_destructuring', 'arrays', 'match', 'parameters']], 'unary_operator_spaces' => ['only_dec_inc' => true], 'whitespace_after_comma_in_array' => ['ensure_single_space' => true], 'phpdoc_align' => [ diff --git a/tests/Fixtures/Ruleset/realodixspec_expected.php b/tests/Fixtures/Ruleset/realodixspec_expected.php index ced5a15..ce7684b 100644 --- a/tests/Fixtures/Ruleset/realodixspec_expected.php +++ b/tests/Fixtures/Ruleset/realodixspec_expected.php @@ -53,7 +53,7 @@ class RealodixSpec public function __construct( public int $a, public ?int $b = 3600, // 1 hour... - public string $c = 'Hello World!' + public string $c = 'Hello World!', ) {} /** diff --git a/tests/Fixtures/Ruleset/relax-commonbox_expected.php b/tests/Fixtures/Ruleset/relax-commonbox_expected.php index 6ffb334..2f16a5d 100644 --- a/tests/Fixtures/Ruleset/relax-commonbox_expected.php +++ b/tests/Fixtures/Ruleset/relax-commonbox_expected.php @@ -227,7 +227,7 @@ public function getBar() class SingleLineEmptyBody { public function __construct( - int $ruleSet + int $ruleSet, ) {} public function basic__single_line_empty_body() {} diff --git a/tests/Fixtures/Ruleset/relax_expected.php b/tests/Fixtures/Ruleset/relax_expected.php index 626f19a..0344f6d 100644 --- a/tests/Fixtures/Ruleset/relax_expected.php +++ b/tests/Fixtures/Ruleset/relax_expected.php @@ -821,7 +821,7 @@ function om_ensure_fully_multiline($a = 10, function om_ensure_single_line( $a = 10, $b = 20, - $c = 30 + $c = 30, ) {} sample( 1, From 5a5271c8859ea25e1eec566fed89a31b95c99c81 Mon Sep 17 00:00:00 2001 From: Kei Date: Tue, 27 Aug 2024 08:32:36 +0700 Subject: [PATCH 3/3] Update test --- tests/Fixtures/Ruleset/relax_actual.php | 7 +++++++ tests/Fixtures/Ruleset/relax_expected.php | 11 +++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/Fixtures/Ruleset/relax_actual.php b/tests/Fixtures/Ruleset/relax_actual.php index 655ba09..c51dcf9 100644 --- a/tests/Fixtures/Ruleset/relax_actual.php +++ b/tests/Fixtures/Ruleset/relax_actual.php @@ -793,6 +793,13 @@ public function control_structure__trailing_comma_in_multiline() 2 ]; + // array_destructuring + $a = [11, 2, 3]; + [ + $c, + $d + ] = $a; + // arguments foo( 1, diff --git a/tests/Fixtures/Ruleset/relax_expected.php b/tests/Fixtures/Ruleset/relax_expected.php index 0344f6d..173430f 100644 --- a/tests/Fixtures/Ruleset/relax_expected.php +++ b/tests/Fixtures/Ruleset/relax_expected.php @@ -766,6 +766,13 @@ public function control_structure__trailing_comma_in_multiline() 2, ]; + // array_destructuring + $a = [11, 2, 3]; + [ + $c, + $d, + ] = $a; + // arguments foo( 1, @@ -775,13 +782,13 @@ public function control_structure__trailing_comma_in_multiline() // parameters function foo_trailing_comma_in_multiline( $x, - $y + $y, ) {} // match match (true) { 1 => '1', - 2 => '2' + 2 => '2', }; // after_heredoc in array