Skip to content

Commit

Permalink
[Privatization] Fix reprint with attribute on FinalizeTestCaseClassRe…
Browse files Browse the repository at this point in the history
…ctor (#5557)

* [Privatization] Fix reprint with attribute on FinalizeTestCaseClassRector

* [Privatization] Fix reprint with attribute on FinalizeTestCaseClassRector
  • Loading branch information
samsonasik committed Feb 4, 2024
1 parent 2dd3951 commit ba1cad3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Rector\Tests\Privatization\Rector\Class_\FinalizeTestCaseClassRector\Fixture;

use PHPUnit\Framework\TestCase;

#[CoversClass(Advisor::class)]
class WithAttribute extends TestCase
{
}

?>
-----
<?php

namespace Rector\Tests\Privatization\Rector\Class_\FinalizeTestCaseClassRector\Fixture;

use PHPUnit\Framework\TestCase;

#[CoversClass(Advisor::class)]
final class WithAttribute extends TestCase
{
}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use PhpParser\Node;
use PhpParser\Node\Stmt\Class_;
use PHPStan\Reflection\ReflectionProvider;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\Privatization\NodeManipulator\VisibilityManipulator;
use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
Expand Down Expand Up @@ -79,6 +80,10 @@ public function refactor(Node $node): ?Node
return null;
}

if ($node->attrGroups !== []) {
$node->setAttribute(AttributeKey::ORIGINAL_NODE, null);
}

$this->visibilityManipulator->makeFinal($node);

return $node;
Expand Down

0 comments on commit ba1cad3

Please sign in to comment.