From 6cf8d3888c5d421176d0ce9f8715a95b1c0035c7 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sat, 20 Aug 2011 23:05:39 -0400 Subject: [PATCH] Use version contraints in the default policy rather than hardcoded version_compare --- src/Composer/DependencyResolver/DefaultPolicy.php | 6 +++++- src/Composer/Package/BasePackage.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Composer/DependencyResolver/DefaultPolicy.php b/src/Composer/DependencyResolver/DefaultPolicy.php index 96f4feffe..921c30f70 100644 --- a/src/Composer/DependencyResolver/DefaultPolicy.php +++ b/src/Composer/DependencyResolver/DefaultPolicy.php @@ -14,6 +14,7 @@ namespace Composer\DependencyResolver; use Composer\Repository\RepositoryInterface; use Composer\Package\PackageInterface; +use Composer\Package\LinkConstraint\VersionConstraint; /** * @author Nils Adermann @@ -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) diff --git a/src/Composer/Package/BasePackage.php b/src/Composer/Package/BasePackage.php index 55feadb14..f6b800ea7 100644 --- a/src/Composer/Package/BasePackage.php +++ b/src/Composer/Package/BasePackage.php @@ -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) {