Skip to content

Commit

Permalink
Merge pull request #34 from DealerDirect/hotfix/change-installed-path…
Browse files Browse the repository at this point in the history
…s-behavior

Fixes #33. Changes the way the installed_paths are set.
  • Loading branch information
frenck authored Aug 1, 2017
2 parents 0abc65e + 5e1bf1e commit b437eb3
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,24 +286,25 @@ private function updateInstalledPaths()
->in($searchPaths);

// Only version 3.x and higher has support for having coding standard in the root of the directory.
$allowCodingStandardsInRoot = $this->isPHPCodeSnifferInstalled('>= 3.0.0');

if ($allowCodingStandardsInRoot !== true) {
if ($this->isPHPCodeSnifferInstalled('>= 3.0.0') !== true) {
$finder->depth('>= 1');
}

// Process each found possible ruleset.
foreach ($finder as $ruleset) {
$standardsPath = $ruleset->getPath();

if ($allowCodingStandardsInRoot === false) {
// Pick the directory above the directory containing the standard, unless this is the project root.
if ($standardsPath !== getcwd()) {
$standardsPath = dirname($standardsPath);
}

// Use relative paths for local project repositories
// Use relative paths for local project repositories.
if ($this->isRunningGlobally() === false) {
$standardsPath = $this->getRelativePath($standardsPath);
}

// De-duplicate and add when directory is not configured.
if (in_array($standardsPath, $this->installedPaths, true) === false) {
$this->installedPaths[] = $standardsPath;
$changes = true;
Expand Down

0 comments on commit b437eb3

Please sign in to comment.