1
0
Fork 0

Fix multi-prefix handling

pull/602/head
Jordi Boggiano 2012-04-19 22:04:49 +02:00
parent a9176acecc
commit 51711c2f73
3 changed files with 4 additions and 4 deletions

View File

@ -84,7 +84,7 @@ EOF;
$mainAutoload = $mainPackage->getAutoload(); $mainAutoload = $mainPackage->getAutoload();
if ($mainPackage->getTargetDir() && $mainAutoload['psr-0']) { if ($mainPackage->getTargetDir() && $mainAutoload['psr-0']) {
$levels = count(explode('/', trim(strtr($mainPackage->getTargetDir(), '\\', '/'), '/'))); $levels = count(explode('/', trim(strtr($mainPackage->getTargetDir(), '\\', '/'), '/')));
$prefixes = implode("', '", array_map(function ($prefix) { $prefixes = implode(', ', array_map(function ($prefix) {
return var_export($prefix, true); return var_export($prefix, true);
}, array_keys($mainAutoload['psr-0']))); }, array_keys($mainAutoload['psr-0'])));
$baseDirFromTargetDirCode = $filesystem->findShortestPathCode(realpath($targetDir), getcwd(), true); $baseDirFromTargetDirCode = $filesystem->findShortestPathCode(realpath($targetDir), getcwd(), true);

View File

@ -145,9 +145,9 @@ class AutoloadGeneratorTest extends TestCase
{ {
$package = new MemoryPackage('a', '1.0', '1.0'); $package = new MemoryPackage('a', '1.0', '1.0');
$package->setAutoload(array( $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()) $this->repository->expects($this->once())
->method('getPackages') ->method('getPackages')

View File

@ -19,7 +19,7 @@ return call_user_func(function() {
} }
spl_autoload_register(function($class) { spl_autoload_register(function($class) {
$prefixes = array('Main\\Foo'); $prefixes = array('Main\\Foo', 'Main\\Bar');
foreach ($prefixes as $prefix) { foreach ($prefixes as $prefix) {
if (0 !== strpos($class, $prefix)) { if (0 !== strpos($class, $prefix)) {
continue; continue;