Skip to content

Commit a6a23b4

Browse files
committed
[DeadCode] Skip pipe operator on RemoveDeadStmtRector
1 parent e80a84d commit a6a23b4

3 files changed

Lines changed: 7 additions & 1 deletion

File tree

rules-tests/DeadCode/Rector/Expression/RemoveDeadStmtRector/Fixture/void-return-functions-with-side-effects.php.inc renamed to rules-tests/DeadCode/Rector/Expression/RemoveDeadStmtRector/Fixture/skip_pipe_operator.php.inc

File renamed without changes.

rules-tests/DeadCode/Rector/Expression/RemoveDeadStmtRector/RemoveDeadStmtRectorTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ final class RemoveDeadStmtRectorTest extends AbstractRectorTestCase
1313
#[DataProvider('provideData')]
1414
public function test(string $filePath): void
1515
{
16+
if (str_ends_with($filePath, 'skip_pipe_operator.php.inc') && PHP_VERSION_ID < 80500) {
17+
$this->markTestSkipped('test contains php 8.5 syntax early before transformation');
18+
}
19+
1620
$this->doTestFile($filePath);
1721
}
1822

rules/DeadCode/NodeManipulator/LivingCodeManipulator.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use PhpParser\Node\Expr\BinaryOp\Coalesce;
1414
use PhpParser\Node\Expr\BinaryOp\LogicalAnd;
1515
use PhpParser\Node\Expr\BinaryOp\LogicalOr;
16+
use PhpParser\Node\Expr\BinaryOp\Pipe;
1617
use PhpParser\Node\Expr\BitwiseNot;
1718
use PhpParser\Node\Expr\BooleanNot;
1819
use PhpParser\Node\Expr\Cast;
@@ -120,7 +121,8 @@ private function isBinaryOpWithoutChange(Expr $expr): bool
120121
$expr instanceof BooleanAnd ||
121122
$expr instanceof LogicalOr ||
122123
$expr instanceof BooleanOr ||
123-
$expr instanceof Coalesce
124+
$expr instanceof Coalesce ||
125+
$expr instanceof Pipe
124126
);
125127
}
126128

0 commit comments

Comments
 (0)