@@ -195,11 +195,12 @@ private function parseTypes(ArrayIterator $tokens, Context $context, int $parser
195
195
);
196
196
}
197
197
198
- if (!in_array ($ parserContext , [
199
- self ::PARSER_IN_COMPOUND ,
200
- self ::PARSER_IN_ARRAY_EXPRESSION ,
201
- self ::PARSER_IN_COLLECTION_EXPRESSION ,
202
- ], true )
198
+ if (
199
+ !in_array ($ parserContext , [
200
+ self ::PARSER_IN_COMPOUND ,
201
+ self ::PARSER_IN_ARRAY_EXPRESSION ,
202
+ self ::PARSER_IN_COLLECTION_EXPRESSION ,
203
+ ], true )
203
204
) {
204
205
throw new RuntimeException (
205
206
'Unexpected type separator '
@@ -209,11 +210,12 @@ private function parseTypes(ArrayIterator $tokens, Context $context, int $parser
209
210
$ compoundToken = $ token ;
210
211
$ tokens ->next ();
211
212
} elseif ($ token === '? ' ) {
212
- if (!in_array ($ parserContext , [
213
- self ::PARSER_IN_COMPOUND ,
214
- self ::PARSER_IN_ARRAY_EXPRESSION ,
215
- self ::PARSER_IN_COLLECTION_EXPRESSION ,
216
- ], true )
213
+ if (
214
+ !in_array ($ parserContext , [
215
+ self ::PARSER_IN_COMPOUND ,
216
+ self ::PARSER_IN_ARRAY_EXPRESSION ,
217
+ self ::PARSER_IN_COLLECTION_EXPRESSION ,
218
+ ], true )
217
219
) {
218
220
throw new RuntimeException (
219
221
'Unexpected nullable character '
@@ -258,7 +260,8 @@ private function parseTypes(ArrayIterator $tokens, Context $context, int $parser
258
260
}
259
261
260
262
$ tokens ->next ();
261
- } elseif ($ parserContext === self ::PARSER_IN_COLLECTION_EXPRESSION
263
+ } elseif (
264
+ $ parserContext === self ::PARSER_IN_COLLECTION_EXPRESSION
262
265
&& ($ token === '> ' || trim ($ token ) === ', ' )
263
266
) {
264
267
break ;
@@ -333,8 +336,10 @@ private function resolveSingleType(string $type, Context $context): object
333
336
switch (true ) {
334
337
case $ this ->isKeyword ($ type ):
335
338
return $ this ->resolveKeyword ($ type );
339
+
336
340
case $ this ->isFqsen ($ type ):
337
341
return $ this ->resolveTypedObject ($ type );
342
+
338
343
case $ this ->isPartialStructuralElementName ($ type ):
339
344
return $ this ->resolveTypedObject ($ type , $ context );
340
345
@@ -515,8 +520,10 @@ private function resolveCollection(ArrayIterator $tokens, Type $classType, Conte
515
520
$ isIterable = ((string ) $ classType === 'iterable ' );
516
521
517
522
// allow only "array", "iterable" or class name before "<"
518
- if (!$ isArray && !$ isIterable
519
- && (!$ classType instanceof Object_ || $ classType ->getFqsen () === null )) {
523
+ if (
524
+ !$ isArray && !$ isIterable
525
+ && (!$ classType instanceof Object_ || $ classType ->getFqsen () === null )
526
+ ) {
520
527
throw new RuntimeException (
521
528
$ classType . ' is not a collection '
522
529
);
@@ -534,7 +541,8 @@ private function resolveCollection(ArrayIterator $tokens, Type $classType, Conte
534
541
if ($ isArray ) {
535
542
// check the key type for an "array" collection. We allow only
536
543
// strings or integers.
537
- if (!$ keyType instanceof String_ &&
544
+ if (
545
+ !$ keyType instanceof String_ &&
538
546
!$ keyType instanceof Integer &&
539
547
!$ keyType instanceof Compound
540
548
) {
@@ -545,7 +553,8 @@ private function resolveCollection(ArrayIterator $tokens, Type $classType, Conte
545
553
546
554
if ($ keyType instanceof Compound) {
547
555
foreach ($ keyType ->getIterator () as $ item ) {
548
- if (!$ item instanceof String_ &&
556
+ if (
557
+ !$ item instanceof String_ &&
549
558
!$ item instanceof Integer
550
559
) {
551
560
throw new RuntimeException (
0 commit comments