1: <?php declare(strict_types = 1);
2:
3: namespace PHPStan\Type\Generic;
4:
5: use PHPStan\Type\BenevolentUnionType;
6: use PHPStan\Type\Type;
7:
8: /** @api */
9: final class TemplateBenevolentUnionType extends BenevolentUnionType implements TemplateType
10: {
11:
12: /** @use TemplateTypeTrait<BenevolentUnionType> */
13: use TemplateTypeTrait;
14:
15: public function __construct(
16: TemplateTypeScope $scope,
17: TemplateTypeStrategy $templateTypeStrategy,
18: TemplateTypeVariance $templateTypeVariance,
19: string $name,
20: BenevolentUnionType $bound,
21: )
22: {
23: parent::__construct($bound->getTypes());
24:
25: $this->scope = $scope;
26: $this->strategy = $templateTypeStrategy;
27: $this->variance = $templateTypeVariance;
28: $this->name = $name;
29: $this->bound = $bound;
30: }
31:
32: /** @param Type[] $types */
33: public function withTypes(array $types): self
34: {
35: return new self(
36: $this->scope,
37: $this->strategy,
38: $this->variance,
39: $this->name,
40: new BenevolentUnionType($types),
41: );
42: }
43:
44: }
45: