|
| 1 | +--- src/Ast/PhpDoc/TypeAliasTagValueNode.php |
| 2 | ++++ src/Ast/PhpDoc/TypeAliasTagValueNode.php |
| 3 | +@@ -4,6 +4,7 @@ |
| 4 | + |
| 5 | + use PHPStan\PhpDocParser\Ast\NodeAttributes; |
| 6 | + use PHPStan\PhpDocParser\Ast\Type\TypeNode; |
| 7 | ++use function implode; |
| 8 | + use function trim; |
| 9 | + |
| 10 | + class TypeAliasTagValueNode implements PhpDocTagValueNode |
| 11 | +@@ -15,15 +16,25 @@ |
| 12 | + |
| 13 | + public TypeNode $type; |
| 14 | + |
| 15 | +- public function __construct(string $alias, TypeNode $type) |
| 16 | ++ /** @var TemplateTagValueNode[] */ |
| 17 | ++ public array $templateTypes; |
| 18 | ++ |
| 19 | ++ /** |
| 20 | ++ * @param TemplateTagValueNode[] $templateTypes |
| 21 | ++ */ |
| 22 | ++ public function __construct(string $alias, TypeNode $type, array $templateTypes = []) |
| 23 | + { |
| 24 | + $this->alias = $alias; |
| 25 | + $this->type = $type; |
| 26 | ++ $this->templateTypes = $templateTypes; |
| 27 | + } |
| 28 | + |
| 29 | + public function __toString(): string |
| 30 | + { |
| 31 | +- return trim("{$this->alias} {$this->type}"); |
| 32 | ++ $templateTypes = $this->templateTypes !== [] |
| 33 | ++ ? '<' . implode(', ', $this->templateTypes) . '>' |
| 34 | ++ : ''; |
| 35 | ++ return trim("{$this->alias}{$templateTypes} {$this->type}"); |
| 36 | + } |
| 37 | + |
| 38 | + /** |
| 39 | +@@ -31,7 +42,7 @@ |
| 40 | + */ |
| 41 | + public static function __set_state(array $properties): self |
| 42 | + { |
| 43 | +- $instance = new self($properties['alias'], $properties['type']); |
| 44 | ++ $instance = new self($properties['alias'], $properties['type'], $properties['templateTypes'] ?? []); |
| 45 | + if (isset($properties['attributes'])) { |
| 46 | + foreach ($properties['attributes'] as $key => $value) { |
| 47 | + $instance->setAttribute($key, $value); |
0 commit comments