|
8 | 8 | use PHPStan\Reflection\ClassReflection;
|
9 | 9 | use PHPStan\Reflection\FunctionVariant;
|
10 | 10 | use PHPStan\Reflection\MethodReflection;
|
| 11 | +use PHPStan\TrinaryLogic; |
| 12 | +use PHPStan\Type\Generic\TemplateTypeMap; |
11 | 13 | use PHPStan\Type\ObjectType;
|
| 14 | +use PHPStan\Type\Type; |
12 | 15 |
|
13 | 16 | class EnumMethodReflection implements MethodReflection
|
14 | 17 | {
|
@@ -60,8 +63,59 @@ public function getPrototype(): ClassMemberReflection
|
60 | 63 |
|
61 | 64 | public function getVariants(): array
|
62 | 65 | {
|
63 |
| - return [ |
64 |
| - new FunctionVariant([], false, new ObjectType($this->classReflection->getName())), |
65 |
| - ]; |
| 66 | + if (true === (new \ReflectionClass(FunctionVariant::class))->hasMethod('getTemplateTypeMap')) { |
| 67 | + return [ |
| 68 | + new FunctionVariant( |
| 69 | + TemplateTypeMap::createEmpty(), |
| 70 | + TemplateTypeMap::createEmpty(), |
| 71 | + [], |
| 72 | + false, |
| 73 | + new ObjectType($this->classReflection->getName()) |
| 74 | + ), |
| 75 | + ]; |
| 76 | + } else { |
| 77 | + return [ |
| 78 | + new FunctionVariant( |
| 79 | + [], |
| 80 | + false, |
| 81 | + new ObjectType($this->classReflection->getName()) |
| 82 | + ), |
| 83 | + ]; |
| 84 | + } |
| 85 | + } |
| 86 | + |
| 87 | + public function getDocComment(): ?string |
| 88 | + { |
| 89 | + return null; |
| 90 | + } |
| 91 | + |
| 92 | + public function isDeprecated(): TrinaryLogic |
| 93 | + { |
| 94 | + return TrinaryLogic::createNo(); |
| 95 | + } |
| 96 | + |
| 97 | + public function getDeprecatedDescription(): ?string |
| 98 | + { |
| 99 | + return null; |
| 100 | + } |
| 101 | + |
| 102 | + public function isFinal(): TrinaryLogic |
| 103 | + { |
| 104 | + return TrinaryLogic::createNo(); |
| 105 | + } |
| 106 | + |
| 107 | + public function isInternal(): TrinaryLogic |
| 108 | + { |
| 109 | + return TrinaryLogic::createNo(); |
| 110 | + } |
| 111 | + |
| 112 | + public function getThrowType(): ?Type |
| 113 | + { |
| 114 | + return null; |
| 115 | + } |
| 116 | + |
| 117 | + public function hasSideEffects(): TrinaryLogic |
| 118 | + { |
| 119 | + return TrinaryLogic::createNo(); |
66 | 120 | }
|
67 | 121 | }
|
0 commit comments