[alias] RootAliasPackage manages the requirements correctly
parent
a811142ff2
commit
b02bdb4c7a
|
@ -28,6 +28,7 @@ class AliasPackage extends BasePackage implements CompletePackageInterface
|
||||||
protected $stability;
|
protected $stability;
|
||||||
|
|
||||||
protected $requires;
|
protected $requires;
|
||||||
|
protected $devRequires;
|
||||||
protected $conflicts;
|
protected $conflicts;
|
||||||
protected $provides;
|
protected $provides;
|
||||||
protected $replaces;
|
protected $replaces;
|
||||||
|
@ -51,32 +52,15 @@ class AliasPackage extends BasePackage implements CompletePackageInterface
|
||||||
$this->stability = VersionParser::parseStability($version);
|
$this->stability = VersionParser::parseStability($version);
|
||||||
$this->dev = $this->stability === 'dev';
|
$this->dev = $this->stability === 'dev';
|
||||||
|
|
||||||
// replace self.version dependencies
|
foreach (array('requires', 'devRequires', 'conflicts', 'provides', 'replaces') as $type) {
|
||||||
foreach (array('requires', 'devRequires') as $type) {
|
$links = $aliasOf->{'get' . ucfirst($type)}();
|
||||||
$links = $aliasOf->{'get'.ucfirst($type)}();
|
$this->$type = $this->replaceSelfVersionDependencies($links, $type);
|
||||||
foreach ($links as $index => $link) {
|
|
||||||
// link is self.version, but must be replacing also the replaced version
|
|
||||||
if ('self.version' === $link->getPrettyConstraint()) {
|
|
||||||
$links[$index] = new Link($link->getSource(), $link->getTarget(), new VersionConstraint('=', $this->version), $type, $prettyVersion);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$this->$type = $links;
|
|
||||||
}
|
|
||||||
|
|
||||||
// duplicate self.version provides
|
|
||||||
foreach (array('conflicts', 'provides', 'replaces') as $type) {
|
|
||||||
$links = $aliasOf->{'get'.ucfirst($type)}();
|
|
||||||
$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), $type, $prettyVersion);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$this->$type = array_merge($links, $newLinks);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return PackageInterface
|
||||||
|
*/
|
||||||
public function getAliasOf()
|
public function getAliasOf()
|
||||||
{
|
{
|
||||||
return $this->aliasOf;
|
return $this->aliasOf;
|
||||||
|
@ -177,6 +161,22 @@ class AliasPackage extends BasePackage implements CompletePackageInterface
|
||||||
return $this->rootPackageAlias;
|
return $this->rootPackageAlias;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $links
|
||||||
|
* @param string $linkDescription
|
||||||
|
* @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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $links;
|
||||||
|
}
|
||||||
|
|
||||||
/***************************************
|
/***************************************
|
||||||
* Wrappers around the aliased package *
|
* Wrappers around the aliased package *
|
||||||
***************************************/
|
***************************************/
|
||||||
|
|
|
@ -63,18 +63,24 @@ class RootAliasPackage extends AliasPackage implements RootPackageInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* @param array $require
|
||||||
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function setRequires(array $require)
|
public function setRequires(array $require)
|
||||||
{
|
{
|
||||||
|
$this->requires = $this->replaceSelfVersionDependencies($require, 'requires');
|
||||||
|
|
||||||
return $this->aliasOf->setRequires($require);
|
return $this->aliasOf->setRequires($require);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* @param array $devRequire
|
||||||
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function setDevRequires(array $devRequire)
|
public function setDevRequires(array $devRequire)
|
||||||
{
|
{
|
||||||
|
$this->devRequires = $this->replaceSelfVersionDependencies($devRequire, 'devRequires');
|
||||||
|
|
||||||
return $this->aliasOf->setDevRequires($devRequire);
|
return $this->aliasOf->setDevRequires($devRequire);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue