compactConverter = $compactConverter; } public function getDefinition(): RectorDefinition { return new RectorDefinition('Change compact() call to own array', [ new CodeSample( <<<'PHP' class SomeClass { public function run() { $checkout = 'one'; $form = 'two'; return compact('checkout', 'form'); } } PHP , <<<'PHP' class SomeClass { public function run() { $checkout = 'one'; $form = 'two'; return ['checkout' => $checkout, 'form' => $form]; } } PHP ), ]); } /** * @return string[] */ public function getNodeTypes(): array { return [FuncCall::class]; } /** * @param FuncCall $node */ public function refactor(Node $node): ?Node { if (! $this->isName($node, 'compact')) { return null; } if (! $this->compactConverter->hasAllArgumentsNamed($node)) { return null; } return $this->compactConverter->convertToArray($node); } }