Skip to content

Commit

Permalink
Fix compatibility with PHPCS 2.x for the fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jrfnl committed Dec 14, 2019
1 parent 6de96f6 commit 22d3cdc
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,18 +245,28 @@ private function saveInstalledPaths()
self::PHPCS_CONFIG_KEY
);

// Okay, lets rock! 🤘
$command = vsprintf('%s ./bin/phpcs %s', array(
'php executable' => $this->getPhpExecCommand(),
'arguments' => implode(' ', $arguments)
));

$exitCode = $this->processExecutor->execute(
$command,
$configResult,
$this->getPHPCodeSnifferInstallPath()
// Determine the path to the main PHPCS file.
$phpcsPath = $this->getPHPCodeSnifferInstallPath();
if (file_exists($phpcsPath . '/bin/phpcs') === true) {
// PHPCS 3.x.
$phpcsExecutable = './bin/phpcs';
} else {
// PHPCS 2.x.
$phpcsExecutable = './scripts/phpcs';
}

// Okay, lets rock!
$command = vsprintf(
'%s %s %s',
array(
'php executable' => $this->getPhpExecCommand(),
'phpcs executable' => $phpcsExecutable,
'arguments' => implode(' ', $arguments)
)
);

$exitCode = $this->processExecutor->execute($command, $configResult, $phpcsPath);

if ($exitCode === 0) {
$this->io->write($configMessage);
} else {
Expand Down

0 comments on commit 22d3cdc

Please sign in to comment.