Skip to content

Commit 3500794

Browse files
[CodingStyle] Skip any CallLike with args !== [] on BinaryOpStandaloneAssignsToDirectRector (#7469)
* [CodingStyle] Skip any CallLike with args !== [] on BinaryOpStandaloneAssignsToDirectRector * fix * fix * [ci-review] Rector Rectify * fix --------- Co-authored-by: GitHub Action <[email protected]>
1 parent d0866a8 commit 3500794

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace Rector\Tests\CodingStyle\Rector\ClassMethod\BinaryOpStandaloneAssignsToDirectRector\Fixture;
4+
5+
use CodingStyle\Rector\ClassMethod\BinaryOpStandaloneAssignsToDirectRector\Source\SomeGetter;
6+
7+
final class SkipAnyCallLikeWithArgs
8+
{
9+
public function run(SomeGetter $firstSomeGetter, SomeGetter $secondSomeGetter)
10+
{
11+
$first = $firstSomeGetter::getSome($arg, $arg2, $arg3, $arg4, $arg5, $arg6);
12+
$second = $secondSomeGetter::getSome($arg, $arg2, $arg3, $arg4, $arg5, $arg6);
13+
14+
return $first <=> $second;
15+
}
16+
}

rules/CodingStyle/Rector/ClassMethod/BinaryOpStandaloneAssignsToDirectRector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
use PhpParser\Node;
88
use PhpParser\Node\Expr\Assign;
99
use PhpParser\Node\Expr\BinaryOp;
10+
use PhpParser\Node\Expr\CallLike;
1011
use PhpParser\Node\Expr\Closure;
11-
use PhpParser\Node\Expr\MethodCall;
1212
use PhpParser\Node\Expr\Variable;
1313
use PhpParser\Node\Stmt;
1414
use PhpParser\Node\Stmt\ClassMethod;
@@ -133,7 +133,7 @@ private function matchToVariableAssignExpr(Stmt $stmt): ?VariableAndExprAssign
133133
}
134134

135135
// skip complex cases
136-
if ($assign->expr instanceof MethodCall && $assign->expr->args !== []) {
136+
if ($assign->expr instanceof CallLike && ! $assign->expr->isFirstClassCallable() && $assign->expr->getArgs() !== []) {
137137
return null;
138138
}
139139

0 commit comments

Comments
 (0)