1: | <?php |
2: | |
3: | declare(strict_types=1); |
4: | |
5: | namespace PHPStan\BetterReflection\Reflection\Adapter; |
6: | |
7: | use ReflectionIntersectionType as CoreReflectionIntersectionType; |
8: | use PHPStan\BetterReflection\Reflection\ReflectionIntersectionType as BetterReflectionIntersectionType; |
9: | use PHPStan\BetterReflection\Reflection\ReflectionNamedType as BetterReflectionNamedType; |
10: | |
11: | use function array_map; |
12: | use function assert; |
13: | |
14: | |
15: | class ReflectionIntersectionType extends CoreReflectionIntersectionType |
16: | { |
17: | private BetterReflectionIntersectionType $betterReflectionType; |
18: | public function __construct(BetterReflectionIntersectionType $betterReflectionType) |
19: | { |
20: | $this->betterReflectionType = $betterReflectionType; |
21: | } |
22: | |
23: | |
24: | public function getTypes(): array |
25: | { |
26: | return array_map(static function (BetterReflectionNamedType $type): ReflectionNamedType { |
27: | $adapterType = ReflectionType::fromType($type); |
28: | assert($adapterType instanceof ReflectionNamedType); |
29: | |
30: | return $adapterType; |
31: | }, $this->betterReflectionType->getTypes()); |
32: | } |
33: | |
34: | |
35: | public function __toString(): string |
36: | { |
37: | return $this->betterReflectionType->__toString(); |
38: | } |
39: | |
40: | public function allowsNull(): bool |
41: | { |
42: | return $this->betterReflectionType->allowsNull(); |
43: | } |
44: | } |
45: | |