1: <?php declare(strict_types = 1);
2:
3: namespace PHPStan\Type\Generic;
4:
5: use PHPStan\TrinaryLogic;
6: use PHPStan\Type\Constant\ConstantArrayType;
7: use PHPStan\Type\Traits\UndecidedComparisonCompoundTypeTrait;
8: use PHPStan\Type\Type;
9:
10: /** @api */
11: final class TemplateConstantArrayType extends ConstantArrayType implements TemplateType
12: {
13:
14: /** @use TemplateTypeTrait<ConstantArrayType> */
15: use TemplateTypeTrait;
16: use UndecidedComparisonCompoundTypeTrait;
17:
18: /**
19: * @param non-empty-string $name
20: */
21: public function __construct(
22: TemplateTypeScope $scope,
23: TemplateTypeStrategy $templateTypeStrategy,
24: TemplateTypeVariance $templateTypeVariance,
25: string $name,
26: ConstantArrayType $bound,
27: ?Type $default,
28: )
29: {
30: parent::__construct($bound->getKeyTypes(), $bound->getValueTypes(), $bound->getNextAutoIndexes(), $bound->getOptionalKeys(), $bound->isList());
31: $this->scope = $scope;
32: $this->strategy = $templateTypeStrategy;
33: $this->variance = $templateTypeVariance;
34: $this->name = $name;
35: $this->bound = $bound;
36: $this->default = $default;
37: }
38:
39: protected function recreate(
40: array $keyTypes,
41: array $valueTypes,
42: array $nextAutoIndexes = [0],
43: array $optionalKeys = [],
44: ?TrinaryLogic $isList = null,
45: ): ConstantArrayType
46: {
47: return new self(
48: $this->scope,
49: $this->strategy,
50: $this->variance,
51: $this->name,
52: new ConstantArrayType($keyTypes, $valueTypes, $nextAutoIndexes, $optionalKeys, $isList),
53: $this->default,
54: );
55: }
56:
57: }
58: