@@ -115,7 +115,7 @@ public function resolve($type, Context $context = null)
115
115
}
116
116
117
117
// 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 );
119
119
$ tokenIterator = new \ArrayIterator ($ tokens );
120
120
121
121
return $ this ->parseTypes ($ tokenIterator , $ context , self ::PARSER_IN_COMPOUND );
@@ -198,7 +198,7 @@ private function parseTypes(\ArrayIterator $tokens, Context $context, $parserCon
198
198
199
199
$ tokens ->next ();
200
200
} elseif ($ parserContext === self ::PARSER_IN_COLLECTION_EXPRESSION
201
- && ($ token === '> ' || $ token === ', ' )
201
+ && ($ token === '> ' || trim ( $ token) === ', ' )
202
202
) {
203
203
break ;
204
204
} else {
@@ -407,7 +407,7 @@ private function resolveCollection(\ArrayIterator $tokens, Type $classType, Cont
407
407
$ valueType = $ this ->parseTypes ($ tokens , $ context , self ::PARSER_IN_COLLECTION_EXPRESSION );
408
408
$ keyType = null ;
409
409
410
- if ($ tokens ->current () === ', ' ) {
410
+ if ($ tokens ->current () !== null && trim ( $ tokens -> current ()) === ', ' ) {
411
411
// if we have a comma, then we just parsed the key type, not the value type
412
412
$ keyType = $ valueType ;
413
413
if ($ isArray ) {
0 commit comments