> */ public function getNodeTypes() : array { return [ClassConstFetch::class]; } /** * @param ClassConstFetch $node */ public function refactor(Node $node) : ?ClassConstFetch { foreach ($this->renameClassConstFetches as $renameClassConstFetch) { if (!$this->isName($node->name, $renameClassConstFetch->getOldConstant())) { continue; } if (!$this->isObjectType($node->class, $renameClassConstFetch->getOldObjectType())) { continue; } if ($renameClassConstFetch instanceof RenameClassAndConstFetch) { return $this->createClassAndConstFetch($renameClassConstFetch); } $node->name = new Identifier($renameClassConstFetch->getNewConstant()); return $node; } return null; } /** * @param mixed[] $configuration */ public function configure(array $configuration) : void { Assert::allIsAOf($configuration, RenameClassConstFetchInterface::class); $this->renameClassConstFetches = $configuration; } private function createClassAndConstFetch(RenameClassAndConstFetch $renameClassAndConstFetch) : ClassConstFetch { return new ClassConstFetch(new FullyQualified($renameClassAndConstFetch->getNewClass()), new Identifier($renameClassAndConstFetch->getNewConstant())); } }