diff --git a/src/Composer/Package/Link.php b/src/Composer/Package/Link.php index 16718a55b..348bbced7 100644 --- a/src/Composer/Package/Link.php +++ b/src/Composer/Package/Link.php @@ -34,12 +34,13 @@ class Link * @param LinkConstraintInterface $constraint Constraint applying to the target of this link * @param string $description Used to create a descriptive string representation */ - public function __construct($source, $target, LinkConstraintInterface $constraint = null, $description = 'relates to') + public function __construct($source, $target, LinkConstraintInterface $constraint = null, $description = 'relates to', $prettyConstraint = null) { $this->source = strtolower($source); $this->target = strtolower($target); $this->constraint = $constraint; $this->description = $description; + $this->prettyConstraint = $prettyConstraint; } public function getSource() @@ -57,6 +58,15 @@ class Link return $this->constraint; } + public function getPrettyConstraint() + { + if (null === $this->prettyConstraint) { + throw new \UnexpectedValueException(sprintf('Link %s has been misconfigured and had no prettyConstraint given.', $this)); + } + + return $this->prettyConstraint; + } + public function __toString() { return $this->source.' '.$this->description.' '.$this->target.' ('.$this->constraint.')'; diff --git a/src/Composer/Package/Loader/ArrayLoader.php b/src/Composer/Package/Loader/ArrayLoader.php index a99796463..3cc440a93 100644 --- a/src/Composer/Package/Loader/ArrayLoader.php +++ b/src/Composer/Package/Loader/ArrayLoader.php @@ -143,10 +143,8 @@ class ArrayLoader { $links = array(); foreach ($linksSpecs as $packageName => $constraint) { - $name = strtolower($packageName); - $constraint = $this->versionParser->parseConstraints($constraint); - $links[] = new Package\Link($srcPackageName, $packageName, $constraint, $description); + $links[] = new Package\Link($srcPackageName, $packageName, $constraint, $description, $constraint); } return $links;