diff --git a/src/Composer/Package/AliasPackage.php b/src/Composer/Package/AliasPackage.php index 8c47e685e..f6aa98a4c 100644 --- a/src/Composer/Package/AliasPackage.php +++ b/src/Composer/Package/AliasPackage.php @@ -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) { - 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); + 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), $linkType, $this->prettyVersion); + } } } + return $links; } diff --git a/src/Composer/Package/RootAliasPackage.php b/src/Composer/Package/RootAliasPackage.php index 471d8b3df..f9d056a59 100644 --- a/src/Composer/Package/RootAliasPackage.php +++ b/src/Composer/Package/RootAliasPackage.php @@ -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()