1: | <?php declare(strict_types = 1); |
2: | |
3: | namespace PHPStan\Type\Generic; |
4: | |
5: | use PHPStan\TrinaryLogic; |
6: | use PHPStan\Type\MixedType; |
7: | use PHPStan\Type\StrictMixedType; |
8: | use PHPStan\Type\Type; |
9: | |
10: | |
11: | final class TemplateMixedType extends MixedType implements TemplateType |
12: | { |
13: | |
14: | |
15: | use TemplateTypeTrait; |
16: | |
17: | public function __construct( |
18: | TemplateTypeScope $scope, |
19: | TemplateTypeStrategy $templateTypeStrategy, |
20: | TemplateTypeVariance $templateTypeVariance, |
21: | string $name, |
22: | MixedType $bound, |
23: | ) |
24: | { |
25: | parent::__construct(true); |
26: | |
27: | $this->scope = $scope; |
28: | $this->strategy = $templateTypeStrategy; |
29: | $this->variance = $templateTypeVariance; |
30: | $this->name = $name; |
31: | $this->bound = $bound; |
32: | } |
33: | |
34: | public function isSuperTypeOfMixed(MixedType $type): TrinaryLogic |
35: | { |
36: | return $this->isSuperTypeOf($type); |
37: | } |
38: | |
39: | public function isAcceptedBy(Type $acceptingType, bool $strictTypes): TrinaryLogic |
40: | { |
41: | $isSuperType = $this->isSuperTypeOf($acceptingType); |
42: | if ($isSuperType->no()) { |
43: | return $isSuperType; |
44: | } |
45: | return TrinaryLogic::createYes(); |
46: | } |
47: | |
48: | public function toStrictMixedType(): TemplateStrictMixedType |
49: | { |
50: | return new TemplateStrictMixedType( |
51: | $this->scope, |
52: | $this->strategy, |
53: | $this->variance, |
54: | $this->name, |
55: | new StrictMixedType(), |
56: | ); |
57: | } |
58: | |
59: | } |
60: | |