1
0
Fork 0

Reverse-orders namespaces by specificity

pull/80/merge
Jordi Boggiano 2011-11-03 21:05:01 +01:00
parent 0cfbea624e
commit bd712db727
1 changed files with 15 additions and 9 deletions

View File

@ -73,11 +73,9 @@ EOF;
if (isset($autoloads['psr-0'])) {
foreach ($autoloads['psr-0'] as $def) {
foreach ($def['mapping'] as $prefix => $path) {
$exportedPrefix = var_export($prefix, true);
$exportedPath = var_export(($def['path'] ? '/'.$def['path'] : '').'/'.$path, true);
$namespacesFile .= " $exportedPrefix => dirname(dirname(__DIR__)).$exportedPath,\n";
}
$exportedPrefix = var_export($def['namespace'], true);
$exportedPath = var_export($def['path'], true);
$namespacesFile .= " $exportedPrefix => dirname(dirname(__DIR__)).$exportedPath,\n";
}
}
@ -107,13 +105,21 @@ EOF;
}
foreach ($package->getAutoload() as $type => $mapping) {
$autoloads[$type][] = array(
'mapping' => $mapping,
'path' => $installPath,
);
foreach ($mapping as $namespace => $path) {
$autoloads[$type][] = array(
'namespace' => $namespace,
'path' => ($installPath ? '/'.$installPath : '').'/'.$path,
);
}
}
}
foreach ($autoloads as $type => $maps) {
usort($autoloads[$type], function ($a, $b) {
return strcmp($b['namespace'], $a['namespace']);
});
}
return $autoloads;
}
}