File tree Expand file tree Collapse file tree 4 files changed +145
-16
lines changed Expand file tree Collapse file tree 4 files changed +145
-16
lines changed Original file line number Diff line number Diff line change @@ -309,7 +309,7 @@ module.exports = {
309
309
nullable = true ;
310
310
this . next ( ) ;
311
311
}
312
- let type = this . read_type ( ) ;
312
+ let type = this . read_types ( ) ;
313
313
if ( nullable && ! type ) {
314
314
this . raiseError (
315
315
"Expecting a type definition combined with nullable operator"
Original file line number Diff line number Diff line change @@ -445,11 +445,13 @@ Program {
445
445
" name" : " prop" ,
446
446
},
447
447
" nullable" : true ,
448
- " type" : TypeReference {
449
- " kind" : " typereference" ,
450
- " name" : " int" ,
451
- " raw" : " int" ,
452
- },
448
+ " type" : Array [
449
+ TypeReference {
450
+ " kind" : " typereference" ,
451
+ " name" : " int" ,
452
+ " raw" : " int" ,
453
+ },
454
+ ],
453
455
" value" : NullKeyword {
454
456
" kind" : " nullkeyword" ,
455
457
" raw" : " null" ,
@@ -504,6 +506,118 @@ Program {
504
506
}
505
507
` ;
506
508
509
+ exports [` Test classes Test class union properties 1` ] = `
510
+ Program {
511
+ " children" : Array [
512
+ Class {
513
+ " body" : Array [
514
+ PropertyStatement {
515
+ " isStatic" : true ,
516
+ " kind" : " propertystatement" ,
517
+ " properties" : Array [
518
+ Property {
519
+ " kind" : " property" ,
520
+ " name" : Identifier {
521
+ " kind" : " identifier" ,
522
+ " name" : " foo" ,
523
+ },
524
+ " nullable" : false ,
525
+ " type" : Array [
526
+ TypeReference {
527
+ " kind" : " typereference" ,
528
+ " name" : " int" ,
529
+ " raw" : " int" ,
530
+ },
531
+ TypeReference {
532
+ " kind" : " typereference" ,
533
+ " name" : " float" ,
534
+ " raw" : " float" ,
535
+ },
536
+ ],
537
+ " value" : null ,
538
+ },
539
+ ],
540
+ " visibility" : " " ,
541
+ },
542
+ PropertyStatement {
543
+ " isStatic" : false ,
544
+ " kind" : " propertystatement" ,
545
+ " properties" : Array [
546
+ Property {
547
+ " kind" : " property" ,
548
+ " name" : Identifier {
549
+ " kind" : " identifier" ,
550
+ " name" : " bar" ,
551
+ },
552
+ " nullable" : true ,
553
+ " type" : Array [
554
+ Name {
555
+ " kind" : " name" ,
556
+ " name" : " Foo" ,
557
+ " resolution" : " uqn" ,
558
+ },
559
+ Name {
560
+ " kind" : " name" ,
561
+ " name" : " Bar" ,
562
+ " resolution" : " uqn" ,
563
+ },
564
+ ],
565
+ " value" : null ,
566
+ },
567
+ ],
568
+ " visibility" : " private" ,
569
+ },
570
+ PropertyStatement {
571
+ " isStatic" : false ,
572
+ " kind" : " propertystatement" ,
573
+ " properties" : Array [
574
+ Property {
575
+ " kind" : " property" ,
576
+ " name" : Identifier {
577
+ " kind" : " identifier" ,
578
+ " name" : " a" ,
579
+ },
580
+ " nullable" : false ,
581
+ " type" : Array [
582
+ Name {
583
+ " kind" : " name" ,
584
+ " name" : " Repo" ,
585
+ " resolution" : " uqn" ,
586
+ },
587
+ TypeReference {
588
+ " kind" : " typereference" ,
589
+ " name" : " string" ,
590
+ " raw" : " string" ,
591
+ },
592
+ Name {
593
+ " kind" : " name" ,
594
+ " name" : " null" ,
595
+ " resolution" : " uqn" ,
596
+ },
597
+ ],
598
+ " value" : null ,
599
+ },
600
+ ],
601
+ " visibility" : " public" ,
602
+ },
603
+ ],
604
+ " extends" : null ,
605
+ " implements" : null ,
606
+ " isAbstract" : false ,
607
+ " isAnonymous" : false ,
608
+ " isFinal" : false ,
609
+ " kind" : " class" ,
610
+ " name" : Identifier {
611
+ " kind" : " identifier" ,
612
+ " name" : " Test" ,
613
+ },
614
+ },
615
+ ],
616
+ " errors" : Array [],
617
+ " kind" : " program" ,
618
+ }
619
+ ` ;
620
+
507
621
exports [` Test classes Test js properties 1` ] = `
508
622
Program {
509
623
" children" : Array [
Original file line number Diff line number Diff line change @@ -303,11 +303,13 @@ Program {
303
303
" name" : " onst" ,
304
304
},
305
305
" nullable" : false ,
306
- " type" : Name {
307
- " kind" : " name" ,
308
- " name" : " foo" ,
309
- " resolution" : " uqn" ,
310
- },
306
+ " type" : Array [
307
+ Name {
308
+ " kind" : " name" ,
309
+ " name" : " foo" ,
310
+ " resolution" : " uqn" ,
311
+ },
312
+ ],
311
313
" value" : null ,
312
314
},
313
315
],
@@ -834,11 +836,13 @@ Program {
834
836
" name" : " mplement" ,
835
837
},
836
838
" nullable" : false ,
837
- " type" : Name {
838
- " kind" : " name" ,
839
- " name" : " bar" ,
840
- " resolution" : " uqn" ,
841
- },
839
+ " type" : Array [
840
+ Name {
841
+ " kind" : " name" ,
842
+ " name" : " bar" ,
843
+ " resolution" : " uqn" ,
844
+ },
845
+ ],
842
846
" value" : null ,
843
847
},
844
848
],
Original file line number Diff line number Diff line change @@ -129,6 +129,17 @@ describe("Test classes", function () {
129
129
) . toMatchSnapshot ( ) ;
130
130
} ) ;
131
131
132
+ it ( "Test class union properties" , function ( ) {
133
+ expect (
134
+ parser . parseEval ( `
135
+ class Test {
136
+ static int|float $foo;
137
+ private ?Foo|Bar $bar;
138
+ public Repo|string|null $a;
139
+ }` )
140
+ ) . toMatchSnapshot ( ) ;
141
+ } ) ;
142
+
132
143
it ( "empty" , function ( ) {
133
144
expect ( parser . parseEval ( "class Foo {}" ) ) . toMatchSnapshot ( ) ;
134
145
} ) ;
You can’t perform that action at this time.
0 commit comments