@@ -37,17 +37,22 @@ protected function setUp(): void
37
37
38
38
/**
39
39
* @dataProvider provideParseData
40
- * @param string $input
41
- * @param TypeNode $expectedType
42
- * @param int $nextTokenType
40
+ * @param string $input
41
+ * @param TypeNode|\Exception $expectedResult
42
+ * @param int $nextTokenType
43
43
*/
44
- public function testParse (string $ input , TypeNode $ expectedType , int $ nextTokenType = Lexer::TOKEN_END ): void
44
+ public function testParse (string $ input , $ expectedResult , int $ nextTokenType = Lexer::TOKEN_END ): void
45
45
{
46
+ if ($ expectedResult instanceof \Exception) {
47
+ $ this ->expectException (get_class ($ expectedResult ));
48
+ $ this ->expectExceptionMessage ($ expectedResult ->getMessage ());
49
+ }
50
+
46
51
$ tokens = new TokenIterator ($ this ->lexer ->tokenize ($ input ));
47
52
$ typeNode = $ this ->typeParser ->parse ($ tokens );
48
53
49
- $ this ->assertSame ((string ) $ expectedType , (string ) $ typeNode );
50
- $ this ->assertEquals ($ expectedType , $ typeNode );
54
+ $ this ->assertSame ((string ) $ expectedResult , (string ) $ typeNode );
55
+ $ this ->assertEquals ($ expectedResult , $ typeNode );
51
56
$ this ->assertSame ($ nextTokenType , $ tokens ->currentTokenType ());
52
57
}
53
58
@@ -410,6 +415,24 @@ public function provideParseData(): array
410
415
])
411
416
),
412
417
],
418
+ [
419
+ 'array{ ' ,
420
+ new \PHPStan \PhpDocParser \Parser \ParserException (
421
+ '' ,
422
+ Lexer::TOKEN_END ,
423
+ 6 ,
424
+ Lexer::TOKEN_IDENTIFIER
425
+ ),
426
+ ],
427
+ [
428
+ 'array{a => int} ' ,
429
+ new \PHPStan \PhpDocParser \Parser \ParserException (
430
+ '=> ' ,
431
+ Lexer::TOKEN_OTHER ,
432
+ 8 ,
433
+ Lexer::TOKEN_CLOSE_CURLY_BRACKET
434
+ ),
435
+ ],
413
436
[
414
437
'callable(): Foo ' ,
415
438
new CallableTypeNode (
0 commit comments