Browse Source

Merge branch 'master' into 2.0

Jordi Boggiano 5 years ago
parent
commit
97e2a249e8

+ 1 - 1
CHANGELOG.md

@@ -1,7 +1,7 @@
 ### [1.10.0] 2020-03-10
 
   * Added `bearer` auth config to authenticate using `Authorization: Bearer <token>` headers
-  * Added `plugin-api-version` in composer.lock so future Composer versions know if they are running a lock file which was not built by the correct version
+  * Added `plugin-api-version` in composer.lock so third-party tools can know which Composer version was used to generate a lock file
   * Fixed composer fund command and funding info parsing to be more useful
   * Fixed issue where --no-dev autoload generation was excluding some packages which should not have been excluded
   * Fixed 1.10-RC regression in create project's handling of absolute paths

+ 5 - 5
src/Composer/Package/Loader/RootPackageLoader.php

@@ -137,6 +137,11 @@ class RootPackageLoader extends ArrayLoader
                 $aliases = $this->extractAliases($links, $aliases);
                 $stabilityFlags = $this->extractStabilityFlags($links, $stabilityFlags, $realPackage->getMinimumStability());
                 $references = $this->extractReferences($links, $references);
+
+                if (isset($links[$config['name']])) {
+                    throw new \RuntimeException(sprintf('Root package \'%s\' cannot require itself in its composer.json' . PHP_EOL .
+                                'Did you accidentally name your root package after an external package?', $config['name']));
+                }
             }
         }
 
@@ -150,11 +155,6 @@ class RootPackageLoader extends ArrayLoader
             }
         }
 
-        if (isset($links[$config['name']])) {
-            throw new \InvalidArgumentException(sprintf('Root package \'%s\' cannot require itself in its composer.json' . PHP_EOL .
-                        'Did you accidentally name your root package after an external package?', $config['name']));
-        }
-
         $realPackage->setAliases($aliases);
         $realPackage->setStabilityFlags($stabilityFlags);
         $realPackage->setReferences($references);

+ 1 - 1
tests/Composer/Test/Fixtures/installer/install-self-from-root.test

@@ -10,7 +10,7 @@ Tries to require a package with the same name as the root package
 --RUN--
 install
 --EXPECT-EXCEPTION--
-InvalidArgumentException
+RuntimeException
 --EXPECT--
 Root package 'foo/bar' cannot require itself in its composer.json
 Did you accidentally name your root package after an external package?