From 08e8328a457e9a37baaf699526730dcd4ee73de1 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sat, 24 Oct 2026 11:49:42 +0200 Subject: [PATCH] remove unused DocBlockTagReplacer --- .../NodeAnalyzer/DocBlockTagReplacer.php | 46 ------------------- .../PhpDocInfo/PhpDocInfo/PhpDocInfoTest.php | 19 -------- .../Source/expected-replaced-tag.txt | 5 -- .../PhpDocInfo/PhpDocInfo/Source/test-tag.txt | 5 -- 4 files changed, 75 deletions(-) delete mode 100644 src/NodeTypeResolver/PhpDoc/NodeAnalyzer/DocBlockTagReplacer.php delete mode 100644 tests/BetterPhpDocParser/PhpDocInfo/PhpDocInfo/Source/expected-replaced-tag.txt delete mode 100644 tests/BetterPhpDocParser/PhpDocInfo/PhpDocInfo/Source/test-tag.txt diff --git a/src/NodeTypeResolver/PhpDoc/NodeAnalyzer/DocBlockTagReplacer.php b/src/NodeTypeResolver/PhpDoc/NodeAnalyzer/DocBlockTagReplacer.php deleted file mode 100644 index 0d85c1c1906..00000000000 --- a/src/NodeTypeResolver/PhpDoc/NodeAnalyzer/DocBlockTagReplacer.php +++ /dev/null @@ -1,46 +0,0 @@ -annotationNaming->normalizeName($oldTag); - $newTag = $this->annotationNaming->normalizeName($newTag); - - $phpDocNode = $phpDocInfo->getPhpDocNode(); - foreach ($phpDocNode->children as $key => $phpDocChildNode) { - if (! $phpDocChildNode instanceof PhpDocTagNode) { - continue; - } - - if ($phpDocChildNode->name !== $oldTag) { - continue; - } - - unset($phpDocNode->children[$key]); - $phpDocNode->children[] = new PhpDocTagNode($newTag, new GenericTagValueNode('')); - $hasChanged = true; - } - - return $hasChanged; - } -} diff --git a/tests/BetterPhpDocParser/PhpDocInfo/PhpDocInfo/PhpDocInfoTest.php b/tests/BetterPhpDocParser/PhpDocInfo/PhpDocInfo/PhpDocInfoTest.php index fb93bd9d6fd..37c2587aad0 100644 --- a/tests/BetterPhpDocParser/PhpDocInfo/PhpDocInfo/PhpDocInfoTest.php +++ b/tests/BetterPhpDocParser/PhpDocInfo/PhpDocInfo/PhpDocInfoTest.php @@ -11,7 +11,6 @@ use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo; use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory; use Rector\BetterPhpDocParser\Printer\PhpDocInfoPrinter; -use Rector\NodeTypeResolver\PhpDoc\NodeAnalyzer\DocBlockTagReplacer; use Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocatorProvider\DynamicSourceLocatorProvider; use Rector\StaticTypeMapper\ValueObject\Type\NonExistingObjectType; use Rector\Testing\PHPUnit\AbstractLazyTestCase; @@ -22,8 +21,6 @@ final class PhpDocInfoTest extends AbstractLazyTestCase private PhpDocInfoPrinter $phpDocInfoPrinter; - private DocBlockTagReplacer $docBlockTagReplacer; - protected function setUp(): void { parent::setUp(); @@ -33,7 +30,6 @@ protected function setUp(): void $dynamicSourceLocatorProvider->reset(); $this->phpDocInfoPrinter = $this->make(PhpDocInfoPrinter::class); - $this->docBlockTagReplacer = $this->make(DocBlockTagReplacer::class); $phpDocInfo = $this->createPhpDocInfoFromFile(__DIR__ . '/Source/doc.txt'); $this->assertInstanceOf(PhpDocInfo::class, $phpDocInfo); @@ -59,21 +55,6 @@ public function testGetReturnType(): void $this->assertEquals($nonExistingObjectType, $this->phpDocInfo->getReturnType()); } - public function testReplaceTagByAnother(): void - { - $phpDocInfo = $this->createPhpDocInfoFromFile(__DIR__ . '/Source/test-tag.txt'); - $this->assertInstanceOf(PhpDocInfo::class, $phpDocInfo); - - $this->docBlockTagReplacer->replaceTagByAnother($phpDocInfo, 'test', 'flow'); - - $printedPhpDocInfo = $this->phpDocInfoPrinter->printFormatPreserving($phpDocInfo); - $printedPhpDocInfo = str_replace("\r\n", "\n", $printedPhpDocInfo); - - $fileContent = str_replace("\r\n", "\n", FileSystem::read(__DIR__ . '/Source/expected-replaced-tag.txt')); - - $this->assertSame($fileContent, $printedPhpDocInfo); - } - public function testDoNotAddSpaseWhenAddEmptyString(): void { $this->phpDocInfo->addPhpDocTagNode(new PhpDocTextNode('')); diff --git a/tests/BetterPhpDocParser/PhpDocInfo/PhpDocInfo/Source/expected-replaced-tag.txt b/tests/BetterPhpDocParser/PhpDocInfo/PhpDocInfo/Source/expected-replaced-tag.txt deleted file mode 100644 index 925c0b21795..00000000000 --- a/tests/BetterPhpDocParser/PhpDocInfo/PhpDocInfo/Source/expected-replaced-tag.txt +++ /dev/null @@ -1,5 +0,0 @@ -/** - * Description - * - * @flow - */ \ No newline at end of file diff --git a/tests/BetterPhpDocParser/PhpDocInfo/PhpDocInfo/Source/test-tag.txt b/tests/BetterPhpDocParser/PhpDocInfo/PhpDocInfo/Source/test-tag.txt deleted file mode 100644 index 51abbfb7a2a..00000000000 --- a/tests/BetterPhpDocParser/PhpDocInfo/PhpDocInfo/Source/test-tag.txt +++ /dev/null @@ -1,5 +0,0 @@ -/** - * Description - * - * @test - */ \ No newline at end of file