@@ -115,7 +115,7 @@ public function resolve($type, Context $context = null)
115115 }
116116
117117 // split the type string into tokens `|`, `?`, `<`, `>`, `,`, `(`, `)[]`, '<', '>' and type names
118- $ tokens = preg_split ('/\s* ( \\|| \\?|<|>|,| \\(| \\)(?: \\[ \\])+)\s* / ' , $ type , -1 , PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE );
118+ $ tokens = preg_split ('/( \\|| \\?|<|>|, ? | \\(| \\)(?: \\[ \\])+)/ ' , $ type , -1 , PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE );
119119 $ tokenIterator = new \ArrayIterator ($ tokens );
120120
121121 return $ this ->parseTypes ($ tokenIterator , $ context , self ::PARSER_IN_COMPOUND );
@@ -198,7 +198,7 @@ private function parseTypes(\ArrayIterator $tokens, Context $context, $parserCon
198198
199199 $ tokens ->next ();
200200 } elseif ($ parserContext === self ::PARSER_IN_COLLECTION_EXPRESSION
201- && ($ token === '> ' || $ token === ', ' )
201+ && ($ token === '> ' || trim ( $ token) === ', ' )
202202 ) {
203203 break ;
204204 } else {
@@ -407,7 +407,7 @@ private function resolveCollection(\ArrayIterator $tokens, Type $classType, Cont
407407 $ valueType = $ this ->parseTypes ($ tokens , $ context , self ::PARSER_IN_COLLECTION_EXPRESSION );
408408 $ keyType = null ;
409409
410- if ($ tokens ->current () === ', ' ) {
410+ if ($ tokens ->current () !== null && trim ( $ tokens -> current ()) === ', ' ) {
411411 // if we have a comma, then we just parsed the key type, not the value type
412412 $ keyType = $ valueType ;
413413 if ($ isArray ) {
0 commit comments