From 7ba36a48fe959684381521c93baf57de999731b5 Mon Sep 17 00:00:00 2001 From: Niki Zakariassen Date: Tue, 9 Jan 2024 08:14:53 +0100 Subject: [PATCH] Added rule for alignment of multiline parameters --- composer.json | 3 ++- src/CegoFixer.php | 4 +++- src/CegoRuleSet.php | 17 +++++++++-------- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index 23bb31c..be09942 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,8 @@ ], "require": { "php": "^7.0|^8.0", - "friendsofphp/php-cs-fixer": "^3.5" + "friendsofphp/php-cs-fixer": "^3.5", + "erickskrauch/php-cs-fixer-custom-fixers": "^1.2" }, "autoload": { "psr-4": { diff --git a/src/CegoFixer.php b/src/CegoFixer.php index 0e13cf8..163ae0c 100644 --- a/src/CegoFixer.php +++ b/src/CegoFixer.php @@ -5,6 +5,7 @@ use Traversable; use PhpCsFixer\Finder; use PhpCsFixer\Config; +use ErickSkrauch\PhpCsFixer\Fixers; use PhpCsFixer\Fixer\FixerInterface; class CegoFixer @@ -27,6 +28,7 @@ public static function applyRules(Finder $finder, array $customRules = [], bool ->setHideProgress(false) ->setUsingCache(true) ->registerCustomFixers($customFixers) + ->registerCustomFixers(new Fixers()) ->setRules(array_merge(CegoRuleSet::get(), $customRules)); } -} \ No newline at end of file +} diff --git a/src/CegoRuleSet.php b/src/CegoRuleSet.php index 4496d36..e7fbc88 100644 --- a/src/CegoRuleSet.php +++ b/src/CegoRuleSet.php @@ -31,14 +31,15 @@ public static function get(): array 'single_quote' => true, 'ternary_to_null_coalescing' => true, - 'return_type_declaration' => ['space_before' => 'none'], - 'array_syntax' => ['syntax' => 'short'], - 'no_extra_blank_lines' => ['tokens' => ['extra']], - 'concat_space' => ['spacing' => 'one'], - 'ordered_imports' => ['sort_algorithm' => 'length'], - 'binary_operator_spaces' => ['operators' => ['=>' => 'align_single_space_minimal']], - 'class_attributes_separation' => ['elements' => ['method' => 'one']], - 'blank_line_before_statement' => ['statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try', 'for', 'foreach', 'if', 'switch', 'do', 'while']], + 'return_type_declaration' => ['space_before' => 'none'], + 'array_syntax' => ['syntax' => 'short'], + 'no_extra_blank_lines' => ['tokens' => ['extra']], + 'concat_space' => ['spacing' => 'one'], + 'ordered_imports' => ['sort_algorithm' => 'length'], + 'binary_operator_spaces' => ['operators' => ['=>' => 'align_single_space_minimal']], + 'class_attributes_separation' => ['elements' => ['method' => 'one']], + 'blank_line_before_statement' => ['statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try', 'for', 'foreach', 'if', 'switch', 'do', 'while']], + 'ErickSkrauch/align_multiline_parameters' => ['variables' => true], 'method_argument_space' => [ 'keep_multiple_spaces_after_comma' => false,