diff --git a/rules-tests/TypeDeclaration/Rector/Class_/MergeDateTimePropertyTypeDeclarationRector/Fixture/do_not_remove_doc_with_description.php.inc b/rules-tests/TypeDeclaration/Rector/Class_/MergeDateTimePropertyTypeDeclarationRector/Fixture/do_not_remove_doc_with_description.php.inc new file mode 100644 index 00000000000..c8f0c095477 --- /dev/null +++ b/rules-tests/TypeDeclaration/Rector/Class_/MergeDateTimePropertyTypeDeclarationRector/Fixture/do_not_remove_doc_with_description.php.inc @@ -0,0 +1,27 @@ + +----- + diff --git a/rules/TypeDeclaration/Rector/Class_/MergeDateTimePropertyTypeDeclarationRector.php b/rules/TypeDeclaration/Rector/Class_/MergeDateTimePropertyTypeDeclarationRector.php index 9afd3551379..08d6768dfff 100644 --- a/rules/TypeDeclaration/Rector/Class_/MergeDateTimePropertyTypeDeclarationRector.php +++ b/rules/TypeDeclaration/Rector/Class_/MergeDateTimePropertyTypeDeclarationRector.php @@ -99,8 +99,11 @@ public function refactor(Node $node): ?Node ? $this->nodeTypeResolver->getFullyQualifiedClassName($varType) : null; if ($className === 'DateTimeInterface') { - $phpDocInfo->removeByType(VarTagValueNode::class); - $this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($property); + $varTagvalueNode = $phpDocInfo->getVarTagValueNode(); + if ($varTagvalueNode instanceof VarTagValueNode && $varTagvalueNode->description === '') { + $phpDocInfo->removeByType(VarTagValueNode::class); + $this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($property); + } $property->type = new FullyQualified('DateTimeInterface'); $hasChanged = true;