From f516d36f6f9315725635fa5276774b3f70132a95 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 25 Aug 2020 15:37:28 +0200 Subject: [PATCH] Make sure Request::requireName can not be called twice for the same name --- src/Composer/DependencyResolver/Request.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Composer/DependencyResolver/Request.php b/src/Composer/DependencyResolver/Request.php index 332ead628..c3367e3d9 100644 --- a/src/Composer/DependencyResolver/Request.php +++ b/src/Composer/DependencyResolver/Request.php @@ -56,7 +56,14 @@ class Request public function requireName($packageName, ConstraintInterface $constraint = null) { $packageName = strtolower($packageName); - $this->requires[$packageName] = $constraint ? $constraint : new MatchAllConstraint(); + + if ($constraint === null) { + $constraint = new MatchAllConstraint(); + } + if (isset($this->requires[$packageName])) { + throw new \LogicException('Overwriting requires seems like a bug ('.$packageName.' '.$this->requires[$packageName]->getPrettyConstraint().' => '.$constraint->getPrettyConstraint().', check why it is happening, might be a root alias'); + } + $this->requires[$packageName] = $constraint; } /**