mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-24 03:35:01 +01:00
[DeadCode] Skip shifted variable
This commit is contained in:
parent
9a3afb2fdc
commit
1d4a20d402
@ -121,8 +121,10 @@ PHP
|
||||
foreach ((array) $functionLike->getStmts() as $stmt) {
|
||||
if (! $this->ifManipulator->isIfWithOnlyReturn($stmt)) {
|
||||
// variable modification
|
||||
$modifiedVariableNames += $this->modifiedVariableNamesCollector->collectModifiedVariableNames($stmt);
|
||||
|
||||
$modifiedVariableNames = array_merge(
|
||||
$modifiedVariableNames,
|
||||
$this->modifiedVariableNamesCollector->collectModifiedVariableNames($stmt)
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\DeadCode\Tests\Rector\FunctionLike\RemoveDuplicatedIfReturnRector\Fixture;
|
||||
|
||||
class SkipArrayShiftedValue
|
||||
{
|
||||
public function output(array $rows): void
|
||||
{
|
||||
if (empty($rows)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$widths = [];
|
||||
|
||||
if (mt_rand(0, 100)) {
|
||||
array_shift($rows);
|
||||
}
|
||||
|
||||
if (empty($rows)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user