Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 34 additions & 8 deletions src/Command/AnalyzeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ class AnalyzeCommand extends Command
'drupal'
];

private $analyzerBinaries = [
'parallel-lint' => 'jakub-onderka/php-parallel-lint/parallel-lint',
'pdepend' => 'pdepend/pdepend/src/bin/pdepend',
'php-cs-fixer' => 'fabpot/php-cs-fixer/php-cs-fixer',
'phpcbf' =>'squizlabs/php_codesniffer/scripts/phpcbf',
'phpcpd' => 'sebastian/phpcpd/phpcpd',
'phpcs' => 'squizlabs/php_codesniffer/scripts/phpcs',
'phpdcd' => 'sebastian/phpdcd/phpdcd',
'phploc' => 'phploc/phploc/phploc',
'phpmd' => 'phpmd/phpmd/src/bin/phpmd',
'phpunit' => 'phpunit/phpunit/phpunit'
];

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -224,7 +237,7 @@ private function analyzer(SymfonyStyle $io, $analyzer, $files, $config, $project
return;
}

$this->validateBinary('bin/'.$analyzer);
$analizerBinary = $this->calculateBinary($analyzer);

$configFile = $config->getProjectAnalyzerConfigFile($project, $analyzer);

Expand All @@ -240,7 +253,7 @@ private function analyzer(SymfonyStyle $io, $analyzer, $files, $config, $project

$processArguments = [
'php',
$this->directory.'bin/'.$analyzer
$this->directory.$analizerBinary
];

if ($configFile) {
Expand Down Expand Up @@ -335,15 +348,28 @@ public function executeProcess(SymfonyStyle $io, $processArguments, $file, $pref
}

/**
* @param $binaryFile
* @param $analyzer
* @throws \Exception
*/
private function validateBinary($binaryFile)
private function calculateBinary($analyzer)
{
if (!file_exists($this->directory.$binaryFile)) {
throw new Exception(
sprintf('%s do not exist!', $binaryFile)
);
$binaries = [
'/bin/'.$analyzer
];

if (array_key_exists($analyzer, $this->analyzerBinaries)) {
$binaries[] = '/../../'.$this->analyzerBinaries[$analyzer];
$binaries[] = '/../../../'.$this->analyzerBinaries[$analyzer];
}

foreach ($binaries as $binary) {
if (file_exists($this->directory.$binary)) {
return $binary;
}
}

throw new Exception(
sprintf('%s do not exist!', $analyzer)
);
}
}