From 0083ce7835ae8e37e0036ff1ad29abf7dac46f01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Wer=C5=82os?= Date: Fri, 14 Jan 2022 17:29:50 +0000 Subject: [PATCH] NoSuperfluousPhpdocTagsFixer - fix for reference and splat operator --- .../Phpdoc/NoSuperfluousPhpdocTagsFixer.php | 2 +- .../NoSuperfluousPhpdocTagsFixerTest.php | 98 +++++++++++++++++++ 2 files changed, 99 insertions(+), 1 deletion(-) diff --git a/src/Fixer/Phpdoc/NoSuperfluousPhpdocTagsFixer.php b/src/Fixer/Phpdoc/NoSuperfluousPhpdocTagsFixer.php index 7f919d1fa01..618a2ba9f13 100644 --- a/src/Fixer/Phpdoc/NoSuperfluousPhpdocTagsFixer.php +++ b/src/Fixer/Phpdoc/NoSuperfluousPhpdocTagsFixer.php @@ -416,7 +416,7 @@ private function parseTypeHint(Tokens $tokens, int $index): array private function annotationIsSuperfluous(Annotation $annotation, array $info, array $symbolShortNames): bool { if ('param' === $annotation->getTag()->getName()) { - $regex = '/@param\s+(?:\S|\s(?!\$))++\s\$\S+\s+\S/'; + $regex = '/@param\s+[^\$]+\s(?:\&\s*)?(?:\.{3}\s*)?\$\S+\s+\S/'; } elseif ('var' === $annotation->getTag()->getName()) { $regex = '/@var\s+\S+(\s+\$\S+)?(\s+)(?!\*+\/)([^$\s]+)/'; } else { diff --git a/tests/Fixer/Phpdoc/NoSuperfluousPhpdocTagsFixerTest.php b/tests/Fixer/Phpdoc/NoSuperfluousPhpdocTagsFixerTest.php index ec5c7dec144..4756a6737e0 100644 --- a/tests/Fixer/Phpdoc/NoSuperfluousPhpdocTagsFixerTest.php +++ b/tests/Fixer/Phpdoc/NoSuperfluousPhpdocTagsFixerTest.php @@ -1496,6 +1496,104 @@ final class Bar{} */ class Foo { }', ], + 'remove when used with reference' => [ + ' [ + ' [ + ' [ + ' [ + ' [ + '