setInject(); CODE_SAMPLE , <<<'CODE_SAMPLE' $serviceDefinition = new Nette\DI\ServiceDefinition; $serviceDefinition->addTag('inject'); CODE_SAMPLE , [new MethodCallToAnotherMethodCallWithArguments('Nette\\DI\\ServiceDefinition', 'setInject', 'addTag', ['inject'])])]); } /** * @return array> */ public function getNodeTypes() : array { return [MethodCall::class]; } /** * @param MethodCall $node */ public function refactor(Node $node) : ?Node { foreach ($this->methodCallRenamesWithAddedArguments as $methodCallRenameWithAddedArgument) { if (!$this->isObjectType($node->var, $methodCallRenameWithAddedArgument->getObjectType())) { continue; } if (!$this->isName($node->name, $methodCallRenameWithAddedArgument->getOldMethod())) { continue; } $node->name = new Identifier($methodCallRenameWithAddedArgument->getNewMethod()); $node->args = $this->nodeFactory->createArgs($methodCallRenameWithAddedArgument->getNewArguments()); return $node; } return null; } /** * @param mixed[] $configuration */ public function configure(array $configuration) : void { Assert::allIsAOf($configuration, MethodCallToAnotherMethodCallWithArguments::class); $this->methodCallRenamesWithAddedArguments = $configuration; } }