From 625b472b10223156be81baaa337ef3caedfab198 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 10 Mar 2020 16:25:41 +0100 Subject: [PATCH 1/4] Fix changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 045b45c1e..f8784b324 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 versions 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 From cd949745c3252838452fe04b89e29103c632688a Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 10 Mar 2020 16:27:12 +0100 Subject: [PATCH 2/4] Typo --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8784b324..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 third-party tools can know which Composer versions was used to generate a lock file + * 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 From d271004b308c9c584e1dd4eb7b49647e4ba220e4 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 10 Mar 2020 17:00:28 +0100 Subject: [PATCH 3/4] Also check for package requiring itself in require, not only require-dev --- src/Composer/Package/Loader/RootPackageLoader.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Composer/Package/Loader/RootPackageLoader.php b/src/Composer/Package/Loader/RootPackageLoader.php index 84e99a857..2115d7378 100644 --- a/src/Composer/Package/Loader/RootPackageLoader.php +++ b/src/Composer/Package/Loader/RootPackageLoader.php @@ -139,6 +139,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'])); + } } } @@ -154,11 +159,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); From 3e82542812333928de365dbeb0bcf3974fe2f6f9 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 10 Mar 2020 17:11:19 +0100 Subject: [PATCH 4/4] Fix test --- .../Test/Fixtures/installer/install-self-from-root.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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?