Procházet zdrojové kódy

Fix multi-prefix handling

Jordi Boggiano před 13 roky
rodič
revize
51711c2f73

+ 1 - 1
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);

+ 2 - 2
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')

+ 1 - 1
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;