Make sure Request::requireName can not be called twice for the same name

main
Jordi Boggiano 4 years ago
parent 00e268cdbf
commit f516d36f6f
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC

@ -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;
}
/**

Loading…
Cancel
Save