1: | <?php declare(strict_types = 1); |
2: | |
3: | namespace PHPStan\Type\Generic; |
4: | |
5: | use PHPStan\Type\KeyOfType; |
6: | use PHPStan\Type\Traits\UndecidedComparisonCompoundTypeTrait; |
7: | use PHPStan\Type\Type; |
8: | |
9: | |
10: | final class TemplateKeyOfType extends KeyOfType implements TemplateType |
11: | { |
12: | |
13: | |
14: | use TemplateTypeTrait; |
15: | use UndecidedComparisonCompoundTypeTrait; |
16: | |
17: | public function __construct( |
18: | TemplateTypeScope $scope, |
19: | TemplateTypeStrategy $templateTypeStrategy, |
20: | TemplateTypeVariance $templateTypeVariance, |
21: | string $name, |
22: | KeyOfType $bound, |
23: | ) |
24: | { |
25: | parent::__construct($bound->getType()); |
26: | $this->scope = $scope; |
27: | $this->strategy = $templateTypeStrategy; |
28: | $this->variance = $templateTypeVariance; |
29: | $this->name = $name; |
30: | $this->bound = $bound; |
31: | } |
32: | |
33: | protected function getResult(): Type |
34: | { |
35: | $result = $this->getBound()->getResult(); |
36: | |
37: | return TemplateTypeFactory::create( |
38: | $this->getScope(), |
39: | $this->getName(), |
40: | $result, |
41: | $this->getVariance(), |
42: | $this->getStrategy(), |
43: | ); |
44: | } |
45: | |
46: | protected function shouldGeneralizeInferredType(): bool |
47: | { |
48: | return false; |
49: | } |
50: | |
51: | } |
52: | |