function Intervals::isSubsetOf
Checks whether $candidate is a subset of $constraint
Return value
bool
2 calls to Intervals::isSubsetOf()
- PoolBuilder::markPackageNameForLoading in vendor/
composer/ composer/ src/ Composer/ DependencyResolver/ PoolBuilder.php - VersionBumper::bumpRequirement in vendor/
composer/ composer/ src/ Composer/ Package/ Version/ VersionBumper.php - Given a constraint, this returns a new constraint with the lower bound bumped to match the given package's version.
File
-
vendor/
composer/ semver/ src/ Intervals.php, line 64
Class
- Intervals
- Helper class generating intervals from constraints
Namespace
Composer\SemverCode
public static function isSubsetOf(ConstraintInterface $candidate, ConstraintInterface $constraint) {
if ($constraint instanceof MatchAllConstraint) {
return true;
}
if ($candidate instanceof MatchNoneConstraint || $constraint instanceof MatchNoneConstraint) {
return false;
}
$intersectionIntervals = self::get(new MultiConstraint(array(
$candidate,
$constraint,
), true));
$candidateIntervals = self::get($candidate);
if (\count($intersectionIntervals['numeric']) !== \count($candidateIntervals['numeric'])) {
return false;
}
foreach ($intersectionIntervals['numeric'] as $index => $interval) {
if (!isset($candidateIntervals['numeric'][$index])) {
return false;
}
if ((string) $candidateIntervals['numeric'][$index]->getStart() !== (string) $interval->getStart()) {
return false;
}
if ((string) $candidateIntervals['numeric'][$index]->getEnd() !== (string) $interval->getEnd()) {
return false;
}
}
if ($intersectionIntervals['branches']['exclude'] !== $candidateIntervals['branches']['exclude']) {
return false;
}
if (\count($intersectionIntervals['branches']['names']) !== \count($candidateIntervals['branches']['names'])) {
return false;
}
foreach ($intersectionIntervals['branches']['names'] as $index => $name) {
if ($name !== $candidateIntervals['branches']['names'][$index]) {
return false;
}
}
return true;
}