make('someService'); CODE_SAMPLE , [new ArrayDimFetchToMethodCall(new ObjectType('SomeClass'), 'make')])]); } public function getNodeTypes() : array { return [ArrayDimFetch::class]; } /** * @param ArrayDimFetch $node */ public function refactor(Node $node) : ?MethodCall { if (!$node->var instanceof Variable) { return null; } if (!$node->dim instanceof Node) { return null; } foreach ($this->arrayDimFetchToMethodCalls as $arrayDimFetchToMethodCall) { if (!$this->isObjectType($node->var, $arrayDimFetchToMethodCall->getObjectType())) { continue; } return new MethodCall($node->var, $arrayDimFetchToMethodCall->getMethod(), [new Arg($node->dim)]); } return null; } public function configure(array $configuration) : void { Assert::allIsInstanceOf($configuration, ArrayDimFetchToMethodCall::class); $this->arrayDimFetchToMethodCalls = $configuration; } }