Browse Source

Merge remote-tracking branch 'Devolicious/feature/no-prepend'

Jordi Boggiano 11 năm trước cách đây
mục cha
commit
7682bc0d60
2 tập tin đã thay đổi với 6 bổ sung4 xóa
  1. 5 4
      src/Composer/Autoload/AutoloadGenerator.php
  2. 1 0
      src/Composer/Config.php

+ 5 - 4
src/Composer/Autoload/AutoloadGenerator.php

@@ -46,6 +46,7 @@ class AutoloadGenerator
         $basePath = $filesystem->normalizePath(getcwd());
         $vendorPath = $filesystem->normalizePath(realpath($config->get('vendor-dir')));
         $useGlobalIncludePath = (bool) $config->get('use-include-path');
+        $prependAutoloader = $config->get('prepend-autoloader') === false ? 'false' : 'true';
         $targetDir = $vendorPath.'/'.$targetDir;
         $filesystem->ensureDirectoryExists($targetDir);
 
@@ -180,7 +181,7 @@ EOF;
             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, (bool) $includeFilesFile, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath));
+        file_put_contents($targetDir.'/autoload_real.php', $this->getAutoloadRealFile(true, true, (bool) $includePathFile, $targetDirLoader, (bool) $includeFilesFile, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader));
 
         // use stream_copy_to_stream instead of copy
         // to work around https://bugs.php.net/bug.php?id=64634
@@ -365,7 +366,7 @@ return ComposerAutoloaderInit$suffix::getLoader();
 AUTOLOAD;
     }
 
-    protected function getAutoloadRealFile($usePSR0, $useClassMap, $useIncludePath, $targetDirLoader, $useIncludeFiles, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath)
+    protected function getAutoloadRealFile($usePSR0, $useClassMap, $useIncludePath, $targetDirLoader, $useIncludeFiles, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader)
     {
         // TODO the class ComposerAutoloaderInit should be revert to a closure
         // when APC has been fixed:
@@ -396,7 +397,7 @@ class ComposerAutoloaderInit$suffix
             return self::\$loader;
         }
 
-        spl_autoload_register(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'), true, true);
+        spl_autoload_register(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'), true, $prependAutoloader);
         self::\$loader = \$loader = new \\Composer\\Autoload\\ClassLoader();
         spl_autoload_unregister(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'));
 
@@ -455,7 +456,7 @@ REGISTER_AUTOLOAD;
         }
 
         $file .= <<<REGISTER_LOADER
-        \$loader->register(true);
+        \$loader->register($prependAutoloader);
 
 
 REGISTER_LOADER;

+ 1 - 0
src/Composer/Config.php

@@ -35,6 +35,7 @@ class Config
         'cache-files-ttl' => null, // fallback to cache-ttl
         'cache-files-maxsize' => '300MiB',
         'discard-changes' => false,
+        'prepend-autoloader' => true,
     );
 
     public static $defaultRepositories = array(