| 1: | <?php declare(strict_types = 1); | 
| 2: |  | 
| 3: | namespace PHPStan\Type; | 
| 4: |  | 
| 5: | use PHPStan\Type\Generic\TemplateTypeVariance; | 
| 6: | use PHPStan\Type\Traits\LateResolvableTypeTrait; | 
| 7: | use PHPStan\Type\Traits\NonGeneralizableTypeTrait; | 
| 8: | use function sprintf; | 
| 9: |  | 
| 10: |  | 
| 11: | final class ValueOfType implements CompoundType, LateResolvableType | 
| 12: | { | 
| 13: |  | 
| 14: | use LateResolvableTypeTrait; | 
| 15: | use NonGeneralizableTypeTrait; | 
| 16: |  | 
| 17: | public function __construct(private Type $type) | 
| 18: | { | 
| 19: | } | 
| 20: |  | 
| 21: | public function getReferencedClasses(): array | 
| 22: | { | 
| 23: | return $this->type->getReferencedClasses(); | 
| 24: | } | 
| 25: |  | 
| 26: | public function getReferencedTemplateTypes(TemplateTypeVariance $positionVariance): array | 
| 27: | { | 
| 28: | return $this->type->getReferencedTemplateTypes($positionVariance); | 
| 29: | } | 
| 30: |  | 
| 31: | public function equals(Type $type): bool | 
| 32: | { | 
| 33: | return $type instanceof self | 
| 34: | && $this->type->equals($type->type); | 
| 35: | } | 
| 36: |  | 
| 37: | public function describe(VerbosityLevel $level): string | 
| 38: | { | 
| 39: | return sprintf('value-of<%s>', $this->type->describe($level)); | 
| 40: | } | 
| 41: |  | 
| 42: | public function isResolvable(): bool | 
| 43: | { | 
| 44: | return !TypeUtils::containsTemplateType($this->type); | 
| 45: | } | 
| 46: |  | 
| 47: | protected function getResult(): Type | 
| 48: | { | 
| 49: | return $this->type->getIterableValueType(); | 
| 50: | } | 
| 51: |  | 
| 52: |  | 
| 53: |  | 
| 54: |  | 
| 55: | public function traverse(callable $cb): Type | 
| 56: | { | 
| 57: | $type = $cb($this->type); | 
| 58: |  | 
| 59: | if ($this->type === $type) { | 
| 60: | return $this; | 
| 61: | } | 
| 62: |  | 
| 63: | return new ValueOfType($type); | 
| 64: | } | 
| 65: |  | 
| 66: |  | 
| 67: |  | 
| 68: |  | 
| 69: | public static function __set_state(array $properties): Type | 
| 70: | { | 
| 71: | return new self( | 
| 72: | $properties['type'], | 
| 73: | ); | 
| 74: | } | 
| 75: |  | 
| 76: | } | 
| 77: |  |