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: /**
16: * @param non-empty-string $name
17: */
18: public function __construct(
19: TemplateTypeScope $scope,
20: TemplateTypeStrategy $templateTypeStrategy,
21: TemplateTypeVariance $templateTypeVariance,
22: string $name,
23: BenevolentUnionType $bound,
24: )
25: {
26: parent::__construct($bound->getTypes());
27:
28: $this->scope = $scope;
29: $this->strategy = $templateTypeStrategy;
30: $this->variance = $templateTypeVariance;
31: $this->name = $name;
32: $this->bound = $bound;
33: }
34:
35: /** @param Type[] $types */
36: public function withTypes(array $types): self
37: {
38: return new self(
39: $this->scope,
40: $this->strategy,
41: $this->variance,
42: $this->name,
43: new BenevolentUnionType($types),
44: );
45: }
46:
47: }
48: