mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-21 18:00:10 +01:00
[DeadCode] Fix RemoveUnusedPrivatePropertyRector in foreach (#5507)
Co-authored-by: Oliver Nybroe <oliver@worksome.com>
This commit is contained in:
parent
65dfaca287
commit
82208c0730
@ -10,7 +10,6 @@ use PhpParser\Node\Expr\ArrayDimFetch;
|
||||
use PhpParser\Node\Expr\Assign;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use PhpParser\Node\Stmt\Return_;
|
||||
use Rector\Core\Exception\NotImplementedYetException;
|
||||
use Rector\NodeNestingScope\ParentScopeFinder;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\ReadWrite\NodeFinder\NodeUsageFinder;
|
||||
@ -58,10 +57,7 @@ abstract class AbstractReadNodeAnalyzer
|
||||
return $parentParent->var !== $parent;
|
||||
}
|
||||
|
||||
if ($parent instanceof Expression) {
|
||||
return false;
|
||||
}
|
||||
|
||||
throw new NotImplementedYetException();
|
||||
// assume it's used by default
|
||||
return ! $parent instanceof Expression;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\DeadCode\Tests\Rector\Property\RemoveUnusedPrivatePropertyRector\Fixture;
|
||||
|
||||
class RemoveMagicProperty
|
||||
{
|
||||
private $unusedProp;
|
||||
|
||||
public function buildMailData(object $recipient)
|
||||
{
|
||||
$this->mails_to_send[$recipient->email] = "";
|
||||
|
||||
foreach ($this->mails_to_send as $email) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\DeadCode\Tests\Rector\Property\RemoveUnusedPrivatePropertyRector\Fixture;
|
||||
|
||||
class RemoveMagicProperty
|
||||
{
|
||||
public function buildMailData(object $recipient)
|
||||
{
|
||||
$this->mails_to_send[$recipient->email] = "";
|
||||
|
||||
foreach ($this->mails_to_send as $email) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user