function Plugin::saveInstalledPaths
Save all coding standard paths back into PHP_CodeSniffer
Return value
int Exit code. 0 for success, 1 or higher for failure.
Throws
1 call to Plugin::saveInstalledPaths()
- Plugin::onDependenciesChangedEvent in vendor/
dealerdirect/ phpcodesniffer-composer-installer/ src/ Plugin.php - Entry point for post install and post update events.
File
-
vendor/
dealerdirect/ phpcodesniffer-composer-installer/ src/ Plugin.php, line 263
Class
- Plugin
- PHP_CodeSniffer standard installation manager.
Namespace
PHPCSStandards\Composer\Plugin\Installers\PHPCodeSnifferCode
private function saveInstalledPaths() {
// Check if we found installed paths to set.
if (count($this->installedPaths) !== 0) {
sort($this->installedPaths);
$paths = implode(',', $this->installedPaths);
$arguments = array(
'--config-set',
self::PHPCS_CONFIG_KEY,
$paths,
);
$configMessage = sprintf('PHP CodeSniffer Config <info>%s</info> <comment>set to</comment> <info>%s</info>', self::PHPCS_CONFIG_KEY, $paths);
}
else {
// Delete the installed paths if none were found.
$arguments = array(
'--config-delete',
self::PHPCS_CONFIG_KEY,
);
$configMessage = sprintf('PHP CodeSniffer Config <info>%s</info> <comment>delete</comment>', self::PHPCS_CONFIG_KEY);
}
// Prepare message in case of failure
$failMessage = sprintf('Failed to set PHP CodeSniffer <info>%s</info> Config', self::PHPCS_CONFIG_KEY);
// Okay, lets rock!
$command = vsprintf('%s %s', array(
'phpcs command' => $this->getPhpcsCommand(),
'arguments' => implode(' ', $arguments),
));
$exitCode = $this->processExecutor
->execute($command, $configResult, $this->getPHPCodeSnifferInstallPath());
if ($exitCode === 0) {
$exitCode = $this->verifySaveSuccess();
}
if ($exitCode === 0) {
$this->io
->write($configMessage);
}
else {
$this->io
->write($failMessage);
}
if ($this->io
->isVerbose() && !empty($configResult)) {
$this->io
->write(sprintf('<info>%s</info>', $configResult));
}
return $exitCode;
}