@@ -434,16 +434,7 @@ private function createFromGeneric(GenericTypeNode $type, Context $context): Typ
434434 return new IntegerRange ((string ) $ type ->genericTypes [0 ], (string ) $ type ->genericTypes [1 ]);
435435
436436 case 'iterable ' :
437- return new Iterable_ (
438- ...array_reverse (
439- array_map (
440- function (TypeNode $ genericType ) use ($ context ): Type {
441- return $ this ->createType ($ genericType , $ context );
442- },
443- $ type ->genericTypes
444- )
445- )
446- );
437+ return new Iterable_ (...array_reverse ($ this ->createTypesByTypeNodes ($ type ->genericTypes , $ context )));
447438
448439 case 'key-of ' :
449440 return new KeyOf ($ this ->createType ($ type ->genericTypes [0 ], $ context ));
@@ -452,18 +443,17 @@ function (TypeNode $genericType) use ($context): Type {
452443 return new ValueOf ($ this ->createType ($ type ->genericTypes [0 ], $ context ));
453444
454445 case 'int-mask ' :
455- return new IntMask (
456- ...array_map (
457- function (TypeNode $ genericType ) use ($ context ): Type {
458- return $ this ->createType ($ genericType , $ context );
459- },
460- $ type ->genericTypes
461- )
462- );
446+ return new IntMask (...$ this ->createTypesByTypeNodes ($ type ->genericTypes , $ context ));
463447
464448 case 'int-mask-of ' :
465449 return new IntMaskOf ($ this ->createType ($ type ->genericTypes [0 ], $ context ));
466450
451+ case 'static ' :
452+ return new Static_ (...$ this ->createTypesByTypeNodes ($ type ->genericTypes , $ context ));
453+
454+ case 'self ' :
455+ return new Self_ (...$ this ->createTypesByTypeNodes ($ type ->genericTypes , $ context ));
456+
467457 default :
468458 $ collectionType = $ this ->createType ($ type ->type , $ context );
469459 if ($ collectionType instanceof Object_ === false ) {
@@ -472,14 +462,7 @@ function (TypeNode $genericType) use ($context): Type {
472462
473463 return new Collection (
474464 $ collectionType ->getFqsen (),
475- ...array_reverse (
476- array_map (
477- function (TypeNode $ genericType ) use ($ context ): Type {
478- return $ this ->createType ($ genericType , $ context );
479- },
480- $ type ->genericTypes
481- )
482- )
465+ ...array_reverse ($ this ->createTypesByTypeNodes ($ type ->genericTypes , $ context ))
483466 );
484467 }
485468 }
@@ -645,14 +628,7 @@ private function resolveTypedObject(string $type, ?Context $context = null): Obj
645628 /** @param TypeNode[] $typeNodes */
646629 private function createArray (array $ typeNodes , Context $ context ): Array_
647630 {
648- $ types = array_reverse (
649- array_map (
650- function (TypeNode $ node ) use ($ context ): Type {
651- return $ this ->createType ($ node , $ context );
652- },
653- $ typeNodes
654- )
655- );
631+ $ types = array_reverse ($ this ->createTypesByTypeNodes ($ typeNodes , $ context ));
656632
657633 if (isset ($ types [1 ]) === false ) {
658634 return new Array_ (...$ types );
@@ -727,4 +703,19 @@ private function tryParseRemainingCompoundTypes(TokenIterator $tokenIterator, Co
727703
728704 return $ type ;
729705 }
706+
707+ /**
708+ * @param TypeNode[] $nodes
709+ *
710+ * @return Type[]
711+ */
712+ private function createTypesByTypeNodes (array $ nodes , Context $ context ): array
713+ {
714+ return array_map (
715+ function (TypeNode $ node ) use ($ context ): Type {
716+ return $ this ->createType ($ node , $ context );
717+ },
718+ $ nodes
719+ );
720+ }
730721}
0 commit comments