2626use phpDocumentor \Reflection \Types \InterfaceString ;
2727use phpDocumentor \Reflection \Types \Intersection ;
2828use phpDocumentor \Reflection \Types \Iterable_ ;
29+ use phpDocumentor \Reflection \PseudoTypes \List_ ;
2930use phpDocumentor \Reflection \Types \Nullable ;
3031use phpDocumentor \Reflection \Types \Object_ ;
3132use phpDocumentor \Reflection \Types \String_ ;
@@ -110,6 +111,7 @@ final class TypeResolver
110111 'parent ' => Types \Parent_::class,
111112 'iterable ' => Types \Iterable_::class,
112113 'never ' => Types \Never_::class,
114+ 'list ' => PseudoTypes \List_::class,
113115 ];
114116
115117 /**
@@ -521,10 +523,11 @@ private function resolveCollection(ArrayIterator $tokens, Type $classType, Conte
521523 {
522524 $ isArray = ((string ) $ classType === 'array ' );
523525 $ isIterable = ((string ) $ classType === 'iterable ' );
526+ $ isList = ((string ) $ classType === 'list ' );
524527
525528 // allow only "array", "iterable" or class name before "<"
526529 if (
527- !$ isArray && !$ isIterable
530+ !$ isArray && !$ isIterable && ! $ isList
528531 && (!$ classType instanceof Object_ || $ classType ->getFqsen () === null )
529532 ) {
530533 throw new RuntimeException (
@@ -538,7 +541,7 @@ private function resolveCollection(ArrayIterator $tokens, Type $classType, Conte
538541 $ keyType = null ;
539542
540543 $ token = $ tokens ->current ();
541- if ($ token !== null && trim ($ token ) === ', ' ) {
544+ if ($ token !== null && trim ($ token ) === ', ' && ! $ isList ) {
542545 // if we have a comma, then we just parsed the key type, not the value type
543546 $ keyType = $ valueType ;
544547 if ($ isArray ) {
@@ -596,6 +599,10 @@ private function resolveCollection(ArrayIterator $tokens, Type $classType, Conte
596599 return new Iterable_ ($ valueType , $ keyType );
597600 }
598601
602+ if ($ isList ) {
603+ return new List_ ($ valueType );
604+ }
605+
599606 if ($ classType instanceof Object_) {
600607 return $ this ->makeCollectionFromObject ($ classType , $ valueType , $ keyType );
601608 }
0 commit comments