ソースを参照

Fixed creating shortest paths in AutoloadGenerator

Martin Hasoň 13 年 前
コミット
afc04c9e53
1 ファイル変更3 行追加7 行削除
  1. 3 7
      src/Composer/Autoload/AutoloadGenerator.php

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

@@ -58,7 +58,7 @@ EOF;
 
         $filesystem = new Filesystem();
         $vendorPath = strtr(realpath($installationManager->getVendorPath()), '\\', '/');
-        $relVendorPath = $filesystem->findShortestPath(getcwd(), $vendorPath);
+        $relVendorPath = $filesystem->findShortestPath(getcwd().'/inDir', $vendorPath);
         $vendorDirCode = $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true);
 
         $appBaseDir = $filesystem->findShortestPathCode($vendorPath, getcwd(), true);
@@ -85,11 +85,7 @@ EOF;
                 $path = strtr($path, '\\', '/');
                 $baseDir = '';
                 if (!$filesystem->isAbsolutePath($path)) {
-                    // vendor dir == working dir
-                    if (preg_match('{^(\./?)?$}', $relVendorPath)) {
-                        $path = '/'.$path;
-                        $baseDir = '$vendorDir . ';
-                    } elseif (strpos($path, $relVendorPath) === 0) {
+                    if (strpos($path, $relVendorPath) === 0) {
                         // path starts with vendor dir
                         $path = substr($path, strlen($relVendorPath));
                         $baseDir = '$vendorDir . ';
@@ -129,7 +125,7 @@ EOF;
         $autoloads['classmap'] = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($autoloads['classmap']));
         foreach ($autoloads['classmap'] as $dir) {
             foreach (ClassMapGenerator::createMap($dir) as $class => $path) {
-                $path = '/'.$filesystem->findShortestPath(getcwd(), $path);
+                $path = '/'.$filesystem->findShortestPath(getcwd().'/inDir', $path);
                 $classmapFile .= '    '.var_export($class, true).' => $baseDir . '.var_export($path, true).",\n";
             }
         }