1
0
Fork 0

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

pull/8850/head
Jordi Boggiano 2020-08-25 15:37:28 +02:00
parent 00e268cdbf
commit f516d36f6f
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
1 changed files with 8 additions and 1 deletions

View File

@ -56,7 +56,14 @@ class Request
public function requireName($packageName, ConstraintInterface $constraint = null) public function requireName($packageName, ConstraintInterface $constraint = null)
{ {
$packageName = strtolower($packageName); $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;
} }
/** /**