Skip to content

Commit

Permalink
[NodeTypeResolver] Clean up unnecessary scope attribute set on Class_…
Browse files Browse the repository at this point in the history
…/Interface_/Enum_ (#6316)

* [NodeTypeResolver] Clean up unnecessary attribute set on Class_/Interface_/Enum_

* add test

* Reduce instanceof check
  • Loading branch information
samsonasik authored Sep 18, 2024
1 parent 71a0da8 commit 886efb0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\Fixture;

#[SomeAttribute(['array-argument'])]
class SkipInAttributeClass
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ public function processNodes(
/** @var MutatingScope $mutatingScope */
$mutatingScope = $this->resolveClassOrInterfaceScope($node, $mutatingScope);
$node->setAttribute(AttributeKey::SCOPE, $mutatingScope);
$this->decorateNodeAttrGroups($node, $mutatingScope, $nodeCallback);

return;
}
Expand All @@ -163,13 +162,13 @@ public function processNodes(
$node->setAttribute(AttributeKey::SCOPE, $mutatingScope);
}

$this->decorateNodeAttrGroups($node, $mutatingScope, $nodeCallback);

if ($node instanceof FileWithoutNamespace) {
$this->nodeScopeResolverProcessNodes($node->stmts, $mutatingScope, $nodeCallback);
return;
}

$this->decorateNodeAttrGroups($node, $mutatingScope, $nodeCallback);

if ((
$node instanceof Expression ||
$node instanceof Return_ ||
Expand Down

0 comments on commit 886efb0

Please sign in to comment.