diff --git a/src/Composer/Autoload/AutoloadGenerator.php b/src/Composer/Autoload/AutoloadGenerator.php index 47e75a944..f58b427b1 100644 --- a/src/Composer/Autoload/AutoloadGenerator.php +++ b/src/Composer/Autoload/AutoloadGenerator.php @@ -54,7 +54,7 @@ EOF; $filesystem = new Filesystem(); $vendorPath = strtr(realpath($installationManager->getVendorPath()), '\\', '/'); - $relVendorPath = ltrim(substr($vendorPath, strlen(getcwd())), '/'); + $relVendorPath = $filesystem->findShortestPath(getcwd(), $vendorPath); $vendorDirCode = $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true); $namespacesFile = <<isAbsolutePath($path)) { - if (strpos($path, $relVendorPath) === 0) { + // vendor dir == working dir + if (preg_match('{^(\./?)?$}', $relVendorPath)) { + $path = '/'.$path; + $baseDir = '$vendorDir . '; + } elseif (strpos($path, $relVendorPath) === 0) { + // path starts with vendor dir $path = substr($path, strlen($relVendorPath)); $baseDir = '$vendorDir . '; } else { diff --git a/src/Composer/DependencyResolver/Solver.php b/src/Composer/DependencyResolver/Solver.php index 9f1d1f4ca..2fa38b55e 100644 --- a/src/Composer/DependencyResolver/Solver.php +++ b/src/Composer/DependencyResolver/Solver.php @@ -937,7 +937,7 @@ class Solver $this->installedMap[$package->getId()] = $package; } - if (version_compare(PHP_VERSION, '5.3.2', '>')) { + if (version_compare(PHP_VERSION, '5.3.3', '>')) { $this->decisionMap = new \SplFixedArray($this->pool->getMaxId() + 1); } else { $this->decisionMap = array_fill(0, $this->pool->getMaxId() + 1, 0); diff --git a/src/Composer/Repository/PearRepository.php b/src/Composer/Repository/PearRepository.php index 0e00a39c7..51c1722b4 100644 --- a/src/Composer/Repository/PearRepository.php +++ b/src/Composer/Repository/PearRepository.php @@ -53,6 +53,9 @@ class PearRepository extends ArrayRepository foreach ($categories as $category) { $categoryLink = $category->getAttribute("xlink:href"); $categoryLink = str_replace("info.xml", "packages.xml", $categoryLink); + if ('/' !== substr($categoryLink, 0, 1)) { + $categoryLink = '/' . $categoryLink; + } $packagesXML = $this->requestXml($this->url . $categoryLink); $packages = $packagesXML->getElementsByTagName('p'); diff --git a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php index 7a9460d8b..f7eee0d69 100644 --- a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php +++ b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php @@ -77,6 +77,24 @@ class AutoloadGeneratorTest extends \PHPUnit_Framework_TestCase $this->assertAutoloadFiles('main', $this->vendorDir.'/.composer'); } + public function testVendorDirSameAsWorkingDir() + { + $this->vendorDir = $this->workingDir; + + $package = new MemoryPackage('a', '1.0', '1.0'); + $package->setAutoload(array('psr-0' => array('Main' => 'src/', 'Lala' => 'src/'))); + + $this->repo->expects($this->once()) + ->method('getPackages') + ->will($this->returnValue(array())); + + if (!is_dir($this->vendorDir.'/.composer')) { + mkdir($this->vendorDir.'/.composer', 0777, true); + } + $this->generator->dump($this->repo, $package, $this->im, $this->vendorDir.'/.composer'); + $this->assertAutoloadFiles('main3', $this->vendorDir.'/.composer'); + } + public function testMainPackageAutoloadingAlternativeVendorDir() { $package = new MemoryPackage('a', '1.0', '1.0'); diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_main3.php b/tests/Composer/Test/Autoload/Fixtures/autoload_main3.php new file mode 100644 index 000000000..6f12b3d75 --- /dev/null +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_main3.php @@ -0,0 +1,10 @@ + $vendorDir . '/src/', + 'Lala' => $vendorDir . '/src/', +);