瀏覽代碼

Tweak license deprecation text to handle + more gracefully, fixes #6981

Jordi Boggiano 7 年之前
父節點
當前提交
188b3a35c8
共有 1 個文件被更改,包括 6 次插入1 次删除
  1. 6 1
      src/Composer/Package/Loader/ValidatingArrayLoader.php

+ 6 - 1
src/Composer/Package/Loader/ValidatingArrayLoader.php

@@ -125,7 +125,12 @@ class ValidatingArrayLoader implements LoaderInterface
                     foreach ($licenses as $license) {
                         $spdxLicense = $licenseValidator->getLicenseByIdentifier($license);
                         if ($spdxLicense && $spdxLicense[3]) {
-                            if (preg_match('{^[AL]?GPL-[123](\.[01])?\+?$}i', $license)) {
+                            if (preg_match('{^[AL]?GPL-[123](\.[01])?\+$}i', $license)) {
+                                $this->warnings[] = sprintf(
+                                    'License "%s" is a deprecated SPDX license identifier, use "'.str_replace('+', '', $license).'-or-later" instead',
+                                    $license
+                                );
+                            } elseif (preg_match('{^[AL]?GPL-[123](\.[01])?$}i', $license)) {
                                 $this->warnings[] = sprintf(
                                     'License "%s" is a deprecated SPDX license identifier, use "'.$license.'-only" or "'.$license.'-or-later" instead',
                                     $license