Skip to content

Commit

Permalink
[Php81] Skip anonymous class on FinalizePublicClassConstantRector (#1970
Browse files Browse the repository at this point in the history
)
  • Loading branch information
samsonasik committed Mar 27, 2022
1 parent 82656ad commit 4562f4f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Rector\Tests\Php81\Rector\ClassConst\FinalizePublicClassConstantRector\Fixture;

new class {
public const NAME = 'value';
};
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ public function refactor(Node $node): ?Node
return null;
}

if ($node->isPrivate()) {
if (! $node->isPublic()) {
return null;
}

if ($node->isProtected()) {
if ($node->isFinal()) {
return null;
}

if ($node->isFinal()) {
if ($this->classAnalyzer->isAnonymousClass($class)) {
return null;
}

Expand All @@ -104,10 +104,6 @@ public function provideMinPhpVersion(): int

private function isClassHasChildren(Class_ $class): bool
{
if ($this->classAnalyzer->isAnonymousClass($class)) {
return false;
}

$className = (string) $this->nodeNameResolver->getName($class);
if (! $this->reflectionProvider->hasClass($className)) {
return false;
Expand Down

0 comments on commit 4562f4f

Please sign in to comment.