Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. InstalledRepository.php

function InstalledRepository::findPackagesWithReplacersAndProviders

Parameters

ConstraintInterface|string|null $constraint:

Return value

BasePackage[]

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\Repository

Code

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;
}
RSS feed
Powered by Drupal