From 8e6422946193a4859118c29511a8f24c6524a32f Mon Sep 17 00:00:00 2001 From: Justin Rainbow Date: Wed, 1 Feb 2012 09:31:27 -0700 Subject: [PATCH 1/6] Increasing version number to include 5.3.3 which also has an issue with SplFixedArray --- src/Composer/DependencyResolver/Solver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); From d27989c808764b0ea2336f52f894d40040c780f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Haso=C5=88?= Date: Tue, 31 Jan 2012 15:04:49 +0100 Subject: [PATCH 2/6] Fixed obscure code --- src/Composer/Autoload/AutoloadGenerator.php | 2 +- tests/Composer/Test/Autoload/AutoloadGeneratorTest.php | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Composer/Autoload/AutoloadGenerator.php b/src/Composer/Autoload/AutoloadGenerator.php index 47e75a944..78eb09f2f 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 = <<assertAutoloadFiles('main', $this->vendorDir.'/.composer'); } + public function testVendorDirSameAsWorkingDir() + { + chdir($this->vendorDir); + $this->testMainPackageAutoloading(); + } + public function testMainPackageAutoloadingAlternativeVendorDir() { $package = new MemoryPackage('a', '1.0', '1.0'); From 15d78e6ad189a6a5f84281e37cc783a25eb49044 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 2 Feb 2012 16:38:48 +0100 Subject: [PATCH 3/6] Fix autoload generator with vendor-dir = working-dir --- src/Composer/Autoload/AutoloadGenerator.php | 7 ++++++- .../Test/Autoload/AutoloadGeneratorTest.php | 13 +++++++++++-- .../Test/Autoload/Fixtures/autoload_main3.php | 10 ++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 tests/Composer/Test/Autoload/Fixtures/autoload_main3.php diff --git a/src/Composer/Autoload/AutoloadGenerator.php b/src/Composer/Autoload/AutoloadGenerator.php index 78eb09f2f..f58b427b1 100644 --- a/src/Composer/Autoload/AutoloadGenerator.php +++ b/src/Composer/Autoload/AutoloadGenerator.php @@ -93,7 +93,12 @@ EOF; $path = strtr($path, '\\', '/'); $baseDir = ''; if (!$filesystem->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/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php index d444e5dfa..329615240 100644 --- a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php +++ b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php @@ -79,8 +79,17 @@ class AutoloadGeneratorTest extends \PHPUnit_Framework_TestCase public function testVendorDirSameAsWorkingDir() { - chdir($this->vendorDir); - $this->testMainPackageAutoloading(); + $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())); + + $this->generator->dump($this->repo, $package, $this->im, $this->vendorDir.'/.composer'); + $this->assertAutoloadFiles('main3', $this->vendorDir.'/.composer'); } public function testMainPackageAutoloadingAlternativeVendorDir() 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/', +); From 3f7e7dff336e6282f92110d67c2c9115a17d1f16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draic=20Brady?= Date: Thu, 2 Feb 2012 19:57:37 +0000 Subject: [PATCH 4/6] Fix a small bug where some PEAR channels' category link href doesn't contain a starting forward slash --- src/Composer/Repository/PearRepository.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Composer/Repository/PearRepository.php b/src/Composer/Repository/PearRepository.php index 0e00a39c7..900abd805 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 ($categoryLink[0] != '/') { + $categoryLink = '/' . $categoryLink; + } $packagesXML = $this->requestXml($this->url . $categoryLink); $packages = $packagesXML->getElementsByTagName('p'); From 568d9dabf612729bac1a209127780c922739da1c Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 3 Feb 2012 20:32:09 +0100 Subject: [PATCH 5/6] fix previous commit --- src/Composer/Repository/PearRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Repository/PearRepository.php b/src/Composer/Repository/PearRepository.php index 900abd805..51c1722b4 100644 --- a/src/Composer/Repository/PearRepository.php +++ b/src/Composer/Repository/PearRepository.php @@ -53,7 +53,7 @@ class PearRepository extends ArrayRepository foreach ($categories as $category) { $categoryLink = $category->getAttribute("xlink:href"); $categoryLink = str_replace("info.xml", "packages.xml", $categoryLink); - if ($categoryLink[0] != '/') { + if ('/' !== substr($categoryLink, 0, 1)) { $categoryLink = '/' . $categoryLink; } $packagesXML = $this->requestXml($this->url . $categoryLink); From d18e749f852b5fc004c0ba78b70e5ddb58d8bee8 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 3 Feb 2012 20:33:57 +0100 Subject: [PATCH 6/6] Test fix, fixes #274 --- tests/Composer/Test/Autoload/AutoloadGeneratorTest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php index 329615240..f7eee0d69 100644 --- a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php +++ b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php @@ -88,6 +88,9 @@ class AutoloadGeneratorTest extends \PHPUnit_Framework_TestCase ->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'); }