Skip to content

Commit b86bb54

Browse files
committed
skip append
1 parent 6ebbed6 commit b86bb54

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Rector\Tests\DowngradePhp80\Rector\FuncCall\DowngradeSubstrFalsyRector\Fixture;
4+
5+
class SkipAppend
6+
{
7+
public function run(string $a)
8+
{
9+
$a .=substr('a', 2);
10+
11+
return $a;
12+
}
13+
}

rules/DowngradePhp80/Rector/FuncCall/DowngradeSubstrFalsyRector.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use PhpParser\Node;
88
use PhpParser\Node\Arg;
99
use PhpParser\Node\Expr;
10+
use PhpParser\Node\Expr\AssignOp;
1011
use PhpParser\Node\Expr\BinaryOp\Concat;
1112
use PhpParser\Node\Expr\BinaryOp\Identical;
1213
use PhpParser\Node\Expr\BooleanNot;
@@ -69,16 +70,17 @@ public function getNodeTypes(): array
6970
Concat::class,
7071
MethodCall::class,
7172
StaticCall::class,
73+
AssignOp::class,
7274
FuncCall::class,
7375
];
7476
}
7577

7678
/**
77-
* @param Cast|Empty_|BooleanNot|Ternary|Identical|Concat|MethodCall|StaticCall|FuncCall $node
79+
* @param Cast|Empty_|BooleanNot|Ternary|Identical|Concat|MethodCall|StaticCall|AssignOp|FuncCall $node
7880
*/
7981
public function refactor(Node $node): ?Node
8082
{
81-
if ($node instanceof Cast || $node instanceof Empty_ || $node instanceof BooleanNot) {
83+
if ($node instanceof Cast || $node instanceof Empty_ || $node instanceof BooleanNot || $node instanceof AssignOp) {
8284
$node->expr->setAttribute(self::IS_UNCASTABLE, true);
8385
return null;
8486
}

0 commit comments

Comments
 (0)