Skip to content

Commit 4287ca3

Browse files
authored
[Php81] Skip no type property on ReadOnlyPropertyRector (#1354)
1 parent 59e9222 commit 4287ca3

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace Rector\Tests\Php81\Rector\Property\ReadOnlyPropertyRector\Fixture;
4+
5+
final class SkipNoType
6+
{
7+
private $name;
8+
9+
public function __construct(string $name)
10+
{
11+
$this->name = $name;
12+
}
13+
14+
public function getName()
15+
{
16+
return $this->name;
17+
}
18+
}

rules/Php81/Rector/Property/ReadOnlyPropertyRector.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ public function refactor(Node $node): ?Node
9393
return null;
9494
}
9595

96+
if ($node->type === null) {
97+
return null;
98+
}
99+
96100
$this->visibilityManipulator->makeReadonly($node);
97101
return $node;
98102
}

0 commit comments

Comments
 (0)