oldProperty = false; CODE_SAMPLE , <<<'CODE_SAMPLE' $someObject = new SomeClass; $someObject->newMethodCall(false); CODE_SAMPLE , [new PropertyAssignToMethodCall('SomeClass', 'oldProperty', 'newMethodCall')])]); } /** * @return array> */ public function getNodeTypes() : array { return [Assign::class]; } /** * @param Assign $node */ public function refactor(Node $node) : ?Node { if (!$node->var instanceof PropertyFetch) { return null; } $propertyFetchNode = $node->var; /** @var Variable $propertyNode */ $propertyNode = $propertyFetchNode->var; foreach ($this->propertyAssignsToMethodCalls as $propertyAssignToMethodCall) { if (!$this->isName($propertyFetchNode, $propertyAssignToMethodCall->getOldPropertyName())) { continue; } if (!$this->isObjectType($propertyFetchNode->var, $propertyAssignToMethodCall->getObjectType())) { continue; } return $this->nodeFactory->createMethodCall($propertyNode, $propertyAssignToMethodCall->getNewMethodName(), [$node->expr]); } return null; } /** * @param mixed[] $configuration */ public function configure(array $configuration) : void { Assert::allIsAOf($configuration, PropertyAssignToMethodCall::class); $this->propertyAssignsToMethodCalls = $configuration; } }