Skip to content

Commit e9e5e9d

Browse files
babeuloulasamizdam
authored andcommitted
Update PHPStan from 0.11 to 0.12 (#11)
* Update PHPStan from 0.11 to 0.12 * Fix PHPunit tests
1 parent bd7928b commit e9e5e9d

File tree

2 files changed

+58
-4
lines changed

2 files changed

+58
-4
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"require": {
88
"php": "~7.1",
99
"myclabs/php-enum": "^1.2",
10-
"phpstan/phpstan": "^0.10|^0.11"
10+
"phpstan/phpstan": "^0.10|^0.11|^0.12"
1111
},
1212
"require-dev": {
1313
"phpunit/phpunit": "^6.0"

src/Reflection/EnumMethodReflection.php

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
use PHPStan\Reflection\ClassReflection;
99
use PHPStan\Reflection\FunctionVariant;
1010
use PHPStan\Reflection\MethodReflection;
11+
use PHPStan\TrinaryLogic;
12+
use PHPStan\Type\Generic\TemplateTypeMap;
1113
use PHPStan\Type\ObjectType;
14+
use PHPStan\Type\Type;
1215

1316
class EnumMethodReflection implements MethodReflection
1417
{
@@ -60,8 +63,59 @@ public function getPrototype(): ClassMemberReflection
6063

6164
public function getVariants(): array
6265
{
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();
66120
}
67121
}

0 commit comments

Comments
 (0)