Skip to content

Commit

Permalink
skip appender
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Jul 13, 2023
1 parent e0a2437 commit 63e97f8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use PhpParser\Node;
use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\AssignOp;
use PhpParser\Node\Expr\AssignOp\Coalesce;
use PhpParser\NodeVisitorAbstract;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\NodeTypeResolver\PHPStan\Scope\Contract\NodeVisitor\ScopeResolverNodeVisitorInterface;
Expand All @@ -19,12 +18,13 @@ final class AssignedToNodeVisitor extends NodeVisitorAbstract implements ScopeRe
{
public function enterNode(Node $node): ?Node
{
if (! $node instanceof Assign && ! $node instanceof AssignOp) {
if ($node instanceof AssignOp) {
$node->var->setAttribute(AttributeKey::IS_ASSIGNED_TO, true);
return null;
}

if ($node instanceof Coalesce) {
$node->var->setAttribute(AttributeKey::IS_ASSIGNED_TO, true);
if (! $node instanceof Assign) {
return null;
}

$node->var->setAttribute(AttributeKey::IS_BEING_ASSIGNED, true);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Rector\Tests\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector\Fixture;

class SkipAppenderAssignment {
private int $bar = 2;

public function bar(): int {
$a = 1;
$a += $this->bar;

return $a;
}
}

0 comments on commit 63e97f8

Please sign in to comment.