1616use Mockery as m ;
1717use phpDocumentor \Reflection \Types \Array_ ;
1818use phpDocumentor \Reflection \Types \Boolean ;
19+ use phpDocumentor \Reflection \Types \ClassString ;
1920use phpDocumentor \Reflection \Types \Compound ;
2021use phpDocumentor \Reflection \Types \Context ;
2122use phpDocumentor \Reflection \Types \Iterable_ ;
@@ -59,6 +60,30 @@ public function testResolvingKeywords(string $keyword, string $expectedClass) :
5960 $ this ->assertInstanceOf ($ expectedClass , $ resolvedType );
6061 }
6162
63+ /**
64+ * @uses \phpDocumentor\Reflection\Types\Context
65+ * @uses \phpDocumentor\Reflection\Types\Object_
66+ * @uses \phpDocumentor\Reflection\Types\String_
67+ *
68+ * @covers ::__construct
69+ * @covers ::resolve
70+ * @covers ::<private>
71+ *
72+ * @dataProvider provideClassStrings
73+ */
74+ public function testResolvingClassStrings (string $ classString , bool $ throwsException ) : void
75+ {
76+ $ fixture = new TypeResolver ();
77+
78+ if ($ throwsException ) {
79+ $ this ->expectException ('RuntimeException ' );
80+ }
81+
82+ $ resolvedType = $ fixture ->resolve ($ classString , new Context ('' ));
83+
84+ $ this ->assertInstanceOf (ClassString::class, $ resolvedType );
85+ }
86+
6287 /**
6388 * @uses \phpDocumentor\Reflection\Types\Context
6489 * @uses \phpDocumentor\Reflection\Types\Object_
@@ -634,6 +659,7 @@ public function provideKeywords() : array
634659 {
635660 return [
636661 ['string ' , Types \String_::class],
662+ ['class-string ' , Types \ClassString::class],
637663 ['int ' , Types \Integer::class],
638664 ['integer ' , Types \Integer::class],
639665 ['float ' , Types \Float_::class],
@@ -657,6 +683,20 @@ public function provideKeywords() : array
657683 ];
658684 }
659685
686+ /**
687+ * Returns a list of class string types and whether they throw an exception.
688+ *
689+ * @return (string|bool)[][]
690+ */
691+ public function provideClassStrings () : array
692+ {
693+ return [
694+ ['class-string<\phpDocumentor\Reflection> ' , false ],
695+ ['class-string<\phpDocumentor\Reflection\DocBlock> ' , false ],
696+ ['class-string<string> ' , true ],
697+ ];
698+ }
699+
660700 /**
661701 * Provides a list of FQSENs to test the resolution patterns with.
662702 *
0 commit comments