Skip to content

Commit

Permalink
[Php81] Skip no type param on ReadOnlyPropertyRector (#1365)
Browse files Browse the repository at this point in the history
* [Php81] Skip no type param on ReadOnlyPropertyRector

* fix
  • Loading branch information
samsonasik committed Dec 2, 2021
1 parent 1cbf32d commit cec23b3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

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

final class SkipNoTypeParam
{
/**
* @param mixed $data
*/
public function __construct(
private $data
) {
}

/**
* @return mixed
*/
public function getData()
{
return $this->data;
}
}
4 changes: 4 additions & 0 deletions rules/Php81/Rector/Property/ReadOnlyPropertyRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ private function refactorParam(Param $param): Param | null
return null;
}

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

// promoted property?
if ($this->propertyManipulator->isPropertyChangeableExceptConstructor($param)) {
return null;
Expand Down

0 comments on commit cec23b3

Please sign in to comment.