1: <?php declare(strict_types = 1);
2:
3: namespace PHPStan\Type\Generic;
4:
5: use PHPStan\Turbo\ShadowedByTurboExtension;
6: use PHPStan\Type\Traits\UndecidedComparisonCompoundTypeTrait;
7: use PHPStan\Type\Type;
8:
9: /** @api */
10: #[ShadowedByTurboExtension(implementation: __DIR__ . '/../../../turbo-ext/src/TemplateGenericObjectType.cpp')]
11: final class TemplateGenericObjectType extends GenericObjectType implements TemplateType
12: {
13:
14: use UndecidedComparisonCompoundTypeTrait;
15: /** @use TemplateTypeTrait<GenericObjectType> */
16: use TemplateTypeTrait;
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: GenericObjectType $bound,
27: ?Type $default,
28: )
29: {
30: parent::__construct($bound->getClassName(), $bound->getTypes(), variances: $bound->getVariances());
31:
32: $this->scope = $scope;
33: $this->strategy = $templateTypeStrategy;
34: $this->variance = $templateTypeVariance;
35: $this->name = $name;
36: $this->bound = $bound;
37: $this->default = $default;
38: }
39:
40: protected function recreate(string $className, array $types, ?Type $subtractedType, array $variances = []): GenericObjectType
41: {
42: return new self(
43: $this->scope,
44: $this->strategy,
45: $this->variance,
46: $this->name,
47: $this->getBound(),
48: $this->default,
49: );
50: }
51:
52: }
53: