Skip to content

Commit

Permalink
Merge pull request #98 from Dealerdirect/feature/bug-fix-loadInstalle…
Browse files Browse the repository at this point in the history
…dPaths

Bug fix: `loadInstalledPaths()` very very broken since PHPCS 3.1.0
  • Loading branch information
Potherca committed Jan 19, 2020
2 parents eb62590 + b09c763 commit 3942e1a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/Plugin.php
Expand Up @@ -46,6 +46,7 @@ class Plugin implements PluginInterface, EventSubscriberInterface
const PACKAGE_NAME = 'squizlabs/php_codesniffer';
const PACKAGE_TYPE = 'phpcodesniffer-standard';

const PHPCS_CONFIG_REGEX = '`%s:[^\r\n]+`';
const PHPCS_CONFIG_KEY = 'installed_paths';

/**
Expand Down Expand Up @@ -209,11 +210,14 @@ private function loadInstalledPaths()
$this->composer->getConfig()->get('bin-dir')
);

$phpcsInstalledPaths = str_replace(self::PHPCS_CONFIG_KEY . ': ', '', $output);
$phpcsInstalledPaths = trim($phpcsInstalledPaths);

if ($phpcsInstalledPaths !== '') {
$this->installedPaths = explode(',', $phpcsInstalledPaths);
$regex = sprintf(self::PHPCS_CONFIG_REGEX, self::PHPCS_CONFIG_KEY);
if (preg_match($regex, $output, $match) === 1) {
$phpcsInstalledPaths = str_replace(self::PHPCS_CONFIG_KEY . ': ', '', $match[0]);
$phpcsInstalledPaths = trim($phpcsInstalledPaths);

if ($phpcsInstalledPaths !== '') {
$this->installedPaths = explode(',', $phpcsInstalledPaths);
}
}
}
}
Expand Down

0 comments on commit 3942e1a

Please sign in to comment.