public function onGetClassFixClass(GetClassEvent $event) { $fileLocation = $event->getFileLocation(); $command = new FixCommand(); $arguments = ['path' => $fileLocation]; $arguments = array_merge($arguments, $this->arguments); $output = isset($this->output) ? $this->output : new BufferedOutput(); $output->writeln(sprintf('<info>Running PSR Fixer on %s</info>', $fileLocation)); $input = new ArrayInput($arguments); $command->run($input, $output); }
public function testCommandHasCacheFileOption() { $command = new Command\FixCommand(); $definition = $command->getDefinition(); $this->assertTrue($definition->hasOption('cache-file')); $option = $definition->getOption('cache-file'); $this->assertNull($option->getShortcut()); $this->assertTrue($option->isValueRequired()); $this->assertSame('The path to the cache file', $option->getDescription()); $this->assertNull($option->getDefault()); }
protected function initialize(InputInterface $input, OutputInterface $output) { $namespace = $input->getOption('namespace'); $this->defaultConfig = call_user_func($this->configFactory, $namespace); $this->parseOptionalOptionValue($input, 'diff', false); $this->parseOptionalOptionValue($input, 'dry-run', false); parent::initialize($input, $output); }
/** * @param Fixer|null $fixer * @param ConfigInterface|null $config */ public function __construct(Fixer $fixer = null, ConfigInterface $config = null) { parent::__construct($fixer, $config ?: new StyleConfig()); $this->setName('style:fix'); $this->setDescription('Fixes a directory or a file.'); }
/** * @param Fixer $fixer */ public function __construct(Fixer $fixer = null) { $finder = DefaultFinder::create(); $finder->append($this->commitedFiles()); parent::__construct($fixer, Config::create()->finder($finder)); }
public function testExitCodeActualRunWithChangedAndInvalidFiles() { $errorsManager = new ErrorsManager(); $errorsManager->report(new Error(Error::TYPE_INVALID, 'Invalid.php')); $fixer = $this->getFixerMock(array('Changed.php'), $errorsManager); $command = new FixCommand($fixer); $input = $this->getInputMock(array('dry-run' => false)); $exitCode = $command->run($input, new NullOutput()); $this->assertSame(0, $exitCode); }