From 61cb0c6537e646a42cb199cb60dd720616eea7f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=D0=B8=D0=BC=20=D0=A1=D0=BF=D0=B8?= =?UTF-8?q?=D1=80=D0=BA=D0=BE=D0=B2?= Date: Sun, 30 Nov 2025 19:36:58 +0400 Subject: [PATCH] Remove `GenericTemplate` class --- src/PseudoTypes/GenericTemplate.php | 43 ------------------- src/TypeResolver.php | 13 +----- tests/unit/CollectionResolverTest.php | 5 +-- .../unit/PseudoTypes/GenericTemplateTest.php | 35 --------------- tests/unit/PseudoTypes/GenericTest.php | 2 +- 5 files changed, 4 insertions(+), 94 deletions(-) delete mode 100644 src/PseudoTypes/GenericTemplate.php delete mode 100644 tests/unit/PseudoTypes/GenericTemplateTest.php diff --git a/src/PseudoTypes/GenericTemplate.php b/src/PseudoTypes/GenericTemplate.php deleted file mode 100644 index 52ca6086..00000000 --- a/src/PseudoTypes/GenericTemplate.php +++ /dev/null @@ -1,43 +0,0 @@ -resolvedType = $resolvedType; - } - - public function getResolvedType(): Object_ - { - return $this->resolvedType; - } - - public function __toString(): string - { - return (string) $this->resolvedType; - } -} diff --git a/src/TypeResolver.php b/src/TypeResolver.php index 39576a83..7f60de4b 100644 --- a/src/TypeResolver.php +++ b/src/TypeResolver.php @@ -26,7 +26,6 @@ use phpDocumentor\Reflection\PseudoTypes\False_; use phpDocumentor\Reflection\PseudoTypes\FloatValue; use phpDocumentor\Reflection\PseudoTypes\Generic; -use phpDocumentor\Reflection\PseudoTypes\GenericTemplate; use phpDocumentor\Reflection\PseudoTypes\HtmlEscapedString; use phpDocumentor\Reflection\PseudoTypes\IntegerRange; use phpDocumentor\Reflection\PseudoTypes\IntegerValue; @@ -472,17 +471,7 @@ private function createFromGeneric(GenericTypeNode $type, Context $context): Typ throw new RuntimeException(sprintf('%s is an unsupported generic', (string) $mainType)); } - $types = array_map( - function (TypeNode $node) use ($context): Type { - $innerType = $this->createType($node, $context); - if ($innerType instanceof Object_ && $innerType instanceof Generic === false) { - return new GenericTemplate($innerType); - } - - return $innerType; - }, - $type->genericTypes - ); + $types = $this->createTypesByTypeNodes($type->genericTypes, $context); return new Generic($mainType->getFqsen(), $types); } diff --git a/tests/unit/CollectionResolverTest.php b/tests/unit/CollectionResolverTest.php index 7f7db8ab..df1fc68e 100644 --- a/tests/unit/CollectionResolverTest.php +++ b/tests/unit/CollectionResolverTest.php @@ -14,7 +14,6 @@ namespace phpDocumentor\Reflection; use phpDocumentor\Reflection\PseudoTypes\Generic; -use phpDocumentor\Reflection\PseudoTypes\GenericTemplate; use phpDocumentor\Reflection\PseudoTypes\List_; use phpDocumentor\Reflection\PseudoTypes\NonEmptyList; use phpDocumentor\Reflection\Types\Array_; @@ -81,7 +80,7 @@ public function testResolvingCollectionWithKeyType(): void $this->assertArrayHasKey(0, $types); $this->assertEquals(new Array_(new String_()), $types[0]); $this->assertArrayHasKey(1, $types); - $this->assertEquals(new GenericTemplate(new Object_(new Fqsen('\\Iterator'))), $types[1]); + $this->assertEquals(new Object_(new Fqsen('\\Iterator')), $types[1]); } /** @@ -193,7 +192,7 @@ public function testResolvingCollectionOfCollection(): void $nestedGenericTypes = $types[1]->getTypes(); $this->assertArrayHasKey(0, $nestedGenericTypes); - $this->assertEquals(new GenericTemplate(new Object_(new Fqsen('\\DateTime'))), $nestedGenericTypes[0]); + $this->assertEquals(new Object_(new Fqsen('\\DateTime')), $nestedGenericTypes[0]); } /** diff --git a/tests/unit/PseudoTypes/GenericTemplateTest.php b/tests/unit/PseudoTypes/GenericTemplateTest.php deleted file mode 100644 index 6cfb02fb..00000000 --- a/tests/unit/PseudoTypes/GenericTemplateTest.php +++ /dev/null @@ -1,35 +0,0 @@ -assertSame($resolvedType, $type->getResolvedType()); - } - - /** - * @covers ::__toString - */ - public function testToString(): void - { - $type = new GenericTemplate(new Object_(new Fqsen('\\Foo\\SomeClass'))); - $this->assertSame('\\Foo\\SomeClass', (string) $type); - } -} diff --git a/tests/unit/PseudoTypes/GenericTest.php b/tests/unit/PseudoTypes/GenericTest.php index 2da410cf..af7d94c5 100644 --- a/tests/unit/PseudoTypes/GenericTest.php +++ b/tests/unit/PseudoTypes/GenericTest.php @@ -70,7 +70,7 @@ public static function provideToStringData(): array new Generic( new Fqsen('\\MyClass'), [ - new GenericTemplate(new Object_(new Fqsen('\\T'))), + new Object_(new Fqsen('\\T')), new Object_(new Fqsen('\\SomeClassSecond')), new Object_(new Fqsen('\\SomeClassThird')), ]