diff --git a/src/Plugin.php b/src/Plugin.php index 1cb5af0f..c7a734f0 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -444,9 +444,17 @@ private function cleanInstalledPaths() */ private function updateInstalledPaths() { - $changes = false; + $changes = false; + $searchPaths = array(); + + // Add root package only if it has the expected package type. + if ( + $this->composer->getPackage() instanceof RootPackageInterface + && $this->composer->getPackage()->getType() === self::PACKAGE_TYPE + ) { + $searchPaths[] = $this->cwd; + } - $searchPaths = array($this->cwd); $codingStandardPackages = $this->getPHPCodingStandardPackages(); foreach ($codingStandardPackages as $package) { $installPath = $this->composer->getInstallationManager()->getInstallPath($package); @@ -458,6 +466,11 @@ private function updateInstalledPaths() $searchPaths[] = $installPath; } + // Nothing to do. + if ($searchPaths === array()) { + return false; + } + $finder = new Finder(); $finder->files() ->depth('<= ' . $this->getMaxDepth()) @@ -499,9 +512,6 @@ private function updateInstalledPaths() * Iterates through Composers' local repository looking for valid Coding * Standard packages. * - * If the package is the RootPackage (the one the plugin is installed into), - * the package is ignored for now since it needs a different install path logic. - * * @return array Composer packages containing coding standard(s) */ private function getPHPCodingStandardPackages() @@ -516,13 +526,6 @@ function (PackageInterface $package) { } ); - if ( - ! $this->composer->getPackage() instanceof RootPackageInterface - && $this->composer->getPackage()->getType() === self::PACKAGE_TYPE - ) { - $codingStandardPackages[] = $this->composer->getPackage(); - } - return $codingStandardPackages; }