Skip to content

Commit 8805dc0

Browse files
committed
Update composer
1 parent 07763f4 commit 8805dc0

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

src/core/Server/Admin.php

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -353,29 +353,31 @@ function (Server $server, $msg) {
353353
'get_composer_packages',
354354
$accepted_process_types,
355355
function (Server $server, $msg) {
356+
if (!class_exists(\Composer\InstalledVersions::class)) {
357+
return self::json('require composer 2.0', 4003);
358+
}
359+
356360
$list = [];
357-
if (class_exists(\Composer\InstalledVersions::class)) {
358-
foreach (['getAllRawData', 'getRawData'] as $method) {
359-
if (method_exists(\Composer\InstalledVersions::class, $method)) {
360-
if ($method === 'getAllRawData') {
361-
$raw_data = \Composer\InstalledVersions::$method();
362-
array_shift($raw_data);
363-
} else {
364-
$raw_data[] = \Composer\InstalledVersions::$method();
365-
}
366-
foreach ($raw_data as $key => $package) {
367-
$key_name = $package['root']['name'];
368-
if ($package['root']['name'] === '__root__' && isset($list['__root__'])) {
369-
$key_name = "__root__{$key}";
370-
}
371-
$package['root']['install_path'] = realpath($package['root']['install_path']);
372-
$list[$key_name] = $package;
373-
}
374-
break;
361+
foreach (['getAllRawData', 'getRawData'] as $method) {
362+
if (!method_exists(\Composer\InstalledVersions::class, $method)) {
363+
continue;
364+
}
365+
366+
$raw_data[] = \Composer\InstalledVersions::$method();
367+
if ($method === 'getAllRawData') {
368+
$raw_data = \Composer\InstalledVersions::$method();
369+
array_shift($raw_data);
370+
}
371+
372+
foreach ($raw_data as $key => $package) {
373+
$key_name = $package['root']['name'];
374+
if ($package['root']['name'] === '__root__' && isset($list['__root__'])) {
375+
$key_name = "__root__{$key}";
375376
}
377+
$package['root']['install_path'] = realpath($package['root']['install_path']);
378+
$list[$key_name] = $package;
376379
}
377-
} else {
378-
return self::json('require composer 2.0', 4003);
380+
break;
379381
}
380382
return self::json($list);
381383
}

0 commit comments

Comments
 (0)