From f35cd8948aa69438ceb597553225d48de12612a7 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 13 Feb 2020 16:29:57 +0100 Subject: [PATCH] Minor refactoring of RootPackageRepo --- src/Composer/Command/SuggestsCommand.php | 2 +- src/Composer/Installer.php | 4 ++-- src/Composer/Repository/RootPackageRepository.php | 7 +++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Composer/Command/SuggestsCommand.php b/src/Composer/Command/SuggestsCommand.php index 07ca1ce00..93c0e1e30 100644 --- a/src/Composer/Command/SuggestsCommand.php +++ b/src/Composer/Command/SuggestsCommand.php @@ -54,7 +54,7 @@ EOT $composer = $this->getComposer(); $installedRepos = array( - new RootPackageRepository(array(clone $composer->getPackage())), + new RootPackageRepository(clone $composer->getPackage()), ); $locker = $composer->getLocker(); diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 627adee76..46b7ea1ea 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -260,7 +260,7 @@ class Installer $installedRepos = array( $this->locker->getLockedRepository($this->devMode), $this->createPlatformRepo(false), - new RootPackageRepository(array(clone $this->package)), + new RootPackageRepository(clone $this->package), ); $this->suggestedPackagesReporter->outputMinimalistic(new CompositeRepository($installedRepos)); } @@ -706,7 +706,7 @@ class Installer $this->fixedRootPackage->setDevRequires(array()); $repositorySet = new RepositorySet($minimumStability, $stabilityFlags, $rootAliases, $this->package->getReferences(), $rootRequires); - $repositorySet->addRepository(new RootPackageRepository(array($this->fixedRootPackage))); + $repositorySet->addRepository(new RootPackageRepository($this->fixedRootPackage)); $repositorySet->addRepository($platformRepo); if ($this->additionalFixedRepository) { $repositorySet->addRepository($this->additionalFixedRepository); diff --git a/src/Composer/Repository/RootPackageRepository.php b/src/Composer/Repository/RootPackageRepository.php index 721737fdc..9652282f7 100644 --- a/src/Composer/Repository/RootPackageRepository.php +++ b/src/Composer/Repository/RootPackageRepository.php @@ -12,6 +12,8 @@ namespace Composer\Repository; +use Composer\Package\RootPackageInterface; + /** * Root package repository. * @@ -21,6 +23,11 @@ namespace Composer\Repository; */ class RootPackageRepository extends ArrayRepository { + public function __construct(RootPackageInterface $package) + { + parent::__construct(array($package)); + } + public function getRepoName() { return 'root package repo';