diff --git a/packages/BetterPhpDocParser/PhpDocParser/DoctrineAnnotationDecorator.php b/packages/BetterPhpDocParser/PhpDocParser/DoctrineAnnotationDecorator.php index e9d3c592e48..3e44d8b3117 100644 --- a/packages/BetterPhpDocParser/PhpDocParser/DoctrineAnnotationDecorator.php +++ b/packages/BetterPhpDocParser/PhpDocParser/DoctrineAnnotationDecorator.php @@ -276,7 +276,7 @@ private function transformGenericTagValueNodesToDoctrineAnnotationTagValueNodes( $phpDocNode->children[$key] = $spacelessPhpDocTagNode; // require to reprint the generic - $phpDocNode->children[$key]->setAttribute(PhpDocAttributeKey::IS_AFTER_GENERIC, true); + $phpDocNode->children[$key]->value->setAttribute(PhpDocAttributeKey::ORIG_NODE, null); array_splice($phpDocNode->children, $key + 1, 0, $spacelessPhpDocTagNodes); } diff --git a/packages/BetterPhpDocParser/Printer/PhpDocInfoPrinter.php b/packages/BetterPhpDocParser/Printer/PhpDocInfoPrinter.php index b97e362dbcb..88ef57acd07 100644 --- a/packages/BetterPhpDocParser/Printer/PhpDocInfoPrinter.php +++ b/packages/BetterPhpDocParser/Printer/PhpDocInfoPrinter.php @@ -16,7 +16,6 @@ use PHPStan\PhpDocParser\Ast\PhpDoc\ThrowsTagValueNode; use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode; use PHPStan\PhpDocParser\Lexer\Lexer; -use Rector\BetterPhpDocParser\PhpDoc\SpacelessPhpDocTagNode; use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo; use Rector\BetterPhpDocParser\PhpDocNodeVisitor\ChangedPhpDocNodeVisitor; use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey; @@ -342,11 +341,7 @@ private function correctPreviouslyReprintedFirstNode(int $key, StartAndEnd $star private function shouldReprint(PhpDocChildNode $phpDocChildNode): bool { $this->changedPhpDocNodeTraverser->traverse($phpDocChildNode); - if ($this->changedPhpDocNodeVisitor->hasChanged()) { - return true; - } - - return $phpDocChildNode instanceof SpacelessPhpDocTagNode && $phpDocChildNode->getAttribute(PhpDocAttributeKey::IS_AFTER_GENERIC) === true; + return $this->changedPhpDocNodeVisitor->hasChanged(); } private function standardPrintPhpDocChildNode(PhpDocChildNode $phpDocChildNode): string diff --git a/packages/BetterPhpDocParser/ValueObject/PhpDocAttributeKey.php b/packages/BetterPhpDocParser/ValueObject/PhpDocAttributeKey.php index dd1cdd9be94..42aee9fe0e1 100644 --- a/packages/BetterPhpDocParser/ValueObject/PhpDocAttributeKey.php +++ b/packages/BetterPhpDocParser/ValueObject/PhpDocAttributeKey.php @@ -33,9 +33,4 @@ final class PhpDocAttributeKey * @var string */ public const ORIG_NODE = NativePhpDocAttributeKey::ORIG_NODE; - - /** - * @var string - */ - public const IS_AFTER_GENERIC = 'is_after_generic'; } diff --git a/packages/PhpDocParser/PhpDocParser/PhpDocNodeVisitor/CloningPhpDocNodeVisitor.php b/packages/PhpDocParser/PhpDocParser/PhpDocNodeVisitor/CloningPhpDocNodeVisitor.php index 5d2b64841a9..e51e7e528ec 100644 --- a/packages/PhpDocParser/PhpDocParser/PhpDocNodeVisitor/CloningPhpDocNodeVisitor.php +++ b/packages/PhpDocParser/PhpDocParser/PhpDocNodeVisitor/CloningPhpDocNodeVisitor.php @@ -18,7 +18,11 @@ final class CloningPhpDocNodeVisitor extends AbstractPhpDocNodeVisitor public function enterNode(Node $node): Node { $clonedNode = clone $node; - $clonedNode->setAttribute(PhpDocAttributeKey::ORIG_NODE, $node); + + if (! $clonedNode->hasAttribute(PhpDocAttributeKey::ORIG_NODE)) { + $clonedNode->setAttribute(PhpDocAttributeKey::ORIG_NODE, $node); + } + return $clonedNode; } }