Skip to content

Commit

Permalink
[Privatization] Skip with parameter on PrivatizeLocalGetterToProperty…
Browse files Browse the repository at this point in the history
…Rector (#6412)

* [Privatization] Skip with parameter on PrivatizeLocalGetterToPropertyRector

* Fix
  • Loading branch information
samsonasik authored Nov 8, 2024
1 parent 293eb97 commit 1b1807b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Rector\Tests\Privatization\Rector\MethodCall\PrivatizeLocalGetterToPropertyRector\Fixture;

class SkipWithParameter
{
public $a = 'value';

public function run()
{
$var = 'a';
return $this->getSome($var);
}

private function getSome(string $parameter)
{
return (new SkipWithParameter())->$parameter;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ public function refactor(Node $node): ?Node

private function matchLocalPropertyFetchInGetterMethod(ClassMethod $classMethod): ?PropertyFetch
{
if ($classMethod->params !== []) {
return null;
}

$stmts = (array) $classMethod->stmts;
if (count($stmts) !== 1) {
return null;
Expand Down

0 comments on commit 1b1807b

Please sign in to comment.