From 51711c2f73e0382e0394049356d0d8ca4bb77abb Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 19 Apr 2012 22:04:49 +0200 Subject: [PATCH] Fix multi-prefix handling --- src/Composer/Autoload/AutoloadGenerator.php | 2 +- tests/Composer/Test/Autoload/AutoloadGeneratorTest.php | 4 ++-- tests/Composer/Test/Autoload/Fixtures/autoload_target_dir.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Composer/Autoload/AutoloadGenerator.php b/src/Composer/Autoload/AutoloadGenerator.php index 8b32cc181..38421b375 100644 --- a/src/Composer/Autoload/AutoloadGenerator.php +++ b/src/Composer/Autoload/AutoloadGenerator.php @@ -84,7 +84,7 @@ EOF; $mainAutoload = $mainPackage->getAutoload(); if ($mainPackage->getTargetDir() && $mainAutoload['psr-0']) { $levels = count(explode('/', trim(strtr($mainPackage->getTargetDir(), '\\', '/'), '/'))); - $prefixes = implode("', '", array_map(function ($prefix) { + $prefixes = implode(', ', array_map(function ($prefix) { return var_export($prefix, true); }, array_keys($mainAutoload['psr-0']))); $baseDirFromTargetDirCode = $filesystem->findShortestPathCode(realpath($targetDir), getcwd(), true); diff --git a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php index 089b40adb..5cabfd2df 100644 --- a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php +++ b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php @@ -145,9 +145,9 @@ class AutoloadGeneratorTest extends TestCase { $package = new MemoryPackage('a', '1.0', '1.0'); $package->setAutoload(array( - 'psr-0' => array('Main\\Foo' => ''), + 'psr-0' => array('Main\\Foo' => '', 'Main\\Bar' => ''), )); - $package->setTargetDir('Main/Foo'); + $package->setTargetDir('Main/Foo/'); $this->repository->expects($this->once()) ->method('getPackages') diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_target_dir.php b/tests/Composer/Test/Autoload/Fixtures/autoload_target_dir.php index 8e70900f0..f2acfcc3b 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_target_dir.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_target_dir.php @@ -19,7 +19,7 @@ return call_user_func(function() { } spl_autoload_register(function($class) { - $prefixes = array('Main\\Foo'); + $prefixes = array('Main\\Foo', 'Main\\Bar'); foreach ($prefixes as $prefix) { if (0 !== strpos($class, $prefix)) { continue;