|
6 | 6 |
|
7 | 7 | use PhpParser\Node; |
8 | 8 | use PhpParser\Node\AttributeGroup; |
| 9 | +use PhpParser\Node\Expr\ArrowFunction; |
| 10 | +use PhpParser\Node\Expr\Closure; |
9 | 11 | use PhpParser\Node\Param; |
| 12 | +use PhpParser\Node\PropertyHook; |
| 13 | +use PhpParser\Node\Stmt\ClassConst; |
| 14 | +use PhpParser\Node\Stmt\ClassLike; |
| 15 | +use PhpParser\Node\Stmt\ClassMethod; |
| 16 | +use PhpParser\Node\Stmt\Const_; |
| 17 | +use PhpParser\Node\Stmt\EnumCase; |
| 18 | +use PhpParser\Node\Stmt\Function_; |
10 | 19 | use PhpParser\Node\Stmt\Property; |
11 | 20 | use Rector\Contract\Rector\ConfigurableRectorInterface; |
12 | 21 | use Rector\Rector\AbstractRector; |
@@ -53,25 +62,26 @@ class SomeClass |
53 | 62 | */ |
54 | 63 | public function getNodeTypes(): array |
55 | 64 | { |
56 | | - return [Node::class]; |
| 65 | + return [ |
| 66 | + ArrowFunction::class, |
| 67 | + ClassConst::class, |
| 68 | + ClassLike::class, |
| 69 | + ClassMethod::class, |
| 70 | + Closure::class, |
| 71 | + Const_::class, |
| 72 | + EnumCase::class, |
| 73 | + Function_::class, |
| 74 | + Param::class, |
| 75 | + Property::class, |
| 76 | + PropertyHook::class, |
| 77 | + ]; |
57 | 78 | } |
58 | 79 |
|
| 80 | + /** |
| 81 | + * @param ArrowFunction|ClassConst|ClassLike|ClassMethod|Closure|Const_|EnumCase|Function_|Param|Property|PropertyHook $node |
| 82 | + */ |
59 | 83 | public function refactor(Node $node): ?Node |
60 | 84 | { |
61 | | - if (! in_array('attrGroups', $node->getSubNodeNames(), true)) { |
62 | | - return null; |
63 | | - } |
64 | | - |
65 | | - if (! isset($node->attrGroups) || $node->attrGroups === null || $node->attrGroups === []) { |
66 | | - return null; |
67 | | - } |
68 | | - |
69 | | - foreach ($node->attrGroups as $attrGroup) { |
70 | | - if (! $attrGroup instanceof AttributeGroup) { |
71 | | - return null; |
72 | | - } |
73 | | - } |
74 | | - |
75 | 85 | $nodeTypes = [$node::class]; |
76 | 86 | if ($node instanceof Param && $node->isPromoted()) { |
77 | 87 | // An attribute removed from a parameter or property must be removed from a promoted property because an |
|
0 commit comments