1
0
Fork 0

Use LockArrayRepository instead of RepositoryInterface to clearly indicate which type of repo it is in some places

pull/8531/head
Jordi Boggiano 2020-01-15 14:56:58 +01:00
parent 6c24e85e54
commit dd556f989b
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
4 changed files with 23 additions and 21 deletions

View File

@ -15,7 +15,7 @@ namespace Composer\DependencyResolver;
use Composer\Package\Package; use Composer\Package\Package;
use Composer\Package\PackageInterface; use Composer\Package\PackageInterface;
use Composer\Package\RootAliasPackage; use Composer\Package\RootAliasPackage;
use Composer\Repository\RepositoryInterface; use Composer\Repository\LockArrayRepository;
use Composer\Semver\Constraint\ConstraintInterface; use Composer\Semver\Constraint\ConstraintInterface;
/** /**
@ -28,7 +28,7 @@ class Request
protected $fixedPackages = array(); protected $fixedPackages = array();
protected $unlockables = array(); protected $unlockables = array();
public function __construct(RepositoryInterface $lockedRepository = null) public function __construct(LockArrayRepository $lockedRepository = null)
{ {
$this->lockedRepository = $lockedRepository; $this->lockedRepository = $lockedRepository;
} }

View File

@ -150,7 +150,7 @@ class Locker
* *
* @param bool $withDevReqs true to retrieve the locked dev packages * @param bool $withDevReqs true to retrieve the locked dev packages
* @throws \RuntimeException * @throws \RuntimeException
* @return \Composer\Repository\RepositoryInterface * @return \Composer\Repository\LockArrayRepository
*/ */
public function getLockedRepository($withDevReqs = false) public function getLockedRepository($withDevReqs = false)
{ {
@ -194,7 +194,7 @@ class Locker
return $packages; return $packages;
} }
throw new \RuntimeException('Your composer.lock was created before 2012-09-15, and is not supported anymore. Run "composer update" to generate a new one.'); throw new \RuntimeException('Your composer.lock is invalid. Run "composer update" to generate a new one.');
} }
/** /**

View File

@ -19,6 +19,7 @@ use Composer\Package\BasePackage;
use Composer\Package\Version\VersionParser; use Composer\Package\Version\VersionParser;
use Composer\Repository\CompositeRepository; use Composer\Repository\CompositeRepository;
use Composer\Repository\PlatformRepository; use Composer\Repository\PlatformRepository;
use Composer\Repository\LockArrayRepository;
use Composer\Semver\Constraint\ConstraintInterface; use Composer\Semver\Constraint\ConstraintInterface;
use Composer\Test\DependencyResolver\PoolTest; use Composer\Test\DependencyResolver\PoolTest;
@ -150,14 +151,15 @@ class RepositorySet
} }
// TODO unify this with above in some simpler version without "request"? // TODO unify this with above in some simpler version without "request"?
public function createPoolForPackage($packageName) public function createPoolForPackage($packageName, LockArrayRepository $lockedRepo = null)
{ {
return $this->createPoolForPackages(array($packageName)); return $this->createPoolForPackages(array($packageName), $lockedRepo);
} }
public function createPoolForPackages($packageNames) public function createPoolForPackages($packageNames, LockArrayRepository $lockedRepo = null)
{ {
$request = new Request(); $request = new Request($lockedRepo);
foreach ($packageNames as $packageName) { foreach ($packageNames as $packageName) {
$request->install($packageName); $request->install($packageName);
} }

View File

@ -48,7 +48,7 @@ class DefaultPolicyTest extends TestCase
$this->repo->addPackage($packageA = $this->getPackage('A', '1.0')); $this->repo->addPackage($packageA = $this->getPackage('A', '1.0'));
$this->repositorySet->addRepository($this->repo); $this->repositorySet->addRepository($this->repo);
$pool = $this->repositorySet->createPoolForPackage('A'); $pool = $this->repositorySet->createPoolForPackage('A', $this->repoLocked);
$literals = array($packageA->getId()); $literals = array($packageA->getId());
$expected = array($packageA->getId()); $expected = array($packageA->getId());
@ -64,7 +64,7 @@ class DefaultPolicyTest extends TestCase
$this->repo->addPackage($packageA2 = $this->getPackage('A', '2.0')); $this->repo->addPackage($packageA2 = $this->getPackage('A', '2.0'));
$this->repositorySet->addRepository($this->repo); $this->repositorySet->addRepository($this->repo);
$pool = $this->repositorySet->createPoolForPackage('A'); $pool = $this->repositorySet->createPoolForPackage('A', $this->repoLocked);
$literals = array($packageA1->getId(), $packageA2->getId()); $literals = array($packageA1->getId(), $packageA2->getId());
$expected = array($packageA2->getId()); $expected = array($packageA2->getId());
@ -80,7 +80,7 @@ class DefaultPolicyTest extends TestCase
$this->repo->addPackage($packageA2 = $this->getPackage('A', '1.0.1-alpha')); $this->repo->addPackage($packageA2 = $this->getPackage('A', '1.0.1-alpha'));
$this->repositorySet->addRepository($this->repo); $this->repositorySet->addRepository($this->repo);
$pool = $this->repositorySet->createPoolForPackage('A'); $pool = $this->repositorySet->createPoolForPackage('A', $this->repoLocked);
$literals = array($packageA1->getId(), $packageA2->getId()); $literals = array($packageA1->getId(), $packageA2->getId());
$expected = array($packageA2->getId()); $expected = array($packageA2->getId());
@ -96,7 +96,7 @@ class DefaultPolicyTest extends TestCase
$this->repo->addPackage($packageA2 = $this->getPackage('A', '1.0.1-alpha')); $this->repo->addPackage($packageA2 = $this->getPackage('A', '1.0.1-alpha'));
$this->repositorySet->addRepository($this->repo); $this->repositorySet->addRepository($this->repo);
$pool = $this->repositorySet->createPoolForPackage('A'); $pool = $this->repositorySet->createPoolForPackage('A', $this->repoLocked);
$literals = array($packageA1->getId(), $packageA2->getId()); $literals = array($packageA1->getId(), $packageA2->getId());
$expected = array($packageA1->getId()); $expected = array($packageA1->getId());
@ -113,7 +113,7 @@ class DefaultPolicyTest extends TestCase
$this->repo->addPackage($packageA2 = $this->getPackage('A', '1.0.0')); $this->repo->addPackage($packageA2 = $this->getPackage('A', '1.0.0'));
$this->repositorySet->addRepository($this->repo); $this->repositorySet->addRepository($this->repo);
$pool = $this->repositorySet->createPoolForPackage('A'); $pool = $this->repositorySet->createPoolForPackage('A', $this->repoLocked);
$literals = array($packageA1->getId(), $packageA2->getId()); $literals = array($packageA1->getId(), $packageA2->getId());
$expected = array($packageA2->getId()); $expected = array($packageA2->getId());
@ -136,7 +136,7 @@ class DefaultPolicyTest extends TestCase
$this->repositorySet->addRepository($repo1); $this->repositorySet->addRepository($repo1);
$this->repositorySet->addRepository($repo2); $this->repositorySet->addRepository($repo2);
$pool = $this->repositorySet->createPoolForPackage('A'); $pool = $this->repositorySet->createPoolForPackage('A', $this->repoLocked);
$literals = array($package1->getId(), $package2->getId(), $package3->getId(), $package4->getId()); $literals = array($package1->getId(), $package2->getId(), $package3->getId(), $package4->getId());
$expected = array($package2->getId()); $expected = array($package2->getId());
@ -148,7 +148,7 @@ class DefaultPolicyTest extends TestCase
$this->repositorySet->addRepository($repo2); $this->repositorySet->addRepository($repo2);
$this->repositorySet->addRepository($repo1); $this->repositorySet->addRepository($repo1);
$pool = $this->repositorySet->createPoolForPackage('A'); $pool = $this->repositorySet->createPoolForPackage('A', $this->repoLocked);
$expected = array($package4->getId()); $expected = array($package4->getId());
$selected = $this->policy->selectPreferredPackages($pool, $literals); $selected = $this->policy->selectPreferredPackages($pool, $literals);
@ -172,7 +172,7 @@ class DefaultPolicyTest extends TestCase
$this->repositorySet->addRepository($this->repo); $this->repositorySet->addRepository($this->repo);
$this->repositorySet->addRepository($this->repoLocked); $this->repositorySet->addRepository($this->repoLocked);
$pool = $this->repositorySet->createPoolForPackage('A'); $pool = $this->repositorySet->createPoolForPackage('A', $this->repoLocked);
$packages = $pool->whatProvides('a', new Constraint('=', '2.1.9999999.9999999-dev')); $packages = $pool->whatProvides('a', new Constraint('=', '2.1.9999999.9999999-dev'));
$literals = array(); $literals = array();
@ -197,7 +197,7 @@ class DefaultPolicyTest extends TestCase
$this->repositorySet->addRepository($this->repo); $this->repositorySet->addRepository($this->repo);
$pool = $this->repositorySet->createPoolForPackages(array('A', 'B')); $pool = $this->repositorySet->createPoolForPackages(array('A', 'B'), $this->repoLocked);
$literals = array($packageA->getId(), $packageB->getId()); $literals = array($packageA->getId(), $packageB->getId());
$expected = $literals; $expected = $literals;
@ -216,7 +216,7 @@ class DefaultPolicyTest extends TestCase
$this->repositorySet->addRepository($this->repo); $this->repositorySet->addRepository($this->repo);
$pool = $this->repositorySet->createPoolForPackages(array('A', 'B')); $pool = $this->repositorySet->createPoolForPackages(array('A', 'B'), $this->repoLocked);
$literals = array($packageA->getId(), $packageB->getId()); $literals = array($packageA->getId(), $packageB->getId());
$expected = $literals; $expected = $literals;
@ -237,7 +237,7 @@ class DefaultPolicyTest extends TestCase
$this->repositorySet->addRepository($this->repo); $this->repositorySet->addRepository($this->repo);
$pool = $this->repositorySet->createPoolForPackages(array('vendor-a/replacer', 'vendor-b/replacer')); $pool = $this->repositorySet->createPoolForPackages(array('vendor-a/replacer', 'vendor-b/replacer'), $this->repoLocked);
$literals = array($packageA->getId(), $packageB->getId()); $literals = array($packageA->getId(), $packageB->getId());
$expected = $literals; $expected = $literals;
@ -253,7 +253,7 @@ class DefaultPolicyTest extends TestCase
$repositorySet = new RepositorySet(array(), array(), 'dev'); $repositorySet = new RepositorySet(array(), array(), 'dev');
$repositorySet->addRepository($this->repo); $repositorySet->addRepository($this->repo);
$pool = $this->repositorySet->createPoolForPackages(array('vendor-a/replacer', 'vendor-b/replacer')); $pool = $this->repositorySet->createPoolForPackages(array('vendor-a/replacer', 'vendor-b/replacer'), $this->repoLocked);
$literals = array($packageA->getId(), $packageB->getId()); $literals = array($packageA->getId(), $packageB->getId());
$expected = $literals; $expected = $literals;
@ -270,7 +270,7 @@ class DefaultPolicyTest extends TestCase
$this->repo->addPackage($packageA2 = $this->getPackage('A', '2.0')); $this->repo->addPackage($packageA2 = $this->getPackage('A', '2.0'));
$this->repositorySet->addRepository($this->repo); $this->repositorySet->addRepository($this->repo);
$pool = $this->repositorySet->createPoolForPackage('A'); $pool = $this->repositorySet->createPoolForPackage('A', $this->repoLocked);
$literals = array($packageA1->getId(), $packageA2->getId()); $literals = array($packageA1->getId(), $packageA2->getId());
$expected = array($packageA1->getId()); $expected = array($packageA1->getId());