From 9327a3e8b46bb49262a674655114d25031f1677c Mon Sep 17 00:00:00 2001 From: zumba Date: Tue, 15 Feb 2022 09:20:36 +0200 Subject: [PATCH] Handle missing license when showing license summary Fixes the issue of license summary command aborting when a package is missing license information. --- src/Composer/Command/LicensesCommand.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Composer/Command/LicensesCommand.php b/src/Composer/Command/LicensesCommand.php index 5375ab08dcfc..a8aadd021adb 100644 --- a/src/Composer/Command/LicensesCommand.php +++ b/src/Composer/Command/LicensesCommand.php @@ -125,7 +125,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $usedLicenses = array(); foreach ($packages as $package) { $license = $package instanceof CompletePackageInterface ? $package->getLicense() : array(); - $licenseName = $license[0]; + $licenseName = array_key_exists(0, $license) ? $license[0] : 'none'; + if (!isset($usedLicenses[$licenseName])) { $usedLicenses[$licenseName] = 0; }