|
23 | 23 | use phpDocumentor\Reflection\PseudoTypes\ConstExpression; |
24 | 24 | use phpDocumentor\Reflection\PseudoTypes\False_; |
25 | 25 | use phpDocumentor\Reflection\PseudoTypes\FloatValue; |
| 26 | +use phpDocumentor\Reflection\PseudoTypes\Generic; |
| 27 | +use phpDocumentor\Reflection\PseudoTypes\GenericTemplate; |
26 | 28 | use phpDocumentor\Reflection\PseudoTypes\HtmlEscapedString; |
27 | 29 | use phpDocumentor\Reflection\PseudoTypes\IntegerRange; |
28 | 30 | use phpDocumentor\Reflection\PseudoTypes\IntegerValue; |
|
56 | 58 | use phpDocumentor\Reflection\Types\Callable_; |
57 | 59 | use phpDocumentor\Reflection\Types\CallableParameter; |
58 | 60 | use phpDocumentor\Reflection\Types\ClassString; |
59 | | -use phpDocumentor\Reflection\Types\Collection; |
60 | 61 | use phpDocumentor\Reflection\Types\Compound; |
61 | 62 | use phpDocumentor\Reflection\Types\Context; |
62 | 63 | use phpDocumentor\Reflection\Types\Expression; |
@@ -460,15 +461,24 @@ private function createFromGeneric(GenericTypeNode $type, Context $context): Typ |
460 | 461 | return new Self_(...$this->createTypesByTypeNodes($type->genericTypes, $context)); |
461 | 462 |
|
462 | 463 | default: |
463 | | - $collectionType = $this->createType($type->type, $context); |
464 | | - if ($collectionType instanceof Object_ === false) { |
465 | | - throw new RuntimeException(sprintf('%s is not a collection', (string) $collectionType)); |
| 464 | + $mainType = $this->createType($type->type, $context); |
| 465 | + if ($mainType instanceof Object_ === false) { |
| 466 | + throw new RuntimeException(sprintf('%s is an unsupported generic', (string) $mainType)); |
466 | 467 | } |
467 | 468 |
|
468 | | - return new Collection( |
469 | | - $collectionType->getFqsen(), |
470 | | - ...array_reverse($this->createTypesByTypeNodes($type->genericTypes, $context)) |
| 469 | + $types = array_map( |
| 470 | + function (TypeNode $node) use ($context): Type { |
| 471 | + $innerType = $this->createType($node, $context); |
| 472 | + if ($innerType instanceof Object_ && $innerType instanceof Generic === false) { |
| 473 | + return new GenericTemplate($innerType); |
| 474 | + } |
| 475 | + |
| 476 | + return $innerType; |
| 477 | + }, |
| 478 | + $type->genericTypes |
471 | 479 | ); |
| 480 | + |
| 481 | + return new Generic($mainType->getFqsen(), $types); |
472 | 482 | } |
473 | 483 | } |
474 | 484 |
|
|
0 commit comments