From 1a0d5dfacd3c0fdafcd4a120ee0b4ae0df5dbed7 Mon Sep 17 00:00:00 2001 From: xy2z Date: Thu, 24 Oct 2019 15:13:17 +0200 Subject: [PATCH] Now using findPackage() instead of HasPackageName() --- src/Composer/Command/InitCommand.php | 2 +- src/Composer/Repository/ArrayRepository.php | 14 -------------- src/Composer/Repository/CompositeRepository.php | 15 --------------- src/Composer/Repository/RepositoryInterface.php | 9 --------- 4 files changed, 1 insertion(+), 39 deletions(-) diff --git a/src/Composer/Command/InitCommand.php b/src/Composer/Command/InitCommand.php index 7efdff049..d50e90c4e 100644 --- a/src/Composer/Command/InitCommand.php +++ b/src/Composer/Command/InitCommand.php @@ -795,7 +795,7 @@ EOT $installedRepo = $this->getComposer()->getRepositoryManager()->getLocalRepository(); foreach ($results as $result) { - if ($installedRepo->hasPackageName($result['name'])) { + if ($installedRepo->findPackage($result['name'], '*')) { // Ignore installed package continue; } diff --git a/src/Composer/Repository/ArrayRepository.php b/src/Composer/Repository/ArrayRepository.php index 4cfbe42f9..4f0409a60 100644 --- a/src/Composer/Repository/ArrayRepository.php +++ b/src/Composer/Repository/ArrayRepository.php @@ -132,20 +132,6 @@ class ArrayRepository extends BaseRepository return false; } - /** - * {@inheritDoc} - */ - public function hasPackageName(string $packageName) - { - foreach ($this->getPackages() as $repoPackage) { - if ($packageName === $repoPackage->getName()) { - return true; - } - } - - return false; - } - /** * Adds a new package to the repository * diff --git a/src/Composer/Repository/CompositeRepository.php b/src/Composer/Repository/CompositeRepository.php index c19a04a7b..ce57504f0 100644 --- a/src/Composer/Repository/CompositeRepository.php +++ b/src/Composer/Repository/CompositeRepository.php @@ -64,21 +64,6 @@ class CompositeRepository extends BaseRepository return false; } - /** - * {@inheritdoc} - */ - public function hasPackageName(string $packageName) - { - foreach ($this->repositories as $repository) { - /* @var $repository RepositoryInterface */ - if ($repository->hasPackageName($packageName)) { - return true; - } - } - - return false; - } - /** * {@inheritdoc} */ diff --git a/src/Composer/Repository/RepositoryInterface.php b/src/Composer/Repository/RepositoryInterface.php index 8e1717fce..9a2aaf3b5 100644 --- a/src/Composer/Repository/RepositoryInterface.php +++ b/src/Composer/Repository/RepositoryInterface.php @@ -35,15 +35,6 @@ interface RepositoryInterface extends \Countable */ public function hasPackage(PackageInterface $package); - /** - * Checks if specified package name is registered (installed). - * - * @param string $package_name package name (vendor/project) - * - * @return bool - */ - public function hasPackageName(string $packageName); - /** * Searches for the first match of a package by name and version. *