Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensures absolute paths during detection phase #73

Merged
merged 1 commit into from Oct 26, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/Plugin.php
Expand Up @@ -72,6 +72,11 @@ class Plugin implements PluginInterface, EventSubscriberInterface
*/
private $filesystem;

/**
* @var string
*/
private $cwd;

/**
* Triggers the plugin's main functionality.
*
Expand Down Expand Up @@ -127,6 +132,7 @@ private function init()
$this->installedPaths = array();
$this->processExecutor = new ProcessExecutor($this->io);
$this->filesystem = new Filesystem($this->processExecutor);
$this->cwd = getcwd();
}

/**
Expand Down Expand Up @@ -285,10 +291,16 @@ private function updateInstalledPaths()
{
$changes = false;

$searchPaths = array(getcwd());
$searchPaths = array($this->cwd);
$codingStandardPackages = $this->getPHPCodingStandardPackages();
foreach ($codingStandardPackages as $package) {
$searchPaths[] = $this->composer->getInstallationManager()->getInstallPath($package);
$installPath = $this->composer->getInstallationManager()->getInstallPath($package);
if ($this->filesystem->isAbsolutePath($installPath) === false) {
$installPath = $this->filesystem->normalizePath(
$this->cwd . DIRECTORY_SEPARATOR . $installPath
);
}
$searchPaths[] = $installPath;
}

$finder = new Finder();
Expand Down Expand Up @@ -408,7 +420,7 @@ private function isPHPCodeSnifferInstalled($versionConstraint = null)
*/
private function isRunningGlobally()
{
return ($this->composer->getConfig()->get('home') === getcwd());
return ($this->composer->getConfig()->get('home') === $this->cwd);
}

/**
Expand Down