Browse Source

Restore special handling of conflict/provide/replace

Jordi Boggiano 10 years ago
parent
commit
fd7e28b8b4
2 changed files with 22 additions and 12 deletions
  1. 18 6
      src/Composer/Package/AliasPackage.php
  2. 4 6
      src/Composer/Package/RootAliasPackage.php

+ 18 - 6
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')
-    {
-        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);
+    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), $linkType, $this->prettyVersion);
+                }
             }
         }
+
         return $links;
     }
 

+ 4 - 6
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()