@@ -2561,6 +2561,29 @@ describe 'PHP grammar', ->
2561
2561
expect (lines[1 ][3 ]).toEqual value : ' Test' , scopes : [' source.php' , ' comment.block.documentation.phpdoc.php' , ' meta.other.type.phpdoc.php' , ' support.class.php' ]
2562
2562
expect (lines[1 ][4 ]).toEqual value : ' description' , scopes : [' source.php' , ' comment.block.documentation.phpdoc.php' ]
2563
2563
2564
+ it ' should tokenize a single nullable type' , ->
2565
+ lines = grammar .tokenizeLines '''
2566
+ /**
2567
+ *@param ?int description
2568
+ '''
2569
+
2570
+ expect (lines[1 ][1 ]).toEqual value : ' @param' , scopes : [' source.php' , ' comment.block.documentation.phpdoc.php' , ' keyword.other.phpdoc.php' ]
2571
+ expect (lines[1 ][2 ]).toEqual value : ' ' , scopes : [' source.php' , ' comment.block.documentation.phpdoc.php' ]
2572
+ expect (lines[1 ][3 ]).toEqual value : ' ?' , scopes : [' source.php' , ' comment.block.documentation.phpdoc.php' , ' meta.other.type.phpdoc.php' , ' keyword.operator.nullable-type.php' ]
2573
+ expect (lines[1 ][4 ]).toEqual value : ' int' , scopes : [' source.php' , ' comment.block.documentation.phpdoc.php' , ' meta.other.type.phpdoc.php' , ' keyword.other.type.php' ]
2574
+ expect (lines[1 ][5 ]).toEqual value : ' description' , scopes : [' source.php' , ' comment.block.documentation.phpdoc.php' ]
2575
+
2576
+ lines = grammar .tokenizeLines '''
2577
+ /**
2578
+ *@param ?Test description
2579
+ '''
2580
+
2581
+ expect (lines[1 ][1 ]).toEqual value : ' @param' , scopes : [' source.php' , ' comment.block.documentation.phpdoc.php' , ' keyword.other.phpdoc.php' ]
2582
+ expect (lines[1 ][2 ]).toEqual value : ' ' , scopes : [' source.php' , ' comment.block.documentation.phpdoc.php' ]
2583
+ expect (lines[1 ][3 ]).toEqual value : ' ?' , scopes : [' source.php' , ' comment.block.documentation.phpdoc.php' , ' meta.other.type.phpdoc.php' , ' keyword.operator.nullable-type.php' ]
2584
+ expect (lines[1 ][4 ]).toEqual value : ' Test' , scopes : [' source.php' , ' comment.block.documentation.phpdoc.php' , ' meta.other.type.phpdoc.php' , ' support.class.php' ]
2585
+ expect (lines[1 ][5 ]).toEqual value : ' description' , scopes : [' source.php' , ' comment.block.documentation.phpdoc.php' ]
2586
+
2564
2587
it ' should tokenize a single namespaced type' , ->
2565
2588
lines = grammar .tokenizeLines '''
2566
2589
/**
@@ -2588,6 +2611,21 @@ describe 'PHP grammar', ->
2588
2611
expect (lines[1 ][5 ]).toEqual value : ' Class' , scopes : [' source.php' , ' comment.block.documentation.phpdoc.php' , ' meta.other.type.phpdoc.php' , ' support.class.php' ]
2589
2612
expect (lines[1 ][6 ]).toEqual value : ' description' , scopes : [' source.php' , ' comment.block.documentation.phpdoc.php' ]
2590
2613
2614
+ it ' should tokenize multiple nullable types' , ->
2615
+ lines = grammar .tokenizeLines '''
2616
+ /**
2617
+ *@param ?int|?Class description
2618
+ '''
2619
+
2620
+ expect (lines[1 ][1 ]).toEqual value : ' @param' , scopes : [' source.php' , ' comment.block.documentation.phpdoc.php' , ' keyword.other.phpdoc.php' ]
2621
+ expect (lines[1 ][2 ]).toEqual value : ' ' , scopes : [' source.php' , ' comment.block.documentation.phpdoc.php' ]
2622
+ expect (lines[1 ][3 ]).toEqual value : ' ?' , scopes : [' source.php' , ' comment.block.documentation.phpdoc.php' , ' meta.other.type.phpdoc.php' , ' keyword.operator.nullable-type.php' ]
2623
+ expect (lines[1 ][4 ]).toEqual value : ' int' , scopes : [' source.php' , ' comment.block.documentation.phpdoc.php' , ' meta.other.type.phpdoc.php' , ' keyword.other.type.php' ]
2624
+ expect (lines[1 ][5 ]).toEqual value : ' |' , scopes : [' source.php' , ' comment.block.documentation.phpdoc.php' , ' meta.other.type.phpdoc.php' , ' punctuation.separator.delimiter.php' ]
2625
+ expect (lines[1 ][6 ]).toEqual value : ' ?' , scopes : [' source.php' , ' comment.block.documentation.phpdoc.php' , ' meta.other.type.phpdoc.php' , ' keyword.operator.nullable-type.php' ]
2626
+ expect (lines[1 ][7 ]).toEqual value : ' Class' , scopes : [' source.php' , ' comment.block.documentation.phpdoc.php' , ' meta.other.type.phpdoc.php' , ' support.class.php' ]
2627
+ expect (lines[1 ][8 ]).toEqual value : ' description' , scopes : [' source.php' , ' comment.block.documentation.phpdoc.php' ]
2628
+
2591
2629
it ' should tokenize intersection types' , ->
2592
2630
lines = grammar .tokenizeLines '''
2593
2631
/**
0 commit comments