Prevent seeing dev versions as equal when they are not, fixes #848
parent
37ef2037cf
commit
2f7130200a
|
@ -49,7 +49,7 @@ class DefaultPolicy implements PolicyInterface
|
|||
|
||||
public function selectPreferedPackages(Pool $pool, array $installedMap, array $literals)
|
||||
{
|
||||
$packages = $this->groupLiteralsByNamePreferInstalled($pool,$installedMap, $literals);
|
||||
$packages = $this->groupLiteralsByNamePreferInstalled($pool, $installedMap, $literals);
|
||||
|
||||
foreach ($packages as &$literals) {
|
||||
$policy = $this;
|
||||
|
|
|
@ -58,6 +58,11 @@ class VersionConstraint extends SpecificConstraint
|
|||
$isProviderEqualOp = '==' === $provider->operator;
|
||||
$isProviderNonEqualOp = '!=' === $provider->operator;
|
||||
|
||||
// dev- versions can not be compared with version_compare
|
||||
if ('dev-' === substr($provider->version, 0, 4) && 'dev-' === substr($this->version, 0, 4)) {
|
||||
return $isEqualOp && $isProviderEqualOp && $provider->version === $this->version ? true : false;
|
||||
}
|
||||
|
||||
// '!=' operator is match when other operator is not '==' operator or version is not match
|
||||
// these kinds of comparisons always have a solution
|
||||
if ($isNonEqualOp || $isProviderNonEqualOp) {
|
||||
|
|
|
@ -33,6 +33,7 @@ class VersionConstraintTest extends \PHPUnit_Framework_TestCase
|
|||
array('!=', '1', '<=', '1'),
|
||||
array('!=', '1', '>', '1'),
|
||||
array('!=', '1', '>=', '1'),
|
||||
array('==', 'dev-foo-bar', '==', 'dev-foo-bar'),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -61,6 +62,7 @@ class VersionConstraintTest extends \PHPUnit_Framework_TestCase
|
|||
array('==', '2', '<', '2'),
|
||||
array('!=', '1', '==', '1'),
|
||||
array('==', '1', '!=', '1'),
|
||||
array('==', 'dev-foo-dist', '==', 'dev-foo-zist'),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue