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