Skip to content

Commit

Permalink
Handle missing license when showing license summary (#10537)
Browse files Browse the repository at this point in the history
Fixes the issue of license summary command aborting when a package is
missing license information.
  • Loading branch information
gzumba committed Feb 16, 2022
1 parent a3e6af5 commit 8756f54
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Composer/Command/LicensesCommand.php
Expand Up @@ -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;
}
Expand Down

0 comments on commit 8756f54

Please sign in to comment.