瀏覽代碼

Fix target-dir autoloader

Jordi Boggiano 13 年之前
父節點
當前提交
aff7745231

+ 3 - 3
src/Composer/Autoload/AutoloadGenerator.php

@@ -88,12 +88,12 @@ EOF;
             $prefixes = implode(', ', array_map(function ($prefix) {
                 return var_export($prefix, true);
             }, array_keys($mainAutoload['psr-0'])));
-            $baseDirFromTargetDirCode = $filesystem->findShortestPathCode(realpath($targetDir), getcwd(), true);
+            $baseDirFromVendorDirCode = $filesystem->findShortestPathCode($vendorPath, getcwd(), true);
 
             $targetDirLoader = <<<EOF
     spl_autoload_register(function(\$class) {
-        static \$dir = $baseDirFromTargetDirCode . '/';
-        static \$prefixes = array($prefixes);
+        \$dir = $baseDirFromVendorDirCode . '/';
+        \$prefixes = array($prefixes);
         foreach (\$prefixes as \$prefix) {
             if (0 !== strpos(\$class, \$prefix)) {
                 continue;

+ 2 - 2
tests/Composer/Test/Autoload/Fixtures/autoload_target_dir.php

@@ -20,8 +20,8 @@ return call_user_func(function() {
     }
 
     spl_autoload_register(function($class) {
-        static $dir = dirname(dirname(__DIR__)) . '/';
-        static $prefixes = array('Main\\Foo', 'Main\\Bar');
+        $dir = dirname(__DIR__) . '/';
+        $prefixes = array('Main\\Foo', 'Main\\Bar');
         foreach ($prefixes as $prefix) {
             if (0 !== strpos($class, $prefix)) {
                 continue;