['TraitNameToRemove']])]); } /** * @return array> */ public function getNodeTypes() : array { return [\PhpParser\Node\Stmt\Class_::class, \PhpParser\Node\Stmt\Trait_::class]; } /** * @param Class_|Trait_ $node */ public function refactor($node) : ?\PhpParser\Node { $this->classHasChanged = \false; foreach ($node->getTraitUses() as $traitUse) { foreach ($traitUse->traits as $trait) { if (!$this->isNames($trait, $this->traitsToRemove)) { continue; } $this->removeNode($traitUse); $this->classHasChanged = \true; } } // invoke re-print if ($this->classHasChanged) { $node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE, null); return $node; } return null; } /** * @param array $configuration */ public function configure(array $configuration) : void { $this->traitsToRemove = $configuration[self::TRAITS_TO_REMOVE] ?? []; } }