From 8163ed2b354bd741ee106d370a3e5d4c6b5b7341 Mon Sep 17 00:00:00 2001 From: Kevin Kaniaburka Date: Fri, 25 Nov 2022 11:12:00 +0100 Subject: [PATCH] Group some PHPDoc tags in PhpdocSeparationFixer rule --- ecs.php | 6 ++++++ tests/Annotations.php | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 tests/Annotations.php diff --git a/ecs.php b/ecs.php index 2273332..da937f1 100644 --- a/ecs.php +++ b/ecs.php @@ -39,6 +39,7 @@ use PhpCsFixer\Fixer\Comment\NoEmptyCommentFixer; use PhpCsFixer\Fixer\Comment\NoTrailingWhitespaceInCommentFixer; use PhpCsFixer\Fixer\Comment\SingleLineCommentStyleFixer; +use PhpCsFixer\Fixer\ConfigurableFixerInterface; use PhpCsFixer\Fixer\ConstantNotation\NativeConstantInvocationFixer; use PhpCsFixer\Fixer\ControlStructure\ElseifFixer; use PhpCsFixer\Fixer\ControlStructure\IncludeFixer; @@ -257,5 +258,10 @@ $ecsConfig->ruleWithConfiguration(TrailingCommaInMultilineFixer::class, ['elements' => ['arrays', 'arguments', 'parameters']]); $ecsConfig->ruleWithConfiguration(VisibilityRequiredFixer::class, ['elements' => ['const', 'property', 'method']]); + // ECS 10 issue + if (is_a(PhpdocSeparationFixer::class, ConfigurableFixerInterface::class, true)) { + $ecsConfig->ruleWithConfiguration(PhpdocSeparationFixer::class, ['groups' => [['Given', 'When', 'Then'], ['var', 'phpstan-var', 'psalm-var'], ['return', 'phpstan-return', 'psalm-return'], ['param', 'phpstan-param', 'psalm-param']]]); + } + $ecsConfig->skip([VisibilityRequiredFixer::class => ['*Spec.php']]); }; diff --git a/tests/Annotations.php b/tests/Annotations.php new file mode 100644 index 0000000..db4ce69 --- /dev/null +++ b/tests/Annotations.php @@ -0,0 +1,32 @@ + + * @psalm-return string + */ + public function foo($bar, $baz) + { + /** + * Some comment + * + * @var int $key + * @phpstan-var int $key + * @psalm-var int $key + */ + $key = --$bar; + + return [$key => $baz]; + } +}