1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-10 09:02:59 +00:00

RepositorySet::findPackages now has an exactMatch option

Allows search for providers/replacers, or exact name search
This commit is contained in:
Nils Adermann 2018-09-11 14:52:44 +02:00
parent 190d263c74
commit 7036f99999
3 changed files with 10 additions and 5 deletions

View file

@ -98,13 +98,14 @@ class RepositorySet
}
/**
* Find packages matching name and optionally a constraint in all repositories
* Find packages providing or matching a name and optionally meeting a constraint in all repositories
*
* @param $name
* @param string $name
* @param ConstraintInterface|null $constraint
* @param bool $exactMatch
* @return array
*/
public function findPackages($name, ConstraintInterface $constraint = null)
public function findPackages($name, ConstraintInterface $constraint = null, $exactMatch = true)
{
$packages = array();
foreach ($this->repositories as $repository) {
@ -115,6 +116,10 @@ class RepositorySet
$result = array();
foreach ($candidates as $candidate) {
if ($exactMatch && $candidate->getName() !== $name) {
continue;
}
if ($this->isPackageAcceptable($candidate->getNames(), $candidate->getStability())) {
$result[] = $candidate;
}