1
0
Fork 0

Avoid filtering dev-require packages when loading plugins/scripts, fixes #7516

pull/7534/head
Jordi Boggiano 2018-08-04 17:43:34 +02:00
parent a1179aa4a7
commit a74b63985e
1 changed files with 7 additions and 8 deletions

View File

@ -157,7 +157,7 @@ EOF;
// Collect information from all packages. // Collect information from all packages.
$packageMap = $this->buildPackageMap($installationManager, $mainPackage, $localRepo->getCanonicalPackages()); $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. // Process the 'psr-0' base directories.
foreach ($autoloads['psr-0'] as $namespace => $paths) { 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 array $packageMap array of array(package, installDir-relative-to-composer.json)
* @param PackageInterface $mainPackage root package instance * @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'))) * @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); $mainPackageMap = array_shift($packageMap);
if ($filterOutRequireDevPackages) {
$packageMap = $this->filterPackageMap($packageMap, $mainPackage); $packageMap = $this->filterPackageMap($packageMap, $mainPackage);
}
$sortedPackageMap = $this->sortPackageMap($packageMap); $sortedPackageMap = $this->sortPackageMap($packageMap);
$sortedPackageMap[] = $mainPackageMap; $sortedPackageMap[] = $mainPackageMap;
array_unshift($packageMap, $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 array $packageMap
* @param PackageInterface $mainPackage * @param PackageInterface $mainPackage
@ -909,10 +912,6 @@ INITIALIZER;
*/ */
protected function filterPackageMap(array $packageMap, PackageInterface $mainPackage) protected function filterPackageMap(array $packageMap, PackageInterface $mainPackage)
{ {
if ($this->devMode === true) {
return $packageMap;
}
$packages = array(); $packages = array();
$include = array(); $include = array();