From b0a9844a031e89f913d42fd62e9c50fc90be1f07 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Thu, 2 Jul 2026 15:13:24 +0200 Subject: [PATCH] Fix SwitchedTypeAndNameFixer to handle generic types with commas in @param --- .../Commenting/SwitchedTypeAndNameFixer.php | 2 +- .../Fixture/wrong4.php.inc | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 packages/coding-standard/tests/Fixer/Commenting/SwitchedTypeAndNameFixer/Fixture/wrong4.php.inc diff --git a/packages/coding-standard/src/Fixer/Commenting/SwitchedTypeAndNameFixer.php b/packages/coding-standard/src/Fixer/Commenting/SwitchedTypeAndNameFixer.php index 4cb2131ff2..59bd632ff7 100644 --- a/packages/coding-standard/src/Fixer/Commenting/SwitchedTypeAndNameFixer.php +++ b/packages/coding-standard/src/Fixer/Commenting/SwitchedTypeAndNameFixer.php @@ -21,7 +21,7 @@ final class SwitchedTypeAndNameFixer extends AbstractDocBlockFixer /** * @see https://regex101.com/r/4us32A/1 */ - private const string NAME_THEN_TYPE_REGEX = '#@((?:psalm-|phpstan-)?(?:param|var))(\s+)(?\$\w+)(\s+)(?[|\\\\\w\[\]\<\>]+)#'; + private const string NAME_THEN_TYPE_REGEX = '#@((?:psalm-|phpstan-)?(?:param|var))(\s+)(?\$\w+)(\s+)(?(?:[|\\\\\w\[\]]|<[^<>]*>)+)#'; public function getDefinition(): FixerDefinitionInterface { diff --git a/packages/coding-standard/tests/Fixer/Commenting/SwitchedTypeAndNameFixer/Fixture/wrong4.php.inc b/packages/coding-standard/tests/Fixer/Commenting/SwitchedTypeAndNameFixer/Fixture/wrong4.php.inc new file mode 100644 index 0000000000..a86a6ca19a --- /dev/null +++ b/packages/coding-standard/tests/Fixer/Commenting/SwitchedTypeAndNameFixer/Fixture/wrong4.php.inc @@ -0,0 +1,21 @@ + + */ +function test($submittedArray): void +{ +} + +?> +----- + $submittedArray + */ +function test($submittedArray): void +{ +} + +?>