diff --git a/src/Composer/Autoload/AutoloadGenerator.php b/src/Composer/Autoload/AutoloadGenerator.php
index 0c32dc750..bd8308804 100644
--- a/src/Composer/Autoload/AutoloadGenerator.php
+++ b/src/Composer/Autoload/AutoloadGenerator.php
@@ -222,34 +222,14 @@ EOF;
);
$namespaceFilter = $namespace === '' ? null : $namespace;
- foreach (ClassMapGenerator::createMap($dir, $whitelist, $this->io, $namespaceFilter) as $class => $path) {
- $pathCode = $this->getPathCode($filesystem, $basePath, $vendorPath, $path).",\n";
- if (!isset($classMap[$class])) {
- $classMap[$class] = $pathCode;
- } elseif ($this->io && $classMap[$class] !== $pathCode && !preg_match('{/(test|fixture|example|stub)s?/}i', strtr($classMap[$class].' '.$path, '\\', '/'))) {
- $this->io->writeError(
- 'Warning: Ambiguous class resolution, "'.$class.'"'.
- ' was found in both "'.str_replace(array('$vendorDir . \'', "',\n"), array($vendorPath, ''), $classMap[$class]).'" and "'.$path.'", the first will be used.'
- );
- }
- }
+ $classMap = $this->addClassMapCode($filesystem, $basePath, $vendorPath, $dir, $whitelist, $namespaceFilter, $classMap);
}
}
}
}
foreach ($autoloads['classmap'] as $dir) {
- foreach (ClassMapGenerator::createMap($dir, null, $this->io) as $class => $path) {
- $pathCode = $this->getPathCode($filesystem, $basePath, $vendorPath, $path).",\n";
- if (!isset($classMap[$class])) {
- $classMap[$class] = $pathCode;
- } elseif ($this->io && $classMap[$class] !== $pathCode && !preg_match('{/(test|fixture|example|stub)s?/}i', strtr($classMap[$class].' '.$path, '\\', '/'))) {
- $this->io->writeError(
- 'Warning: Ambiguous class resolution, "'.$class.'"'.
- ' was found in both "'.str_replace(array('$vendorDir . \'', "',\n"), array($vendorPath, ''), $classMap[$class]).'" and "'.$path.'", the first will be used.'
- );
- }
- }
+ $classMap = $this->addClassMapCode($filesystem, $basePath, $vendorPath, $dir, null, null, $classMap);
}
ksort($classMap);
@@ -297,6 +277,28 @@ EOF;
));
}
+ private function addClassMapCode($filesystem, $basePath, $vendorPath, $dir, $whitelist = null, $namespaceFilter = null, array $classMap = array())
+ {
+ foreach ($this->generateClassMap($dir, $whitelist, $this->io, $namespaceFilter) as $class => $path) {
+ $pathCode = $this->getPathCode($filesystem, $basePath, $vendorPath, $path).",\n";
+ if (!isset($classMap[$class])) {
+ $classMap[$class] = $pathCode;
+ } elseif ($this->io && $classMap[$class] !== $pathCode && !preg_match('{/(test|fixture|example|stub)s?/}i', strtr($classMap[$class].' '.$path, '\\', '/'))) {
+ $this->io->writeError(
+ 'Warning: Ambiguous class resolution, "'.$class.'"'.
+ ' was found in both "'.str_replace(array('$vendorDir . \'', "',\n"), array($vendorPath, ''), $classMap[$class]).'" and "'.$path.'", the first will be used.'
+ );
+ }
+ }
+
+ return $classMap;
+ }
+
+ private function generateClassMap($dir, $whitelist = null, $namespaceFilter = null)
+ {
+ return ClassMapGenerator::createMap($dir, $whitelist, $this->io, $namespaceFilter);
+ }
+
public function buildPackageMap(InstallationManager $installationManager, PackageInterface $mainPackage, array $packages)
{
// build package => install path map
@@ -386,6 +388,12 @@ EOF;
}
}
+ if (isset($autoloads['classmap'])) {
+ foreach ($autoloads['classmap'] as $dir) {
+ $loader->addClassMap($this->generateClassMap($dir));
+ }
+ }
+
return $loader;
}