diff --git a/src/Composer/Autoload/AutoloadGenerator.php b/src/Composer/Autoload/AutoloadGenerator.php index 675d3f9d1..65ea6e5bf 100644 --- a/src/Composer/Autoload/AutoloadGenerator.php +++ b/src/Composer/Autoload/AutoloadGenerator.php @@ -167,12 +167,6 @@ EOF; } $classmapFile .= ");\n"; - $filesCode = ""; - $autoloads['files'] = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($autoloads['files'])); - foreach ($autoloads['files'] as $functionFile) { - $filesCode .= 'require '.$this->getPathCode($filesystem, $basePath, $vendorPath, $functionFile).";\n"; - } - if (!$suffix) { $suffix = md5(uniqid('', true)); } @@ -182,13 +176,11 @@ EOF; if ($includePathFile = $this->getIncludePathsFile($packageMap, $filesystem, $basePath, $vendorPath, $vendorPathCode52, $appBaseDirCode)) { file_put_contents($targetDir.'/include_paths.php', $includePathFile); } - if ($filesCode) { - $filesCode = "getIncludeFilesFile($autoloads['files'], $filesystem, $basePath, $vendorPath, $vendorPathCode52, $appBaseDirCode)) { + file_put_contents($targetDir.'/autoload_files.php', $includeFilesFile); } file_put_contents($vendorPath.'/autoload.php', $this->getAutoloadFile($vendorPathToTargetDirCode, $suffix)); - file_put_contents($targetDir.'/autoload_real.php', $this->getAutoloadRealFile(true, true, (bool) $includePathFile, $targetDirLoader, $filesCode, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath)); + file_put_contents($targetDir.'/autoload_real.php', $this->getAutoloadRealFile(true, true, (bool) $includePathFile, $targetDirLoader, (bool) $includeFilesFile, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath)); // use stream_copy_to_stream instead of copy // to work around https://bugs.php.net/bug.php?id=64634 @@ -303,6 +295,31 @@ EOF; return $includePathsFile . ");\n"; } + protected function getIncludeFilesFile(array $files, Filesystem $filesystem, $basePath, $vendorPath, $vendorPathCode, $appBaseDirCode) + { + $filesCode = ''; + $files = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($files)); + foreach ($files as $functionFile) { + $filesCode .= 'require '.$this->getPathCode($filesystem, $basePath, $vendorPath, $functionFile).";\n"; + } + + if (!$filesCode) { + return FALSE; + } + $filesCode = rtrim($filesCode); + + return <<isAbsolutePath($path)) { @@ -343,7 +360,7 @@ return ComposerAutoloaderInit$suffix::getLoader(); AUTOLOAD; } - protected function getAutoloadRealFile($usePSR0, $useClassMap, $useIncludePath, $targetDirLoader, $filesCode, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath) + protected function getAutoloadRealFile($usePSR0, $useClassMap, $useIncludePath, $targetDirLoader, $useIncludeFiles, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath) { // TODO the class ComposerAutoloaderInit should be revert to a closure // when APC has been fixed: @@ -352,10 +369,6 @@ AUTOLOAD; // - https://bugs.php.net/bug.php?id=61576 // - https://bugs.php.net/bug.php?id=59298 - if ($filesCode) { - $filesCode = "\n\n".rtrim($filesCode); - } - $file = <<
register(true);{$filesCode} + $file .= <<register(true); + +REGISTER_LOADER; + + if ($useIncludeFiles) { + $file .= <<