1
0
Fork 0

Use version contraints in the default policy rather than hardcoded version_compare

pull/9/head
Nils Adermann 2011-08-20 23:05:39 -04:00
parent ac61c3973b
commit 6cf8d3888c
2 changed files with 6 additions and 2 deletions

View File

@ -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)

View File

@ -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) {