hasService("someKey"); $container->removeService("someKey"); CODE_SAMPLE , [new UnsetAndIssetToMethodCall('SomeContainer', 'hasService', 'removeService')])]); } /** * @return array> */ public function getNodeTypes() : array { return [Isset_::class, Unset_::class]; } /** * @param Isset_|Unset_ $node */ public function refactor(Node $node) : ?Node { foreach ($node->vars as $arrayDimFetch) { if (!$arrayDimFetch instanceof ArrayDimFetch) { continue; } foreach ($this->issetUnsetToMethodCalls as $issetUnsetToMethodCall) { if (!$this->isObjectType($arrayDimFetch->var, $issetUnsetToMethodCall->getObjectType())) { continue; } $newNode = $this->processArrayDimFetchNode($node, $arrayDimFetch, $issetUnsetToMethodCall); if ($newNode instanceof Node) { return $newNode; } } } return null; } /** * @param mixed[] $configuration */ public function configure(array $configuration) : void { Assert::allIsAOf($configuration, UnsetAndIssetToMethodCall::class); $this->issetUnsetToMethodCalls = $configuration; } private function processArrayDimFetchNode(Node $node, ArrayDimFetch $arrayDimFetch, UnsetAndIssetToMethodCall $unsetAndIssetToMethodCall) : ?Node { if ($node instanceof Isset_) { if ($unsetAndIssetToMethodCall->getIssetMethodCall() === '') { return null; } return $this->nodeFactory->createMethodCall($arrayDimFetch->var, $unsetAndIssetToMethodCall->getIssetMethodCall(), [$arrayDimFetch->dim]); } if ($node instanceof Unset_) { if ($unsetAndIssetToMethodCall->getUnsedMethodCall() === '') { return null; } return $this->nodeFactory->createMethodCall($arrayDimFetch->var, $unsetAndIssetToMethodCall->getUnsedMethodCall(), [$arrayDimFetch->dim]); } return null; } }