1
0
Fork 0

Normalize namespaces in psr-0/psr-4 rules to fix edge cases, fixes #12028 (#12063)

pull/12090/head
Jordi Boggiano 2024-08-19 13:52:44 +02:00 committed by GitHub
parent 9da1948585
commit 3ba58ea3eb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 0 deletions

View File

@ -1241,6 +1241,10 @@ INITIALIZER;
} }
foreach ($autoload[$type] as $namespace => $paths) { foreach ($autoload[$type] as $namespace => $paths) {
if (in_array($type, ['psr-4', 'psr-0'], true)) {
// normalize namespaces to ensure "\" becomes "" and others do not have leading separators as they are not needed
$namespace = ltrim($namespace, '\\');
}
foreach ((array) $paths as $path) { foreach ((array) $paths as $path) {
if (($type === 'files' || $type === 'classmap' || $type === 'exclude-from-classmap') && $package->getTargetDir() && !Filesystem::isReadable($installPath.'/'.$path)) { if (($type === 'files' || $type === 'classmap' || $type === 'exclude-from-classmap') && $package->getTargetDir() && !Filesystem::isReadable($installPath.'/'.$path)) {
// remove target-dir from file paths of the root package // remove target-dir from file paths of the root package