Skip to content

Commit

Permalink
[Php81] Skip no type property on ReadOnlyPropertyRector (#1354)
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Nov 30, 2021
1 parent 59e9222 commit 4287ca3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Rector\Tests\Php81\Rector\Property\ReadOnlyPropertyRector\Fixture;

final class SkipNoType
{
private $name;

public function __construct(string $name)
{
$this->name = $name;
}

public function getName()
{
return $this->name;
}
}
4 changes: 4 additions & 0 deletions rules/Php81/Rector/Property/ReadOnlyPropertyRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ public function refactor(Node $node): ?Node
return null;
}

if ($node->type === null) {
return null;
}

$this->visibilityManipulator->makeReadonly($node);
return $node;
}
Expand Down

0 comments on commit 4287ca3

Please sign in to comment.