1
0
Fork 0

Restore special handling of conflict/provide/replace

pull/3982/head
Jordi Boggiano 2015-04-29 20:46:25 +01:00
parent b02bdb4c7a
commit fd7e28b8b4
2 changed files with 21 additions and 11 deletions

View File

@ -163,17 +163,29 @@ class AliasPackage extends BasePackage implements CompletePackageInterface
/**
* @param array $links
* @param string $linkDescription
* @param string $linkType
* @internal param string $prettyVersion
* @return array
*/
protected function replaceSelfVersionDependencies(array $links, $linkDescription = 'relates to')
protected function replaceSelfVersionDependencies(array $links, $linkType)
{
if (in_array($linkType, array('conflicts', 'provides', 'replaces'), true)) {
$newLinks = array();
foreach ($links as $link) {
// link is self.version, but must be replacing also the replaced version
if ('self.version' === $link->getPrettyConstraint()) {
$newLinks[] = new Link($link->getSource(), $link->getTarget(), new VersionConstraint('=', $this->version), $linkType, $this->prettyVersion);
}
}
$links = array_merge($links, $newLinks);
} else {
foreach ($links as $index => $link) {
if ('self.version' === $link->getPrettyConstraint()) {
$links[$index] = new Link($link->getSource(), $link->getTarget(), new VersionConstraint('=', $this->version), $linkDescription, $this->prettyVersion);
$links[$index] = new Link($link->getSource(), $link->getTarget(), new VersionConstraint('=', $this->version), $linkType, $this->prettyVersion);
}
}
}
return $links;
}

View File

@ -63,25 +63,23 @@ class RootAliasPackage extends AliasPackage implements RootPackageInterface
}
/**
* @param array $require
* @return mixed
* {@inheritDoc}
*/
public function setRequires(array $require)
{
$this->requires = $this->replaceSelfVersionDependencies($require, 'requires');
return $this->aliasOf->setRequires($require);
$this->aliasOf->setRequires($require);
}
/**
* @param array $devRequire
* @return mixed
* {@inheritDoc}
*/
public function setDevRequires(array $devRequire)
{
$this->devRequires = $this->replaceSelfVersionDependencies($devRequire, 'devRequires');
return $this->aliasOf->setDevRequires($devRequire);
$this->aliasOf->setDevRequires($devRequire);
}
public function __clone()