Skip to content

Commit 8888fd4

Browse files
committed
Fix compatibility with PHPStan 0.12
1 parent d53d40e commit 8888fd4

File tree

5 files changed

+95
-2
lines changed

5 files changed

+95
-2
lines changed

src/Reflection/Nette/HtmlMethodReflection.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@
66
use PHPStan\Reflection\ClassReflection;
77
use PHPStan\Reflection\FunctionVariant;
88
use PHPStan\Reflection\MethodReflection;
9+
use PHPStan\TrinaryLogic;
10+
use PHPStan\Type\Generic\TemplateTypeMap;
911
use PHPStan\Type\MixedType;
1012
use PHPStan\Type\ObjectType;
13+
use PHPStan\Type\Type;
14+
use PHPStan\Type\VoidType;
1115

1216
class HtmlMethodReflection implements MethodReflection
1317
{
@@ -46,6 +50,7 @@ public function getVariants(): array
4650
{
4751
return [
4852
new FunctionVariant(
53+
TemplateTypeMap::createEmpty(),
4954
[],
5055
true,
5156
substr($this->name, 0, 3) === 'get' ? new MixedType() : new ObjectType('Nette\Utils\Html')
@@ -68,4 +73,29 @@ public function getName(): string
6873
return $this->name;
6974
}
7075

76+
public function isDeprecated(): TrinaryLogic
77+
{
78+
return TrinaryLogic::createNo();
79+
}
80+
81+
public function getDeprecatedDescription(): ?string
82+
{
83+
return null;
84+
}
85+
86+
public function isFinal(): TrinaryLogic
87+
{
88+
return TrinaryLogic::createNo();
89+
}
90+
91+
public function isInternal(): TrinaryLogic
92+
{
93+
return TrinaryLogic::createNo();
94+
}
95+
96+
public function getThrowType(): ?Type
97+
{
98+
return new VoidType();
99+
}
100+
71101
}

src/Reflection/Nette/HtmlPropertyReflection.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use PHPStan\Reflection\ClassReflection;
66
use PHPStan\Reflection\PropertyReflection;
7+
use PHPStan\TrinaryLogic;
78
use PHPStan\Type\MixedType;
89
use PHPStan\Type\Type;
910

@@ -53,4 +54,19 @@ public function isWritable(): bool
5354
return true;
5455
}
5556

57+
public function isDeprecated(): TrinaryLogic
58+
{
59+
return TrinaryLogic::createNo();
60+
}
61+
62+
public function getDeprecatedDescription(): ?string
63+
{
64+
return null;
65+
}
66+
67+
public function isInternal(): TrinaryLogic
68+
{
69+
return TrinaryLogic::createNo();
70+
}
71+
5672
}

src/Reflection/Nette/NetteObjectEventListenerMethodReflection.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
use PHPStan\Reflection\ClassReflection;
77
use PHPStan\Reflection\FunctionVariant;
88
use PHPStan\Reflection\MethodReflection;
9+
use PHPStan\TrinaryLogic;
10+
use PHPStan\Type\Generic\TemplateTypeMap;
11+
use PHPStan\Type\Type;
912
use PHPStan\Type\VoidType;
1013

1114
class NetteObjectEventListenerMethodReflection implements MethodReflection
@@ -50,6 +53,7 @@ public function getVariants(): array
5053
{
5154
return [
5255
new FunctionVariant(
56+
TemplateTypeMap::createEmpty(),
5357
[],
5458
true,
5559
new VoidType()
@@ -67,4 +71,29 @@ public function isPublic(): bool
6771
return true;
6872
}
6973

74+
public function isDeprecated(): TrinaryLogic
75+
{
76+
return TrinaryLogic::createNo();
77+
}
78+
79+
public function getDeprecatedDescription(): ?string
80+
{
81+
return null;
82+
}
83+
84+
public function isFinal(): TrinaryLogic
85+
{
86+
return TrinaryLogic::createNo();
87+
}
88+
89+
public function isInternal(): TrinaryLogic
90+
{
91+
return TrinaryLogic::createNo();
92+
}
93+
94+
public function getThrowType(): ?Type
95+
{
96+
return null;
97+
}
98+
7099
}

src/Reflection/Nette/NetteObjectPropertyReflection.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use PHPStan\Reflection\ClassReflection;
66
use PHPStan\Reflection\PropertyReflection;
7+
use PHPStan\TrinaryLogic;
78
use PHPStan\Type\Type;
89

910
class NetteObjectPropertyReflection implements PropertyReflection
@@ -56,4 +57,19 @@ public function isWritable(): bool
5657
return true;
5758
}
5859

60+
public function isDeprecated(): TrinaryLogic
61+
{
62+
return TrinaryLogic::createNo();
63+
}
64+
65+
public function getDeprecatedDescription(): ?string
66+
{
67+
return null;
68+
}
69+
70+
public function isInternal(): TrinaryLogic
71+
{
72+
return TrinaryLogic::createNo();
73+
}
74+
5975
}

tests/Type/Nette/FormContainerValuesDynamicReturnTypeExtensionTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use PHPStan\Reflection\MethodReflection;
1111
use PHPStan\Type\ArrayType;
1212
use PHPStan\Type\Constant\ConstantBooleanType;
13+
use PHPStan\Type\Generic\TemplateTypeMap;
1314
use PHPStan\Type\IterableType;
1415
use PHPStan\Type\MixedType;
1516
use PHPStan\Type\ObjectType;
@@ -33,6 +34,7 @@ public function testParameterAsArray(): void
3334
$methodReflection
3435
->method('getVariants')
3536
->willReturn([new FunctionVariant(
37+
TemplateTypeMap::createEmpty(),
3638
[],
3739
true,
3840
new UnionType([new ArrayType(new MixedType(), new MixedType()), new IterableType(new MixedType(), new ObjectType(\Nette\Utils\ArrayHash::class))])
@@ -62,7 +64,7 @@ public function testParameterAsArrayHash(): void
6264
$methodReflection = $this->createMock(MethodReflection::class);
6365
$methodReflection
6466
->method('getVariants')
65-
->willReturn([new FunctionVariant([], true, new UnionType([new ArrayType(new MixedType(), new MixedType()), new IterableType(new MixedType(), new ObjectType(\Nette\Utils\ArrayHash::class))]))]);
67+
->willReturn([new FunctionVariant(TemplateTypeMap::createEmpty(), [], true, new UnionType([new ArrayType(new MixedType(), new MixedType()), new IterableType(new MixedType(), new ObjectType(\Nette\Utils\ArrayHash::class))]))]);
6668

6769
$scope = $this->createMock(Scope::class);
6870
$scope->method('getType')->willReturn(new ConstantBooleanType(false));
@@ -89,7 +91,7 @@ public function testDefaultParameterIsArrayHash(): void
8991
$methodReflection = $this->createMock(MethodReflection::class);
9092
$methodReflection
9193
->method('getVariants')
92-
->willReturn([new FunctionVariant([], true, new UnionType([new ArrayType(new MixedType(), new MixedType()), new IterableType(new MixedType(), new ObjectType(\Nette\Utils\ArrayHash::class))]))]);
94+
->willReturn([new FunctionVariant(TemplateTypeMap::createEmpty(), [], true, new UnionType([new ArrayType(new MixedType(), new MixedType()), new IterableType(new MixedType(), new ObjectType(\Nette\Utils\ArrayHash::class))]))]);
9395

9496
$scope = $this->createMock(Scope::class);
9597
$scope->method('getType')->willReturn(new ConstantBooleanType(false));

0 commit comments

Comments
 (0)