Skip to content

Commit

Permalink
[Transform] Skip different method on CallableInMethodCallToVariableRe…
Browse files Browse the repository at this point in the history
…ctor (#2395)

* [Transform] Skip different method on CallableInMethodCallToVariableRector

* [Transform] Skip different method on CallableInMethodCallToVariableRector

* [Transform] Skip different method on CallableInMethodCallToVariableRector

* Fixed 🎉

* cs

* fix code analysis dev
  • Loading branch information
samsonasik authored May 30, 2022
1 parent 7df41da commit 0dc9777
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/code_analysis_no_dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ jobs:
rm phpstan-for-rector.neon
touch phpstan-for-rector.neon
- run: composer install --no-progress --ansi --no-dev
- run: bin/rector list --ansi
- run: |
composer install --ansi
composer install --no-progress --ansi --no-dev
- run: bin/rector list --ansi
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Rector\Tests\Transform\Rector\MethodCall\CallableInMethodCallToVariableRector\Fixture;

use Rector\Tests\Transform\Rector\MethodCall\CallableInMethodCallToVariableRector\Source\DummyCache;

final class SkipDifferentMethod
{
public function run(DummyCache $dummyCache, $someValue)
{
$dummyCache->load('key', function ($someValue) {
$someValue= $someValue + 1000;
return $someValue + 10;
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ public function refactor(Node $node): ?MethodCall
continue;
}

if (! $this->nodeNameResolver->isName(
$node->name,
$singleCallableInMethodCallToVariable->getMethodName()
)) {
continue;
}

$position = $singleCallableInMethodCallToVariable->getArgumentPosition();
if (! isset($node->args[$position])) {
continue;
Expand Down

0 comments on commit 0dc9777

Please sign in to comment.