Skip to content

Commit 742192e

Browse files
Merge pull request #16 from sascha-egerer/feature/phpstan-0-12-compatibility
Add phpstan 0.12 compatibility
2 parents edc496f + 46eaefe commit 742192e

File tree

5 files changed

+92
-8
lines changed

5 files changed

+92
-8
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
/typo3
44
/.idea
55
/index.php
6+
/public

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77
"prefer-stable": true,
88
"require": {
99
"php": "~7.1",
10-
"phpstan/phpstan": "^0.10 || ^0.11",
11-
"typo3/cms-core": "^8.7 || ^9.5 || ^10.0",
12-
"typo3/cms-extbase": "^8.7 || ^9.5 || ^10.0"
10+
"phpstan/phpstan": "^0.12",
11+
"typo3/cms-core": "^8.7 || ^9.5 || ^10.2",
12+
"typo3/cms-extbase": "^8.7 || ^9.5 || ^10.2"
1313
},
1414
"require-dev": {
1515
"consistence/coding-standard": "^3.8",
1616
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.4",
1717
"jakub-onderka/php-parallel-lint": "^1.0",
1818
"phing/phing": "^2.16.0",
19-
"phpstan/phpstan-strict-rules": "^0.11"
19+
"phpstan/phpstan-strict-rules": "^0.12"
2020
},
2121
"suggest": {
2222
"typo3/testing-framework": "Testing framework is used in the bootstrap (src/PhpStanTypo3Bootstrap.php). In most cases you need this package but you may also use your custom bootstrap (e.g. if you use nimut/testing-framework)"
@@ -28,7 +28,7 @@
2828
},
2929
"extra": {
3030
"branch-alias": {
31-
"dev-master": "0.10-dev"
31+
"dev-master": "0.12-dev"
3232
},
3333
"phpstan": {
3434
"includes": ["extension.neon"]

src/Reflection/RepositoryFindByMethodReflection.php

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
use PHPStan\Reflection\ClassReflection;
88
use PHPStan\Reflection\FunctionVariant;
99
use PHPStan\Reflection\MethodReflection;
10+
use PHPStan\TrinaryLogic;
11+
use PHPStan\Type\Generic\TemplateTypeMap;
1012
use PHPStan\Type\ObjectType;
1113
use PHPStan\Type\Type;
1214
use TYPO3\CMS\Core\Utility\ClassNamingUtility;
@@ -80,7 +82,7 @@ public function getParameters(): array
8082
{
8183
$modelReflection = $this->broker->getClass($this->getModelName());
8284

83-
$type = $modelReflection->getNativeProperty($this->getPropertyName())->getType();
85+
$type = $modelReflection->getNativeProperty($this->getPropertyName())->getReadableType();
8486

8587
return [
8688
new RepositoryFindByParameterReflection('arg', $type),
@@ -104,11 +106,48 @@ public function getVariants(): array
104106
{
105107
return [
106108
new FunctionVariant(
109+
TemplateTypeMap::createEmpty(),
110+
null,
107111
$this->getParameters(),
108112
$this->isVariadic(),
109113
$this->getReturnType()
110114
),
111115
];
112116
}
113117

118+
public function getDocComment(): ?string
119+
{
120+
return null;
121+
}
122+
123+
public function isDeprecated(): TrinaryLogic
124+
{
125+
return TrinaryLogic::createNo();
126+
}
127+
128+
public function getDeprecatedDescription(): ?string
129+
{
130+
return null;
131+
}
132+
133+
public function isFinal(): TrinaryLogic
134+
{
135+
return TrinaryLogic::createNo();
136+
}
137+
138+
public function isInternal(): TrinaryLogic
139+
{
140+
return TrinaryLogic::createNo();
141+
}
142+
143+
public function getThrowType(): ?\PHPStan\Type\Type
144+
{
145+
return null;
146+
}
147+
148+
public function hasSideEffects(): TrinaryLogic
149+
{
150+
return TrinaryLogic::createNo();
151+
}
152+
114153
}

src/Reflection/RepositoryFindByParameterReflection.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class RepositoryFindByParameterReflection implements ParameterReflection
1414
/** @var string */
1515
private $name;
1616

17-
/** @var \PHPStan\Type\Type */
17+
/** @var Type */
1818
private $type;
1919

2020
public function __construct(string $name, Type $type)
@@ -53,4 +53,9 @@ public function passedByReference(): PassedByReference
5353
return PassedByReference::createNo();
5454
}
5555

56+
public function getDefaultValue(): ?Type
57+
{
58+
return null;
59+
}
60+
5661
}

src/Reflection/RepositoryFindOneByMethodReflection.php

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
use PHPStan\Reflection\ClassReflection;
88
use PHPStan\Reflection\FunctionVariant;
99
use PHPStan\Reflection\MethodReflection;
10+
use PHPStan\TrinaryLogic;
11+
use PHPStan\Type\Generic\TemplateTypeMap;
1012
use PHPStan\Type\ObjectType;
1113
use PHPStan\Type\Type;
1214
use PHPStan\Type\TypeCombinator;
@@ -80,7 +82,7 @@ public function getParameters(): array
8082
{
8183
$modelReflection = $this->broker->getClass($this->getModelName());
8284

83-
$type = $modelReflection->getNativeProperty($this->getPropertyName())->getType();
85+
$type = $modelReflection->getNativeProperty($this->getPropertyName())->getReadableType();
8486

8587
return [
8688
new RepositoryFindByParameterReflection('arg', $type),
@@ -104,11 +106,48 @@ public function getVariants(): array
104106
{
105107
return [
106108
new FunctionVariant(
109+
TemplateTypeMap::createEmpty(),
110+
null,
107111
$this->getParameters(),
108112
$this->isVariadic(),
109113
$this->getReturnType()
110114
),
111115
];
112116
}
113117

118+
public function getDocComment(): ?string
119+
{
120+
return null;
121+
}
122+
123+
public function isDeprecated(): \PHPStan\TrinaryLogic
124+
{
125+
return TrinaryLogic::createNo();
126+
}
127+
128+
public function getDeprecatedDescription(): ?string
129+
{
130+
return null;
131+
}
132+
133+
public function isFinal(): \PHPStan\TrinaryLogic
134+
{
135+
return TrinaryLogic::createNo();
136+
}
137+
138+
public function isInternal(): \PHPStan\TrinaryLogic
139+
{
140+
return TrinaryLogic::createNo();
141+
}
142+
143+
public function getThrowType(): ?\PHPStan\Type\Type
144+
{
145+
return null;
146+
}
147+
148+
public function hasSideEffects(): \PHPStan\TrinaryLogic
149+
{
150+
return TrinaryLogic::createNo();
151+
}
152+
114153
}

0 commit comments

Comments
 (0)