1
0
Fork 0

Merge pull request #369 from Seldaek/match_fix

Match fix
pull/370/head
Nils Adermann 2012-02-26 17:43:02 -08:00
commit 29a1a2a424
2 changed files with 9 additions and 8 deletions

View File

@ -104,6 +104,7 @@ class DefaultPolicy implements PolicyInterface
public function compareByPriorityPreferInstalled(Pool $pool, array $installedMap, PackageInterface $a, PackageInterface $b, $ignoreReplace = false) public function compareByPriorityPreferInstalled(Pool $pool, array $installedMap, PackageInterface $a, PackageInterface $b, $ignoreReplace = false)
{ {
if ($a->getRepository() === $b->getRepository()) { if ($a->getRepository() === $b->getRepository()) {
// prefer aliases to the original package
if ($a->getName() === $b->getName()) { if ($a->getName() === $b->getName()) {
$aAliased = $a instanceof AliasPackage; $aAliased = $a instanceof AliasPackage;
$bAliased = $b instanceof AliasPackage; $bAliased = $b instanceof AliasPackage;

View File

@ -73,18 +73,18 @@ abstract class BasePackage implements PackageInterface
public function getNames() public function getNames()
{ {
$names = array( $names = array(
$this->getName(), $this->getName() => true,
); );
foreach ($this->getProvides() as $link) { foreach ($this->getProvides() as $link) {
$names[] = $link->getTarget(); $names[$link->getTarget()] = true;
} }
foreach ($this->getReplaces() as $link) { foreach ($this->getReplaces() as $link) {
$names[] = $link->getTarget(); $names[$link->getTarget()] = true;
} }
return $names; return array_keys($names);
} }
/** /**
@ -118,14 +118,14 @@ abstract class BasePackage implements PackageInterface
} }
foreach ($this->getProvides() as $link) { foreach ($this->getProvides() as $link) {
if ($link->getTarget() === $name) { if ($link->getTarget() === $name && $constraint->matches($link->getConstraint())) {
return $constraint->matches($link->getConstraint()); return true;
} }
} }
foreach ($this->getReplaces() as $link) { foreach ($this->getReplaces() as $link) {
if ($link->getTarget() === $name) { if ($link->getTarget() === $name && $constraint->matches($link->getConstraint())) {
return $constraint->matches($link->getConstraint()); return true;
} }
} }