26
26
use phpDocumentor \Reflection \Types \InterfaceString ;
27
27
use phpDocumentor \Reflection \Types \Intersection ;
28
28
use phpDocumentor \Reflection \Types \Iterable_ ;
29
+ use phpDocumentor \Reflection \PseudoTypes \List_ ;
29
30
use phpDocumentor \Reflection \Types \Nullable ;
30
31
use phpDocumentor \Reflection \Types \Object_ ;
31
32
use phpDocumentor \Reflection \Types \String_ ;
@@ -110,6 +111,7 @@ final class TypeResolver
110
111
'parent ' => Types \Parent_::class,
111
112
'iterable ' => Types \Iterable_::class,
112
113
'never ' => Types \Never_::class,
114
+ 'list ' => PseudoTypes \List_::class,
113
115
];
114
116
115
117
/**
@@ -521,10 +523,11 @@ private function resolveCollection(ArrayIterator $tokens, Type $classType, Conte
521
523
{
522
524
$ isArray = ((string ) $ classType === 'array ' );
523
525
$ isIterable = ((string ) $ classType === 'iterable ' );
526
+ $ isList = ((string ) $ classType === 'list ' );
524
527
525
528
// allow only "array", "iterable" or class name before "<"
526
529
if (
527
- !$ isArray && !$ isIterable
530
+ !$ isArray && !$ isIterable && ! $ isList
528
531
&& (!$ classType instanceof Object_ || $ classType ->getFqsen () === null )
529
532
) {
530
533
throw new RuntimeException (
@@ -538,7 +541,7 @@ private function resolveCollection(ArrayIterator $tokens, Type $classType, Conte
538
541
$ keyType = null ;
539
542
540
543
$ token = $ tokens ->current ();
541
- if ($ token !== null && trim ($ token ) === ', ' ) {
544
+ if ($ token !== null && trim ($ token ) === ', ' && ! $ isList ) {
542
545
// if we have a comma, then we just parsed the key type, not the value type
543
546
$ keyType = $ valueType ;
544
547
if ($ isArray ) {
@@ -596,6 +599,10 @@ private function resolveCollection(ArrayIterator $tokens, Type $classType, Conte
596
599
return new Iterable_ ($ valueType , $ keyType );
597
600
}
598
601
602
+ if ($ isList ) {
603
+ return new List_ ($ valueType );
604
+ }
605
+
599
606
if ($ classType instanceof Object_) {
600
607
return $ this ->makeCollectionFromObject ($ classType , $ valueType , $ keyType );
601
608
}
0 commit comments