/** * Resolves a package link to a package in the installed pool * * Since dependencies are already installed this should always find one. * * @param Pool $pool Pool of installed packages only * @param Link $link Package link to look up * * @return PackageInterface|null The found package */ private function lookupInstalledPackage(Pool $pool, Link $link) { $packages = $pool->whatProvides($link->getTarget(), $link->getConstraint()); return !empty($packages) ? $packages[0] : null; }
/** * Include the constraint of root dependency version in the constraint * of installed package. * * @param PackageInterface $package The installed package * @param Link $link The link contained installed constraint * * @return Link The link with root and installed version constraint */ private function includeRootConstraint(PackageInterface $package, Link $link) { if (isset($this->requires[$package->getName()])) { /* @var Link $rLink */ $rLink = $this->requires[$package->getName()]; $useConjunctive = FilterUtil::checkExtraOption($this->package, 'asset-optimize-with-conjunctive'); $constraint = new MultiConstraint(array($rLink->getConstraint(), $link->getConstraint()), $useConjunctive); $link = new Link($rLink->getSource(), $rLink->getTarget(), $constraint, 'installed', $constraint->getPrettyString()); } return $link; }
/** * @param \Composer\Package\Link $packageLink * @param bool $ignoreRequiredVersion * @param bool $exactAsTilda * @return \Composer\Package\PackageInterface[] */ private function getVersionsByPackageLink(Link $packageLink, $ignoreRequiredVersion = FALSE, $exactAsTilda = FALSE) { $constraint = $packageLink->getConstraint(); if ($this->versionParser->parseStability($constraint->getPrettyString()) !== 'dev') { if ($ignoreRequiredVersion) { $constraint = NULL; } elseif ($exactAsTilda && $this->isExact($constraint)) { $constraint = $this->versionParser->parseConstraints(sprintf('~%s', $constraint->getPrettyString())); } } return $this->getVersions($packageLink->getTarget(), $constraint); }
/** * Check if the require dependency has a satisfactory version. * * @param Link $require The require link defined in root package. * @param string $normalizedVersion The normalized version * * @return bool */ protected function satisfyVersion(Link $require, $normalizedVersion) { $constraintSame = $this->versionParser->parseConstraints($normalizedVersion); $sameVersion = (bool) $require->getConstraint()->matches($constraintSame); $normalizedVersion = $this->getVersionConstraint($normalizedVersion); $constraint = $this->getVersionConstraint($normalizedVersion); return (bool) $require->getConstraint()->matches($constraint) || $sameVersion; }