/** * Run the command. Executed immediately. * * @since 1.0.0 * * @return int CLI tool exit code. */ public function fire() { parent::fire(); if (!$this->isInstalledGlobally()) { $this->error('Due to dependency conflicts with Laravel\'s CLI tools ' . 'PHP-CS-Fixer cannot be bundled with BCA\'s Laravel-Inspect ' . 'package.' . "\n\n" . 'To continue, please install PHP-CS-Fixer in your system path ' . 'by issuing the following commands:' . "\n\n" . "\t" . 'sudo curl http://cs.sensiolabs.org/get/php-cs-fixer.phar -o' . ' /usr/local/bin/php-cs-fixer' . "\n" . "\t" . 'sudo chmod a+x /usr/local/bin/php-cs-fixer' . "\n\n" . 'Once the tool has been installed you can run ' . $this->name . ' ' . 'again to activate the fixer.'); return false; } $this->info('Running php-cs-fixer...'); if (!$this->option('dry-run') && !$this->option('force')) { if (!$this->confirm('This will permanently modify your code to comply with PSR-1. ' . "\n" . 'Are you sure that you want to continue? (y/n)[y]')) { return false; } } $command = self::CLI_TOOL . ' '; $command .= 'fix '; $command .= base_path() . '/' . $this->option('path'); $command .= ' --level=psr1'; if ($this->option('dry-run')) { $command .= ' --dry-run'; } passthru($command, $exitCode); $this->info('Done.'); return $exitCode; }
/** * Run the command. Executed immediately. * * @since 1.0.0 * * @return int CLI tool exit code. */ public function fire() { parent::fire(); if ($this->option('install-ruleset')) { if ($this->installRuleset()) { $this->info('Copied ruleset to ' . $this->pathRulesetLocal); } } $this->info('Running PHP Code Sniffer...'); $commandParts = array($this->pathCli, '--standard=' . $this->pathRuleset, sprintf('--tab-width=%d', $this->option('tab-width'))); $commandParts = $this->appendCommandOptions($commandParts); $commandParts[] = sprintf('%s/%s', base_path(), $this->option('path')); $command = implode(' ', $commandParts); passthru($command, $exitCode); $this->info('Done.'); return $exitCode; }