function Pool::match
Checks if the package matches the given constraint directly or through provided or replaced packages
Parameters
string $name Name of the package to be matched:
1 call to Pool::match()
- Pool::computeWhatProvides in vendor/
composer/ composer/ src/ Composer/ DependencyResolver/ Pool.php
File
-
vendor/
composer/ composer/ src/ Composer/ DependencyResolver/ Pool.php, line 202
Class
- Pool
- A package pool contains all packages for dependency resolution
Namespace
Composer\DependencyResolverCode
public function match(BasePackage $candidate, string $name, ?ConstraintInterface $constraint = null) : bool {
$candidateName = $candidate->getName();
$candidateVersion = $candidate->getVersion();
if ($candidateName === $name) {
return $constraint === null || CompilingMatcher::match($constraint, Constraint::OP_EQ, $candidateVersion);
}
$provides = $candidate->getProvides();
$replaces = $candidate->getReplaces();
// aliases create multiple replaces/provides for one target so they can not use the shortcut below
if (isset($replaces[0]) || isset($provides[0])) {
foreach ($provides as $link) {
if ($link->getTarget() === $name && ($constraint === null || $constraint->matches($link->getConstraint()))) {
return true;
}
}
foreach ($replaces as $link) {
if ($link->getTarget() === $name && ($constraint === null || $constraint->matches($link->getConstraint()))) {
return true;
}
}
return false;
}
if (isset($provides[$name]) && ($constraint === null || $constraint->matches($provides[$name]->getConstraint()))) {
return true;
}
if (isset($replaces[$name]) && ($constraint === null || $constraint->matches($replaces[$name]->getConstraint()))) {
return true;
}
return false;
}