Browse Source

Also check for package requiring itself in require, not only require-dev

Jordi Boggiano 5 years ago
parent
commit
d271004b30
1 changed files with 5 additions and 5 deletions
  1. 5 5
      src/Composer/Package/Loader/RootPackageLoader.php

+ 5 - 5
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);