/**
* @return Result
*/
public function run()
{
$this->startTimer();
if (!isset($this->standard)) {
$this->standard[] = $this->getJoomlaCodingSniffers();
}
$this->printTaskInfo('Initialising CodeSniffer Checks...');
// Build the options for the sniffer
$options = array('files' => $this->files, 'standard' => $this->standard, 'ignored' => $this->ignored, 'showProgress' => true, 'verbosity' => false, 'ignore_errors_on_exit' => $this->ignore_errors_on_exit);
// Instantiate the sniffer
$phpcs = new \PHP_CodeSniffer_CLI();
// Ensure PHPCS can run, will exit if requirements aren't met
$phpcs->checkRequirements();
// Run the sniffs
$numErrors = $phpcs->process($options);
$this->stopTimer();
$message = 'There were no code style issues detected.';
$exitCode = 0;
if ($numErrors) {
$message = "There were {$numErrors} issues detected.";
$exitCode = 1;
}
if ($this->ignore_errors_on_exit) {
$exitCode = 0;
}
return new Result($this, $exitCode, $message, ['time' => $this->getExecutionTime()]);
}