diff --git a/CHANGELOG.md b/CHANGELOG.md index 045b45c1e..9c1156f66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ ### [1.10.0] 2020-03-10 * Added `bearer` auth config to authenticate using `Authorization: Bearer ` 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 diff --git a/src/Composer/Package/Loader/RootPackageLoader.php b/src/Composer/Package/Loader/RootPackageLoader.php index bf79d654e..3dfe3b7d2 100644 --- a/src/Composer/Package/Loader/RootPackageLoader.php +++ b/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); diff --git a/tests/Composer/Test/Fixtures/installer/install-self-from-root.test b/tests/Composer/Test/Fixtures/installer/install-self-from-root.test index 82092c77f..a994d0c44 100644 --- a/tests/Composer/Test/Fixtures/installer/install-self-from-root.test +++ b/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?