Merge pull request #8982 from Seldaek/fix-inline-aliases-when-extracting-dev-reqs
Fix inline aliases not being loaded when extracting dev requirementspull/8986/head
commit
cda9849d19
|
@ -88,7 +88,7 @@ class PoolBuilder
|
||||||
* @param int[] $stabilityFlags an array of package name => BasePackage::STABILITY_* value
|
* @param int[] $stabilityFlags an array of package name => BasePackage::STABILITY_* value
|
||||||
* @psalm-param array<string, int> $stabilityFlags
|
* @psalm-param array<string, int> $stabilityFlags
|
||||||
* @param array[] $rootAliases
|
* @param array[] $rootAliases
|
||||||
* @psalm-param list<array{package: string, version: string, alias: string, alias_normalized: string}> $rootAliases
|
* @psalm-param array<string, array<string, array{alias: string, alias_normalized: string}>> $rootAliases
|
||||||
* @param string[] $rootReferences an array of package name => source reference
|
* @param string[] $rootReferences an array of package name => source reference
|
||||||
* @psalm-param array<string, string> $rootReferences
|
* @psalm-param array<string, string> $rootReferences
|
||||||
*/
|
*/
|
||||||
|
@ -96,7 +96,7 @@ class PoolBuilder
|
||||||
{
|
{
|
||||||
$this->acceptableStabilities = $acceptableStabilities;
|
$this->acceptableStabilities = $acceptableStabilities;
|
||||||
$this->stabilityFlags = $stabilityFlags;
|
$this->stabilityFlags = $stabilityFlags;
|
||||||
$this->rootAliases = $this->getRootAliasesPerPackage($rootAliases);
|
$this->rootAliases = $rootAliases;
|
||||||
$this->rootReferences = $rootReferences;
|
$this->rootReferences = $rootReferences;
|
||||||
$this->eventDispatcher = $eventDispatcher;
|
$this->eventDispatcher = $eventDispatcher;
|
||||||
$this->io = $io;
|
$this->io = $io;
|
||||||
|
@ -425,19 +425,5 @@ class PoolBuilder
|
||||||
unset($this->skippedLoad[$name]);
|
unset($this->skippedLoad[$name]);
|
||||||
unset($this->loadedNames[$name]);
|
unset($this->loadedNames[$name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getRootAliasesPerPackage(array $aliases)
|
|
||||||
{
|
|
||||||
$normalizedAliases = array();
|
|
||||||
|
|
||||||
foreach ($aliases as $alias) {
|
|
||||||
$normalizedAliases[$alias['package']][$alias['version']] = array(
|
|
||||||
'alias' => $alias['alias'],
|
|
||||||
'alias_normalized' => $alias['alias_normalized'],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $normalizedAliases;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ use Composer\EventDispatcher\EventDispatcher;
|
||||||
use Composer\IO\IOInterface;
|
use Composer\IO\IOInterface;
|
||||||
use Composer\IO\NullIO;
|
use Composer\IO\NullIO;
|
||||||
use Composer\Package\BasePackage;
|
use Composer\Package\BasePackage;
|
||||||
|
use Composer\Package\AliasPackage;
|
||||||
use Composer\Package\Version\VersionParser;
|
use Composer\Package\Version\VersionParser;
|
||||||
use Composer\Repository\CompositeRepository;
|
use Composer\Repository\CompositeRepository;
|
||||||
use Composer\Repository\PlatformRepository;
|
use Composer\Repository\PlatformRepository;
|
||||||
|
@ -44,7 +45,7 @@ class RepositorySet
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array[]
|
* @var array[]
|
||||||
* @psalm-var list<array{package: string, version: string, alias: string, alias_normalized: string}>
|
* @psalm-var array<string, array<string, array{alias: string, alias_normalized: string}>>
|
||||||
*/
|
*/
|
||||||
private $rootAliases;
|
private $rootAliases;
|
||||||
|
|
||||||
|
@ -91,7 +92,7 @@ class RepositorySet
|
||||||
*/
|
*/
|
||||||
public function __construct($minimumStability = 'stable', array $stabilityFlags = array(), array $rootAliases = array(), array $rootReferences = array(), array $rootRequires = array())
|
public function __construct($minimumStability = 'stable', array $stabilityFlags = array(), array $rootAliases = array(), array $rootReferences = array(), array $rootRequires = array())
|
||||||
{
|
{
|
||||||
$this->rootAliases = $rootAliases;
|
$this->rootAliases = $this->getRootAliasesPerPackage($rootAliases);
|
||||||
$this->rootReferences = $rootReferences;
|
$this->rootReferences = $rootReferences;
|
||||||
|
|
||||||
$this->acceptableStabilities = array();
|
$this->acceptableStabilities = array();
|
||||||
|
@ -249,8 +250,22 @@ class RepositorySet
|
||||||
|
|
||||||
$packages = array();
|
$packages = array();
|
||||||
foreach ($this->repositories as $repository) {
|
foreach ($this->repositories as $repository) {
|
||||||
$packages = array_merge($packages, $repository->getPackages());
|
foreach ($repository->getPackages() as $package) {
|
||||||
|
$packages[] = $package;
|
||||||
|
|
||||||
|
if (isset($this->rootAliases[$package->getName()][$package->getVersion()])) {
|
||||||
|
$alias = $this->rootAliases[$package->getName()][$package->getVersion()];
|
||||||
|
while ($package instanceof AliasPackage) {
|
||||||
|
$package = $package->getAliasOf();
|
||||||
|
}
|
||||||
|
$aliasPackage = new AliasPackage($package, $alias['alias_normalized'], $alias['alias']);
|
||||||
|
$aliasPackage->setRootPackageAlias(true);
|
||||||
|
$packages[] = $aliasPackage;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Pool($packages);
|
return new Pool($packages);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,4 +285,18 @@ class RepositorySet
|
||||||
|
|
||||||
return $this->createPool($request, new NullIO());
|
return $this->createPool($request, new NullIO());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getRootAliasesPerPackage(array $aliases)
|
||||||
|
{
|
||||||
|
$normalizedAliases = array();
|
||||||
|
|
||||||
|
foreach ($aliases as $alias) {
|
||||||
|
$normalizedAliases[$alias['package']][$alias['version']] = array(
|
||||||
|
'alias' => $alias['alias'],
|
||||||
|
'alias_normalized' => $alias['alias_normalized'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $normalizedAliases;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,90 @@
|
||||||
|
--TEST--
|
||||||
|
Aliases are loaded when splitting require-dev from require (https://github.com/composer/composer/issues/8954)
|
||||||
|
--COMPOSER--
|
||||||
|
{
|
||||||
|
"repositories": [
|
||||||
|
{
|
||||||
|
"type": "package",
|
||||||
|
"package": [
|
||||||
|
{
|
||||||
|
"name": "a/aliased", "version": "dev-next", "replace": { "a/aliased-replaced": "self.version" }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "b/requirer", "version": "2.3.0",
|
||||||
|
"require": { "a/aliased-replaced": "^4.0" }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "a/aliased2", "version": "dev-next", "replace": { "a/aliased-replaced2": "self.version" }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "b/requirer2", "version": "2.3.0",
|
||||||
|
"require": { "a/aliased-replaced": "^4.0", "a/aliased-replaced2": "^4.0" }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"require": {
|
||||||
|
"a/aliased": "dev-next as 4.1.0-RC2",
|
||||||
|
"b/requirer": "2.3.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"a/aliased2": "dev-next as 4.1.0-RC2",
|
||||||
|
"b/requirer2": "2.3.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--RUN--
|
||||||
|
update
|
||||||
|
--EXPECT-LOCK--
|
||||||
|
{
|
||||||
|
"packages": [
|
||||||
|
{
|
||||||
|
"name": "a/aliased", "version": "dev-next",
|
||||||
|
"type": "library",
|
||||||
|
"replace": { "a/aliased-replaced": "self.version" }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "b/requirer", "version": "2.3.0",
|
||||||
|
"require": { "a/aliased-replaced": "^4.0" },
|
||||||
|
"type": "library"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"packages-dev": [
|
||||||
|
{
|
||||||
|
"name": "a/aliased2", "version": "dev-next",
|
||||||
|
"type": "library",
|
||||||
|
"replace": { "a/aliased-replaced2": "self.version" }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "b/requirer2", "version": "2.3.0",
|
||||||
|
"require": { "a/aliased-replaced": "^4.0", "a/aliased-replaced2": "^4.0" },
|
||||||
|
"type": "library"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"aliases": [{
|
||||||
|
"package": "a/aliased2",
|
||||||
|
"version": "dev-next",
|
||||||
|
"alias": "4.1.0-RC2",
|
||||||
|
"alias_normalized": "4.1.0.0-RC2"
|
||||||
|
}, {
|
||||||
|
"package": "a/aliased",
|
||||||
|
"version": "dev-next",
|
||||||
|
"alias": "4.1.0-RC2",
|
||||||
|
"alias_normalized": "4.1.0.0-RC2"
|
||||||
|
}],
|
||||||
|
"minimum-stability": "stable",
|
||||||
|
"stability-flags": {
|
||||||
|
"a/aliased": 20,
|
||||||
|
"a/aliased2": 20
|
||||||
|
},
|
||||||
|
"prefer-stable": false,
|
||||||
|
"prefer-lowest": false,
|
||||||
|
"platform": [],
|
||||||
|
"platform-dev": []
|
||||||
|
}
|
||||||
|
--EXPECT--
|
||||||
|
Installing a/aliased (dev-next)
|
||||||
|
Marking a/aliased (4.1.0-RC2) as installed, alias of a/aliased (dev-next)
|
||||||
|
Installing b/requirer (2.3.0)
|
||||||
|
Installing a/aliased2 (dev-next)
|
||||||
|
Marking a/aliased2 (4.1.0-RC2) as installed, alias of a/aliased2 (dev-next)
|
||||||
|
Installing b/requirer2 (2.3.0)
|
Loading…
Reference in New Issue