Skip to content

Commit 0f4885a

Browse files
committed
Bleeding edge - OverridingPropertyRule
1 parent 9395ecf commit 0f4885a

File tree

11 files changed

+507
-19
lines changed

11 files changed

+507
-19
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
"nette/neon": "^3.0",
2222
"nette/schema": "^1.0",
2323
"nette/utils": "^3.1.3",
24-
"nikic/php-parser": "4.12.0",
24+
"nikic/php-parser": "dev-master as 4.12.0",
2525
"ondram/ci-detector": "^3.4.0",
26-
"ondrejmirtes/better-reflection": "4.3.64",
26+
"ondrejmirtes/better-reflection": "4.3.65",
2727
"phpstan/php-8-stubs": "^0.1.22",
2828
"phpstan/phpdoc-parser": "^0.5.5",
2929
"react/child-process": "^0.6.1",

composer.lock

Lines changed: 24 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

conf/bleedingEdge.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@ parameters:
2626
finalByPhpDocTag: true
2727
classConstants: true
2828
privateStaticCall: true
29+
overridingProperty: true
2930
stubFiles:
3031
- ../stubs/arrayFunctions.stub

conf/config.level0.neon

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ conditionalTags:
2929
phpstan.rules.rule: %featureToggles.fileWhitespace%
3030
PHPStan\Rules\Properties\UninitializedPropertyRule:
3131
phpstan.rules.rule: %checkUninitializedProperties%
32+
PHPStan\Rules\Properties\OverridingPropertyRule:
33+
phpstan.rules.rule: %featureToggles.overridingProperty%
3234

3335
parametersSchema:
3436
missingClosureNativeReturnCheckObjectTypehint: bool()
@@ -213,6 +215,11 @@ services:
213215
checkClassCaseSensitivity: %checkClassCaseSensitivity%
214216
checkThisOnly: %checkThisOnly%
215217

218+
-
219+
class: PHPStan\Rules\Properties\OverridingPropertyRule
220+
arguments:
221+
checkPhpDocMethodSignatures: %checkPhpDocMethodSignatures%
222+
216223
-
217224
class: PHPStan\Rules\Properties\UninitializedPropertyRule
218225
arguments:

conf/config.neon

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ parameters:
5050
finalByPhpDocTag: false
5151
classConstants: false
5252
privateStaticCall: false
53+
overridingProperty: false
5354
fileExtensions:
5455
- php
5556
checkAlwaysTrueCheckTypeFunctionCall: false
@@ -229,7 +230,8 @@ parametersSchema:
229230
crossCheckInterfaces: bool(),
230231
finalByPhpDocTag: bool(),
231232
classConstants: bool(),
232-
privateStaticCall: bool()
233+
privateStaticCall: bool(),
234+
overridingProperty: bool()
233235
])
234236
fileExtensions: listOf(string())
235237
checkAlwaysTrueCheckTypeFunctionCall: bool()

src/Node/ClassPropertyNode.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ public function isStatic(): bool
9999
return (bool) ($this->flags & Class_::MODIFIER_STATIC);
100100
}
101101

102+
public function isReadOnly(): bool
103+
{
104+
return (bool) ($this->flags & Class_::MODIFIER_READONLY);
105+
}
106+
102107
/**
103108
* @return Identifier|Name|NullableType|UnionType|null
104109
*/

src/Reflection/Php/PhpPropertyReflection.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,15 @@ public function isPublic(): bool
9797
return $this->reflection->isPublic();
9898
}
9999

100+
public function isReadOnly(): bool
101+
{
102+
if (method_exists($this->reflection, 'isReadOnly')) {
103+
return $this->reflection->isReadOnly();
104+
}
105+
106+
return false;
107+
}
108+
100109
public function getReadableType(): Type
101110
{
102111
if ($this->type === null) {
@@ -149,6 +158,11 @@ public function getPhpDocType(): Type
149158
return new MixedType();
150159
}
151160

161+
public function hasNativeType(): bool
162+
{
163+
return $this->nativeType !== null;
164+
}
165+
152166
public function getNativeType(): Type
153167
{
154168
if ($this->finalNativeType === null) {

src/Rules/PhpDoc/IncompatiblePropertyPhpDocTypeRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function processNode(Node $node, Scope $scope): array
4343
$propertyName = $node->getName();
4444
$propertyReflection = $scope->getClassReflection()->getNativeProperty($propertyName);
4545

46-
if (!$propertyReflection->hasPhpDoc()) {
46+
if (!$propertyReflection->hasPhpDocType()) {
4747
return [];
4848
}
4949

0 commit comments

Comments
 (0)