Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Errors when installing package that defines multiple Paths for a PSR-4 Autoload #40

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 44 additions & 40 deletions src/ComponentInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,48 +222,52 @@ private function loadModuleClassesDependencies(PackageInterface $package)

$autoload = $package->getAutoload();
foreach ($autoload as $type => $map) {
foreach ($map as $namespace => $path) {
switch ($type) {
case 'classmap':
$fullPath = sprintf('%s/%s', $packagePath, $path);
if (is_dir(rtrim($fullPath, '/'))) {
$modulePath = sprintf('%s%s', $fullPath, 'Module.php');
} elseif (substr($path, -10) === 'Module.php') {
$modulePath = $fullPath;
} else {
foreach ($map as $namespace => $paths) {
$paths = (array)$paths;

foreach ($paths as $path) {
switch ($type) {
case 'classmap':
$fullPath = sprintf('%s/%s', $packagePath, $path);
if (is_dir(rtrim($fullPath, '/'))) {
$modulePath = sprintf('%s%s', $fullPath, 'Module.php');
} elseif (substr($path, -10) === 'Module.php') {
$modulePath = $fullPath;
} else {
continue 2;
}
break;
case 'files':
if (substr($path, -10) !== 'Module.php') {
continue 2;
}
$modulePath = sprintf('%s/%s', $packagePath, $path);
break;
case 'psr-0':
$modulePath = sprintf(
'%s/%s%s%s',
$packagePath,
$path,
str_replace('\\', '/', $namespace),
'Module.php'
);
break;
case 'psr-4':
$modulePath = sprintf(
'%s/%s%s',
$packagePath,
$path,
'Module.php'
);
break;
default:
continue 2;
}
break;
case 'files':
if (substr($path, -10) !== 'Module.php') {
continue 2;
}
$modulePath = sprintf('%s/%s', $packagePath, $path);
break;
case 'psr-0':
$modulePath = sprintf(
'%s/%s%s%s',
$packagePath,
$path,
str_replace('\\', '/', $namespace),
'Module.php'
);
break;
case 'psr-4':
$modulePath = sprintf(
'%s/%s%s',
$packagePath,
$path,
'Module.php'
);
break;
default:
continue 2;
}
}

if (file_exists($modulePath)) {
if ($result = $this->getModuleDependencies($modulePath)) {
$dependencies += $result;
if (file_exists($modulePath)) {
if ($result = $this->getModuleDependencies($modulePath)) {
$dependencies += $result;
}
}
}
}
Expand Down