From 520829e40510639bce645ed81277b2d4c20be7fc Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Thu, 23 Nov 2023 14:04:05 +0700 Subject: [PATCH] Temporary restore keep comment feature on before @\ with auto import (#5280) * Temporary restore keep comment feature on before @\ with auto import * cs * temporary removed * temporary removed * link --- .../PhpDocParser/DoctrineAnnotationDecorator.php | 13 +++++-------- .../DocBlock/two_routes_with_comment_before.php.inc | 1 - 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/packages/BetterPhpDocParser/PhpDocParser/DoctrineAnnotationDecorator.php b/packages/BetterPhpDocParser/PhpDocParser/DoctrineAnnotationDecorator.php index d73c69fdedf..cf65a792654 100644 --- a/packages/BetterPhpDocParser/PhpDocParser/DoctrineAnnotationDecorator.php +++ b/packages/BetterPhpDocParser/PhpDocParser/DoctrineAnnotationDecorator.php @@ -165,14 +165,11 @@ private function processTextSpacelessInTextNode( return; } - $otherText = Strings::replace($phpDocTextNode->text, self::LONG_ANNOTATION_REGEX, ''); - if (! in_array($otherText, ["\n", ""], true)) { - $phpDocNode->children[$key] = new PhpDocTextNode($otherText); - array_splice($phpDocNode->children, $key + 1, 0, $spacelessPhpDocTagNodes); - } else { - unset($phpDocNode->children[$key]); - array_splice($phpDocNode->children, $key, 0, $spacelessPhpDocTagNodes); - } + // temporary restore keep comment feature to avoid error + // in nested annotation + // @see https://github.com/rectorphp/rector-src/pull/5280#pullrequestreview-1745794426 + unset($phpDocNode->children[$key]); + array_splice($phpDocNode->children, $key, 0, $spacelessPhpDocTagNodes); } private function transformGenericTagValueNodesToDoctrineAnnotationTagValueNodes( diff --git a/tests/Issues/AutoImport/Fixture/DocBlock/two_routes_with_comment_before.php.inc b/tests/Issues/AutoImport/Fixture/DocBlock/two_routes_with_comment_before.php.inc index 04f023bfa37..79eb9320c90 100644 --- a/tests/Issues/AutoImport/Fixture/DocBlock/two_routes_with_comment_before.php.inc +++ b/tests/Issues/AutoImport/Fixture/DocBlock/two_routes_with_comment_before.php.inc @@ -26,7 +26,6 @@ use Symfony\Component\Routing\Annotation\Route; class TwoRoutesWithCommentBefore { /** - * Testsssssssssss * @Route("/first", methods={"GET"}) * @Route("/second", methods={"GET"}) */