1
0
Fork 0

Make sure there's always a constraint

pull/8850/head
Yanick Witschi 2020-04-24 17:42:24 +02:00 committed by Jordi Boggiano
parent 912aecb666
commit 10555ecff3
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
3 changed files with 6 additions and 8 deletions

View File

@ -294,10 +294,6 @@ class PoolBuilder
$this->io->writeError('<warning>Dependency "'.$require.'" is also a root requirement. Package has not been listed as an update argument, so keeping locked at old version. Use --with-all-dependencies to include root dependencies.</warning>');
}
} else {
if (null === $this->loadedNames[$require] || null === $linkConstraint) {
unset($this->loadedNames[$require]);
}
if (!$this->loadedNames[$require]->matches($linkConstraint)) {
$loadNames[$require] = MultiConstraint::create(array($this->loadedNames[$require], $linkConstraint), false);
unset($this->loadedNames[$require]);
@ -313,7 +309,7 @@ class PoolBuilder
if (isset($this->loadedNames[$replace]) && isset($this->skippedLoad[$replace])) {
if ($request->getUpdateAllowTransitiveRootDependencies() || !$this->isRootRequire($request, $this->skippedLoad[$replace])) {
$this->unfixPackage($request, $replace);
$loadNames[$replace] = null;
$loadNames[$replace] = $link->getConstraint();
} elseif (!$request->getUpdateAllowTransitiveRootDependencies() && $this->isRootRequire($request, $replace) && !isset($this->updateAllowWarned[$replace])) {
$this->updateAllowWarned[$replace] = true;
$this->io->writeError('<warning>Dependency "'.$replace.'" is also a root requirement. Package has not been listed as an update argument, so keeping locked at old version. Use --with-all-dependencies to include root dependencies.</warning>');

View File

@ -17,6 +17,7 @@ use Composer\Package\PackageInterface;
use Composer\Package\RootAliasPackage;
use Composer\Repository\LockArrayRepository;
use Composer\Semver\Constraint\ConstraintInterface;
use Composer\Semver\Constraint\EmptyConstraint;
/**
* @author Nils Adermann <naderman@naderman.de>
@ -55,7 +56,7 @@ class Request
public function requireName($packageName, ConstraintInterface $constraint = null)
{
$packageName = strtolower($packageName);
$this->requires[$packageName] = $constraint;
$this->requires[$packageName] = $constraint ? $constraint : new EmptyConstraint();
}
/**

View File

@ -13,6 +13,7 @@
namespace Composer\Package;
use Composer\Semver\Constraint\ConstraintInterface;
use Composer\Semver\Constraint\EmptyConstraint;
/**
* Represents a link between two packages, represented by their names
@ -59,7 +60,7 @@ class Link
{
$this->source = strtolower($source);
$this->target = strtolower($target);
$this->constraint = $constraint;
$this->constraint = $constraint ? $constraint : new EmptyConstraint();
$this->description = $description;
$this->prettyConstraint = $prettyConstraint;
}
@ -89,7 +90,7 @@ class Link
}
/**
* @return ConstraintInterface|null
* @return ConstraintInterface
*/
public function getConstraint()
{