Skip to content

RefactorCommand

github-actions edited this page Apr 19, 2026 · 1 revision

Provides functionality to execute automated code refactoring using Rector.

This class MUST NOT be extended and SHALL encapsulate the logic for Rector invocation.


  • Full name: \FastForward\DevTools\Console\Command\RefactorCommand
  • Parent class: BaseCommand
  • This class is marked as final and can't be subclassed
  • This class is a Final class

Constants

Constant Visibility Type Value
CONFIG public string 'rector.php'

Methods

__construct

Creates a new RefactorCommand instance.

public __construct(\Symfony\Component\Config\FileLocatorInterface $fileLocator, \FastForward\DevTools\Process\ProcessBuilderInterface $processBuilder, \FastForward\DevTools\Process\ProcessQueueInterface $processQueue): mixed

Parameters:

Parameter Type Description
$fileLocator \Symfony\Component\Config\FileLocatorInterface the file locator
$processBuilder \FastForward\DevTools\Process\ProcessBuilderInterface the process builder
$processQueue \FastForward\DevTools\Process\ProcessQueueInterface the process queue

configure

Configures the refactor command options and description.

protected configure(): void

This method MUST define the expected --fix option. It SHALL configure the command name and descriptions accurately.


execute

Executes the refactoring process securely.

protected execute(\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output): int

The method MUST execute Rector securely via Process. It SHALL use dry-run mode unless the --fix option is specified. It MUST return self::SUCCESS or self::FAILURE.

Parameters:

Parameter Type Description
$input \Symfony\Component\Console\Input\InputInterface the input interface to retrieve arguments properly
$output \Symfony\Component\Console\Output\OutputInterface the output interface to log outputs

Return Value:

the status code denoting success or failure


Clone this wiki locally