Restore special handling of conflict/provide/replace
parent
b02bdb4c7a
commit
fd7e28b8b4
|
@ -163,17 +163,29 @@ class AliasPackage extends BasePackage implements CompletePackageInterface
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $links
|
* @param array $links
|
||||||
* @param string $linkDescription
|
* @param string $linkType
|
||||||
* @internal param string $prettyVersion
|
* @internal param string $prettyVersion
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function replaceSelfVersionDependencies(array $links, $linkDescription = 'relates to')
|
protected function replaceSelfVersionDependencies(array $links, $linkType)
|
||||||
{
|
{
|
||||||
foreach ($links as $index => $link) {
|
if (in_array($linkType, array('conflicts', 'provides', 'replaces'), true)) {
|
||||||
if ('self.version' === $link->getPrettyConstraint()) {
|
$newLinks = array();
|
||||||
$links[$index] = new Link($link->getSource(), $link->getTarget(), new VersionConstraint('=', $this->version), $linkDescription, $this->prettyVersion);
|
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), $linkType, $this->prettyVersion);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $links;
|
return $links;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,25 +63,23 @@ class RootAliasPackage extends AliasPackage implements RootPackageInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $require
|
* {@inheritDoc}
|
||||||
* @return mixed
|
|
||||||
*/
|
*/
|
||||||
public function setRequires(array $require)
|
public function setRequires(array $require)
|
||||||
{
|
{
|
||||||
$this->requires = $this->replaceSelfVersionDependencies($require, 'requires');
|
$this->requires = $this->replaceSelfVersionDependencies($require, 'requires');
|
||||||
|
|
||||||
return $this->aliasOf->setRequires($require);
|
$this->aliasOf->setRequires($require);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $devRequire
|
* {@inheritDoc}
|
||||||
* @return mixed
|
|
||||||
*/
|
*/
|
||||||
public function setDevRequires(array $devRequire)
|
public function setDevRequires(array $devRequire)
|
||||||
{
|
{
|
||||||
$this->devRequires = $this->replaceSelfVersionDependencies($devRequire, 'devRequires');
|
$this->devRequires = $this->replaceSelfVersionDependencies($devRequire, 'devRequires');
|
||||||
|
|
||||||
return $this->aliasOf->setDevRequires($devRequire);
|
$this->aliasOf->setDevRequires($devRequire);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __clone()
|
public function __clone()
|
||||||
|
|
Loading…
Reference in New Issue