function InstalledRepository::findPackagesWithReplacersAndProviders
Parameters
ConstraintInterface|string|null $constraint:
Return value
File
-
vendor/
composer/ composer/ src/ Composer/ Repository/ InstalledRepository.php, line 40
Class
- InstalledRepository
- Installed repository is a composite of all installed repo types.
Namespace
Composer\RepositoryCode
public function findPackagesWithReplacersAndProviders(string $name, $constraint = null) : array {
$name = strtolower($name);
if (null !== $constraint && !$constraint instanceof ConstraintInterface) {
$versionParser = new VersionParser();
$constraint = $versionParser->parseConstraints($constraint);
}
$matches = [];
foreach ($this->getRepositories() as $repo) {
foreach ($repo->getPackages() as $candidate) {
if ($name === $candidate->getName()) {
if (null === $constraint || $constraint->matches(new Constraint('==', $candidate->getVersion()))) {
$matches[] = $candidate;
}
continue;
}
foreach (array_merge($candidate->getProvides(), $candidate->getReplaces()) as $link) {
if ($name === $link->getTarget() && ($constraint === null || $constraint->matches($link->getConstraint()))) {
$matches[] = $candidate;
continue 2;
}
}
}
}
return $matches;
}