Skip to content

Commit 805e838

Browse files
rattusczondrejmirtes
authored andcommitted
first try
1 parent 07efcc0 commit 805e838

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

extension.neon

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,8 @@ services:
8686
class: PHPStan\Type\Nette\FormContainerValuesDynamicReturnTypeExtension
8787
tags:
8888
- phpstan.broker.dynamicMethodReturnTypeExtension
89+
90+
-
91+
class: PHPStan\Rule\Nette\PresenterInjectedPropertiesExtension
92+
tags:
93+
- phpstan.properties.readWriteExtension
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace PHPStan\Rule\Nette;
4+
5+
use PHPStan\Reflection\PropertyReflection;
6+
use PHPStan\Rules\Properties\ReadWritePropertiesExtension;
7+
8+
class PresenterInjectedPropertiesExtension implements ReadWritePropertiesExtension
9+
{
10+
11+
public function isAlwaysRead(PropertyReflection $property, string $propertyName): bool
12+
{
13+
return false;
14+
}
15+
16+
public function isAlwaysWritten(PropertyReflection $property, string $propertyName): bool
17+
{
18+
return false;
19+
}
20+
21+
public function isInitialized(PropertyReflection $property, string $propertyName): bool
22+
{
23+
return $property->isPublic() &&
24+
$property->getDeclaringClass()->isSubclassOf('Nette\Application\UI\Presenter') &&
25+
strpos($property->getDocComment() ?? '', '@inject') !== false;
26+
}
27+
28+
}

0 commit comments

Comments
 (0)