Skip to content

Commit d5c50b3

Browse files
committed
validate array
1 parent e630a6e commit d5c50b3

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

rules/Php85/Rector/StmtsAwareInterface/NestedToPipeOperatorRector.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use PhpParser\Node\Stmt\Expression;
2020
use PhpParser\Node\VariadicPlaceholder;
2121
use Rector\Contract\PhpParser\Node\StmtsAwareInterface;
22+
use Rector\NodeAnalyzer\ExprAnalyzer;
2223
use Rector\Rector\AbstractRector;
2324
use Rector\ValueObject\PhpVersionFeature;
2425
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
@@ -31,6 +32,11 @@
3132
*/
3233
final class NestedToPipeOperatorRector extends AbstractRector implements MinPhpVersionInterface
3334
{
35+
public function __construct(
36+
private ExprAnalyzer $exprAnalyzer
37+
) {
38+
}
39+
3440
public function getRuleDefinition(): RuleDefinition
3541
{
3642
return new RuleDefinition(
@@ -185,12 +191,15 @@ private function findAssignmentChain(array $statements, int $startIndex): ?array
185191

186192
private function isSimpleValue(Expr $expr): bool
187193
{
194+
if ($expr instanceof Array_) {
195+
return ! $this->exprAnalyzer->isDynamicExpr($expr);
196+
}
197+
188198
return $expr instanceof Variable
189199
|| $expr instanceof ConstFetch
190200
|| $expr instanceof String_
191201
|| $expr instanceof Float_
192-
|| $expr instanceof Int_
193-
|| $expr instanceof Array_;
202+
|| $expr instanceof Int_;
194203
}
195204

196205
/**

0 commit comments

Comments
 (0)