1616use phpDocumentor \Reflection \PseudoTypes \List_ ;
1717use phpDocumentor \Reflection \PseudoTypes \NonEmptyList ;
1818use phpDocumentor \Reflection \Types \Array_ ;
19- use phpDocumentor \Reflection \Types \Collection ;
2019use phpDocumentor \Reflection \Types \Compound ;
2120use phpDocumentor \Reflection \Types \Context ;
2221use phpDocumentor \Reflection \Types \Float_ ;
22+ use phpDocumentor \Reflection \Types \GenericType ;
2323use phpDocumentor \Reflection \Types \Integer ;
2424use phpDocumentor \Reflection \Types \Nullable ;
2525use phpDocumentor \Reflection \Types \Object_ ;
@@ -36,7 +36,7 @@ class CollectionResolverTest extends TestCase
3636 /**
3737 * @uses \phpDocumentor\Reflection\Types\Context
3838 * @uses \phpDocumentor\Reflection\Types\Compound
39- * @uses \phpDocumentor\Reflection\Types\Collection
39+ * @uses \phpDocumentor\Reflection\Types\GenericType
4040 * @uses \phpDocumentor\Reflection\Types\String_
4141 *
4242 * @covers ::resolve
@@ -49,23 +49,16 @@ public function testResolvingCollection(): void
4949
5050 $ resolvedType = $ fixture ->resolve ('ArrayObject<string> ' , new Context ('' ));
5151
52- $ this ->assertInstanceOf (Collection ::class, $ resolvedType );
52+ $ this ->assertInstanceOf (GenericType ::class, $ resolvedType );
5353 $ this ->assertSame ('\\ArrayObject<string> ' , (string ) $ resolvedType );
54-
55- $ this ->assertEquals ('\\ArrayObject ' , (string ) $ resolvedType ->getFqsen ());
56-
57- $ valueType = $ resolvedType ->getValueType ();
58-
59- $ keyType = $ resolvedType ->getKeyType ();
60-
61- $ this ->assertInstanceOf (String_::class, $ valueType );
62- $ this ->assertInstanceOf (Compound::class, $ keyType );
54+ $ this ->assertSame ('\\ArrayObject ' , (string ) $ resolvedType ->getFqsen ());
55+ $ this ->assertEquals ([new String_ ()], $ resolvedType ->getTypes ());
6356 }
6457
6558 /**
6659 * @uses \phpDocumentor\Reflection\Types\Context
6760 * @uses \phpDocumentor\Reflection\Types\Compound
68- * @uses \phpDocumentor\Reflection\Types\Collection
61+ * @uses \phpDocumentor\Reflection\Types\GenericType
6962 * @uses \phpDocumentor\Reflection\Types\String_
7063 *
7164 * @covers ::__construct
@@ -78,25 +71,22 @@ public function testResolvingCollectionWithKeyType(): void
7871
7972 $ resolvedType = $ fixture ->resolve ('ArrayObject<string[],Iterator> ' , new Context ('' ));
8073
81- $ this ->assertInstanceOf (Collection::class, $ resolvedType );
82- $ this ->assertSame ('\\ArrayObject<string[], \\Iterator> ' , (string ) $ resolvedType );
74+ $ this ->assertInstanceOf (GenericType::class, $ resolvedType );
75+ $ this ->assertSame ('\\ArrayObject<string[], \\Iterator> ' , (string ) $ resolvedType );
76+ $ this ->assertSame ('\\ArrayObject ' , (string ) $ resolvedType ->getFqsen ());
8377
84- $ this -> assertEquals ( '\\ ArrayObject ' , ( string ) $ resolvedType ->getFqsen () );
78+ $ types = $ resolvedType ->getTypes ( );
8579
86- $ valueType = $ resolvedType ->getValueType ();
87-
88- $ keyType = $ resolvedType ->getKeyType ();
89-
90- $ this ->assertInstanceOf (Object_::class, $ valueType );
91- $ this ->assertEquals ('\\Iterator ' , (string ) $ valueType ->getFqsen ());
92- $ this ->assertInstanceOf (Array_::class, $ keyType );
93- $ this ->assertInstanceOf (String_::class, $ keyType ->getValueType ());
80+ $ this ->assertArrayHasKey (0 , $ types );
81+ $ this ->assertEquals (new Array_ (new String_ ()), $ types [0 ]);
82+ $ this ->assertArrayHasKey (1 , $ types );
83+ $ this ->assertInstanceOf (Object_::class, $ types [1 ]);
84+ $ this ->assertSame ('\\Iterator ' , (string ) $ types [1 ]->getFqsen ());
9485 }
9586
9687 /**
9788 * @uses \phpDocumentor\Reflection\Types\Context
9889 * @uses \phpDocumentor\Reflection\Types\Compound
99- * @uses \phpDocumentor\Reflection\Types\Collection
10090 * @uses \phpDocumentor\Reflection\Types\String_
10191 *
10292 * @covers ::__construct
@@ -123,7 +113,6 @@ public function testResolvingArrayCollection(): void
123113 /**
124114 * @uses \phpDocumentor\Reflection\Types\Context
125115 * @uses \phpDocumentor\Reflection\Types\Compound
126- * @uses \phpDocumentor\Reflection\Types\Collection
127116 * @uses \phpDocumentor\Reflection\Types\String_
128117 *
129118 * @covers ::__construct
@@ -150,7 +139,6 @@ public function testResolvingArrayCollectionWithKey(): void
150139 /**
151140 * @uses \phpDocumentor\Reflection\Types\Context
152141 * @uses \phpDocumentor\Reflection\Types\Compound
153- * @uses \phpDocumentor\Reflection\Types\Collection
154142 * @uses \phpDocumentor\Reflection\Types\String_
155143
156144 * @covers ::__construct
@@ -177,7 +165,7 @@ public function testResolvingArrayCollectionWithKeyAndWhitespace(): void
177165 /**
178166 * @uses \phpDocumentor\Reflection\Types\Context
179167 * @uses \phpDocumentor\Reflection\Types\Compound
180- * @uses \phpDocumentor\Reflection\Types\Collection
168+ * @uses \phpDocumentor\Reflection\Types\GenericType
181169 * @uses \phpDocumentor\Reflection\Types\String_
182170 *
183171 * @covers ::__construct
@@ -190,25 +178,22 @@ public function testResolvingCollectionOfCollection(): void
190178
191179 $ resolvedType = $ fixture ->resolve ('ArrayObject<string|integer|double,ArrayObject<DateTime>> ' , new Context ('' ));
192180
193- $ this ->assertInstanceOf (Collection::class, $ resolvedType );
194- $ this ->assertSame ('\\ArrayObject<string|int|float, \\ArrayObject< \\DateTime>> ' , (string ) $ resolvedType );
181+ $ this ->assertInstanceOf (GenericType::class, $ resolvedType );
182+ $ this ->assertSame ('\\ArrayObject<string|int|float, \\ArrayObject< \\DateTime>> ' , (string ) $ resolvedType );
183+ $ this ->assertSame ('\\ArrayObject ' , (string ) $ resolvedType ->getFqsen ());
195184
196- $ this -> assertEquals ( '\\ ArrayObject ' , ( string ) $ resolvedType ->getFqsen () );
185+ $ types = $ resolvedType ->getTypes ( );
197186
198- $ valueType = $ resolvedType ->getValueType ();
199- $ this ->assertInstanceOf (Collection::class, $ valueType );
200- $ collectionValueType = $ valueType ->getValueType ();
187+ $ this ->assertArrayHasKey (0 , $ types );
188+ $ this ->assertEquals (new Compound ([new String_ (), new Integer (), new Float_ ()]), $ types [0 ]);
201189
202- $ this ->assertInstanceOf (Object_::class, $ valueType ->getValueType ());
203- $ this ->assertEquals ('\\ArrayObject ' , (string ) $ valueType ->getFqsen ());
204- $ this ->assertInstanceOf (Object_::class, $ collectionValueType );
205- $ this ->assertEquals ('\\DateTime ' , (string ) $ collectionValueType ->getFqsen ());
190+ $ this ->assertArrayHasKey (0 , $ types );
191+ $ this ->assertInstanceOf (GenericType::class, $ types [1 ]);
192+ $ this ->assertSame ('\\ArrayObject ' , (string ) $ types [1 ]->getFqsen ());
206193
207- $ keyType = $ resolvedType ->getKeyType ();
208- $ this ->assertInstanceOf (Compound::class, $ keyType );
209- $ this ->assertInstanceOf (String_::class, $ keyType ->get (0 ));
210- $ this ->assertInstanceOf (Integer::class, $ keyType ->get (1 ));
211- $ this ->assertInstanceOf (Float_::class, $ keyType ->get (2 ));
194+ $ nestedGenericTypes = $ types [1 ]->getTypes ();
195+ $ this ->assertArrayHasKey (0 , $ nestedGenericTypes );
196+ $ this ->assertEquals (new Object_ (new Fqsen ('\\DateTime ' )), $ nestedGenericTypes [0 ]);
212197 }
213198
214199 /**
@@ -278,15 +263,14 @@ public function testMissingEndCollection(): void
278263 public function testBadCollectionClass (): void
279264 {
280265 $ this ->expectException (RuntimeException::class);
281- $ this ->expectExceptionMessage ('string is not a collection ' );
266+ $ this ->expectExceptionMessage ('string is an unsupported generic ' );
282267 $ fixture = new TypeResolver ();
283268 $ fixture ->resolve ('string<integer> ' , new Context ('' ));
284269 }
285270
286271 /**
287272 * @uses \phpDocumentor\Reflection\Types\Context
288273 * @uses \phpDocumentor\Reflection\Types\Compound
289- * @uses \phpDocumentor\Reflection\Types\Collection
290274 * @uses \phpDocumentor\Reflection\Types\String_
291275 *
292276 * @covers ::__construct
0 commit comments