protected function execute(InputInterface $input, OutputInterface $output)
{
$startTime = microtime(true);
$startMemUsage = memory_get_usage(true);
$output->writeln($this->getApplication()->getLongVersion() . " by overtrue and contributors.\n");
$options = $this->mergeOptions();
$verbosity = $output->getVerbosity();
if ($verbosity >= OutputInterface::VERBOSITY_DEBUG) {
$output->writeln('Options: ' . json_encode($options));
}
$linter = new Linter($options['path'], $options['exclude'], $options['extensions']);
$linter->setProcessLimit($options['jobs']);
if (!$input->getOption('no-cache') && Cache::isCached()) {
$output->writeln('Using cache.');
$linter->setCache(Cache::get());
}
$fileCount = count($linter->getFiles());
if ($fileCount <= 0) {
$output->writeln('<info>Could not find files to lint</info>');
return 0;
}
$errors = $this->executeLint($linter, $output, $fileCount, !$input->getOption('no-cache'));
$timeUsage = Helper::formatTime(microtime(true) - $startTime);
$memUsage = Helper::formatMemory(memory_get_usage(true) - $startMemUsage);
$code = 0;
$errCount = count($errors);
$output->writeln("\n\nTime: {$timeUsage}, Memory: {$memUsage}MB\n");
if ($errCount > 0) {
$output->writeln('<error>FAILURES!</error>');
$output->writeln("<error>Files: {$fileCount}, Failures: {$errCount}</error>");
$this->showErrors($errors);
$code = 1;
} else {
$output->writeln("<info>OK! (Files: {$fileCount}, Success: {$fileCount})</info>");
}
return $code;
}