Skip to content

Commit

Permalink
LocallyCalledStaticMethodToNonStaticRector with method args (#4233)
Browse files Browse the repository at this point in the history
* LocallyCalledStaticMethodToNonStaticRector with method args
* keep method args on refactoring

* LocallyCalledStaticMethodToNonStaticRector with method args
* remove leading whitespaced
  • Loading branch information
toastedghost committed Jun 14, 2023
1 parent 7753562 commit 2694671
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace Rector\Tests\RemovingStatic\Rector\ClassMethod\LocallyCalledStaticMethodToNonStaticRector\Fixture;

class MethodWithArg
{
public function run($arg)
{
self::someStatic($arg);
}

private static function someStatic($arg)
{
}
}

?>
-----
<?php

namespace Rector\Tests\RemovingStatic\Rector\ClassMethod\LocallyCalledStaticMethodToNonStaticRector\Fixture;

class MethodWithArg
{
public function run($arg)
{
$this->someStatic($arg);
}

private function someStatic($arg)
{
}
}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ private function refactorClassMethod(Class_ $class, ClassMethod $classMethod): ?
return null;
}

return new MethodCall(new Variable('this'), $classMethodName);
return new MethodCall(new Variable('this'), $classMethodName, $node->args);
});

// change static calls to non-static ones, but only if in non-static method!!!
Expand Down

0 comments on commit 2694671

Please sign in to comment.