Skip to content

Commit 520fc08

Browse files
committed
fix
1 parent 0e005ed commit 520fc08

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

rules/Php84/NodeFinder/SetterAndGetterFinder.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use PhpParser\Node\Stmt\Class_;
88
use PhpParser\Node\Stmt\ClassMethod;
99
use Rector\TypeDeclaration\NodeAnalyzer\ClassMethodAndPropertyAnalyzer;
10+
use Rector\ValueObject\MethodName;
1011

1112
final readonly class SetterAndGetterFinder
1213
{
@@ -22,6 +23,16 @@ public function findGetterAndSetterClassMethods(Class_ $class, string $propertyN
2223
{
2324
$classMethods = [];
2425

26+
$constructClassMethod = $class->getMethod(MethodName::CONSTRUCT);
27+
28+
if ($constructClassMethod instanceof ClassMethod) {
29+
foreach ($constructClassMethod->params as $param) {
30+
if ($param->isReadonly()) {
31+
return [];
32+
}
33+
}
34+
}
35+
2536
$getterClassMethod = $this->findGetterClassMethod($class, $propertyName);
2637
if ($getterClassMethod instanceof ClassMethod) {
2738
$classMethods[] = $getterClassMethod;

0 commit comments

Comments
 (0)