Use version contraints in the default policy rather than hardcoded version_compare

main
Nils Adermann 13 years ago
parent ac61c3973b
commit 6cf8d3888c

@ -14,6 +14,7 @@ namespace Composer\DependencyResolver;
use Composer\Repository\RepositoryInterface;
use Composer\Package\PackageInterface;
use Composer\Package\LinkConstraint\VersionConstraint;
/**
* @author Nils Adermann <naderman@naderman.de>
@ -32,7 +33,10 @@ class DefaultPolicy implements PolicyInterface
public function versionCompare(PackageInterface $a, PackageInterface $b, $operator)
{
return version_compare($a->getVersion(), $b->getVersion(), $operator);
$constraint = new VersionConstraint($operator, $b->getVersion());
$version = new VersionConstraint('==', $a->getVersion());
return $constraint->matchSpecific($version);
}
public function findUpdatePackages(Solver $solver, Pool $pool, RepositoryInterface $repo, PackageInterface $package, $allowAll = false)

@ -100,7 +100,7 @@ abstract class BasePackage implements PackageInterface
public function matches($name, LinkConstraintInterface $constraint)
{
if ($this->name === $name) {
return $constraint->matches(new VersionConstraint('=', $this->getVersion(), $this->getReleaseType()));
return $constraint->matches(new VersionConstraint('==', $this->getVersion(), $this->getReleaseType()));
}
foreach ($this->getProvides() as $link) {

Loading…
Cancel
Save