Fix multi-prefix handling
parent
a9176acecc
commit
51711c2f73
|
@ -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);
|
||||||
|
|
|
@ -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')
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue