private function analyzer($output, $analyzer, $files, $config, $project)
{
if (!$config->get('application.analyzer.' . $analyzer . '.enabled', false)) {
return;
}
$this->validateBinary('bin/' . $analyzer);
$configFile = $config->getProjectAnalyzerConfigFile($project, $analyzer);
$exception = $config->get('application.analyzer.' . $analyzer . '.exception', false);
$options = $config->get('application.analyzer.' . $analyzer . '.options', []);
$arguments = $config->get('application.analyzer.' . $analyzer . '.arguments', []);
$prefixes = $config->get('application.analyzer.' . $analyzer . '.prefixes', []);
$postfixes = $config->get('application.analyzer.' . $analyzer . '.postfixes', []);
$success = true;
$output->writeln(sprintf('<info>%s</info>', $config->get('application.messages.' . $analyzer . '.info')));
$processArguments = ['php', $this->directory . 'bin/' . $analyzer];
if ($configFile) {
$singleExecution = $config->get('application.analyzer.' . $analyzer . '.file.single-execution');
if ($singleExecution) {
$process = $this->executeProcess($output, $processArguments, $configFile, $prefixes, $postfixes, $arguments, $options);
$success = $process->isSuccessful();
$files = [];
}
$processArguments[] = $configFile;
}
foreach ($files as $file) {
if (!preg_match($this->needle, $file) && !is_dir(realpath($this->directory . $file))) {
continue;
}
$process = $this->executeProcess($output, $processArguments, $file, $prefixes, $postfixes, $arguments, $options);
if ($success) {
$success = $process->isSuccessful();
}
}
if ($exception && !$success) {
throw new Exception($config->get('application.messages.' . $analyzer . '.error'));
}
}