From afc04c9e53bfad3029a1927b25455302e4fcd6f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Haso=C5=88?= Date: Wed, 21 Mar 2012 14:29:24 +0100 Subject: [PATCH] Fixed creating shortest paths in AutoloadGenerator --- src/Composer/Autoload/AutoloadGenerator.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/Composer/Autoload/AutoloadGenerator.php b/src/Composer/Autoload/AutoloadGenerator.php index 036b40b95..f504a6bca 100644 --- a/src/Composer/Autoload/AutoloadGenerator.php +++ b/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"; } }