Skip to content

Commit 3a3ecce

Browse files
authored
[Php85] Clean up dynamic expr check on NestedToPipeOperatorRector (#7578)
1 parent 09ab43b commit 3a3ecce

File tree

1 file changed

+1
-18
lines changed

1 file changed

+1
-18
lines changed

rules/Php85/Rector/StmtsAwareInterface/NestedToPipeOperatorRector.php

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,8 @@
99
use PhpParser\Node\Expr;
1010
use PhpParser\Node\Expr\Assign;
1111
use PhpParser\Node\Expr\BinaryOp\Pipe;
12-
use PhpParser\Node\Expr\Cast\Array_;
13-
use PhpParser\Node\Expr\Cast\String_;
14-
use PhpParser\Node\Expr\ConstFetch;
1512
use PhpParser\Node\Expr\FuncCall;
1613
use PhpParser\Node\Expr\Variable;
17-
use PhpParser\Node\Scalar\Float_;
18-
use PhpParser\Node\Scalar\Int_;
1914
use PhpParser\Node\Stmt;
2015
use PhpParser\Node\Stmt\Expression;
2116
use PhpParser\Node\VariadicPlaceholder;
@@ -161,7 +156,7 @@ private function findAssignmentChain(array $statements, int $startIndex): ?array
161156
if ($currentIndex === $startIndex) {
162157

163158
// First in chain - must be a variable or simple value
164-
if (! $arg->value instanceof Variable && ! $this->isSimpleValue($arg->value)) {
159+
if (! $arg->value instanceof Variable && ! $this->exprAnalyzer->isDynamicExpr($arg->value)) {
165160
return null;
166161
}
167162

@@ -192,18 +187,6 @@ private function findAssignmentChain(array $statements, int $startIndex): ?array
192187
return $chain;
193188
}
194189

195-
private function isSimpleValue(Expr $expr): bool
196-
{
197-
if ($expr instanceof Array_) {
198-
return ! $this->exprAnalyzer->isDynamicExpr($expr);
199-
}
200-
201-
return $expr instanceof ConstFetch
202-
|| $expr instanceof String_
203-
|| $expr instanceof Float_
204-
|| $expr instanceof Int_;
205-
}
206-
207190
/**
208191
* @param array<int, array{stmt: Stmt, assign: Expr, funcCall: Expr\FuncCall}> $chain
209192
*/

0 commit comments

Comments
 (0)