From a74b63985e7cd811e5cdde30753249d8466666dd Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sat, 4 Aug 2018 17:43:34 +0200 Subject: [PATCH] Avoid filtering dev-require packages when loading plugins/scripts, fixes #7516 --- src/Composer/Autoload/AutoloadGenerator.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Composer/Autoload/AutoloadGenerator.php b/src/Composer/Autoload/AutoloadGenerator.php index 8f03d330a..d54f3d6f6 100644 --- a/src/Composer/Autoload/AutoloadGenerator.php +++ b/src/Composer/Autoload/AutoloadGenerator.php @@ -157,7 +157,7 @@ EOF; // Collect information from all packages. $packageMap = $this->buildPackageMap($installationManager, $mainPackage, $localRepo->getCanonicalPackages()); - $autoloads = $this->parseAutoloads($packageMap, $mainPackage); + $autoloads = $this->parseAutoloads($packageMap, $mainPackage, $this->devMode === false); // Process the 'psr-0' base directories. foreach ($autoloads['psr-0'] as $namespace => $paths) { @@ -383,12 +383,15 @@ EOF; * * @param array $packageMap array of array(package, installDir-relative-to-composer.json) * @param PackageInterface $mainPackage root package instance + * @param bool $filterOutRequireDevPackages whether to filter out require-dev packages * @return array array('psr-0' => array('Ns\\Foo' => array('installDir'))) */ - public function parseAutoloads(array $packageMap, PackageInterface $mainPackage) + public function parseAutoloads(array $packageMap, PackageInterface $mainPackage, $filterOutRequireDevPackages = false) { $mainPackageMap = array_shift($packageMap); - $packageMap = $this->filterPackageMap($packageMap, $mainPackage); + if ($filterOutRequireDevPackages) { + $packageMap = $this->filterPackageMap($packageMap, $mainPackage); + } $sortedPackageMap = $this->sortPackageMap($packageMap); $sortedPackageMap[] = $mainPackageMap; array_unshift($packageMap, $mainPackageMap); @@ -901,7 +904,7 @@ INITIALIZER; } /** - * Filters out dev-dependencies when not in dev-mode + * Filters out dev-dependencies * * @param array $packageMap * @param PackageInterface $mainPackage @@ -909,10 +912,6 @@ INITIALIZER; */ protected function filterPackageMap(array $packageMap, PackageInterface $mainPackage) { - if ($this->devMode === true) { - return $packageMap; - } - $packages = array(); $include = array();