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