Do not apply non-array package links in ArrayLoader (#11008)
parent
51774693c7
commit
d2d8474013
|
@ -55,7 +55,9 @@ class ArrayLoader implements LoaderInterface
|
||||||
$package = $this->createObject($config, $class);
|
$package = $this->createObject($config, $class);
|
||||||
|
|
||||||
foreach (BasePackage::$supportedLinkTypes as $type => $opts) {
|
foreach (BasePackage::$supportedLinkTypes as $type => $opts) {
|
||||||
if (isset($config[$type])) {
|
if (!isset($config[$type]) || !is_array($config[$type])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$method = 'set'.ucfirst($opts['method']);
|
$method = 'set'.ucfirst($opts['method']);
|
||||||
$package->{$method}(
|
$package->{$method}(
|
||||||
$this->parseLinks(
|
$this->parseLinks(
|
||||||
|
@ -66,7 +68,6 @@ class ArrayLoader implements LoaderInterface
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$package = $this->configureObject($package, $config);
|
$package = $this->configureObject($package, $config);
|
||||||
|
|
||||||
|
|
|
@ -402,4 +402,31 @@ class ArrayLoaderTest extends TestCase
|
||||||
$package = $this->loader->load($config);
|
$package = $this->loader->load($config);
|
||||||
$this->assertCount(0, $package->getRequires());
|
$this->assertCount(0, $package->getRequires());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testPackageLinksReplace(): void
|
||||||
|
{
|
||||||
|
$config = array(
|
||||||
|
'name' => 'acme/package',
|
||||||
|
'version' => 'dev-1',
|
||||||
|
'replace' => [
|
||||||
|
'coyote/package' => 'self.version',
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
$package = $this->loader->load($config);
|
||||||
|
$this->assertArrayHasKey('coyote/package', $package->getReplaces());
|
||||||
|
$this->assertSame('dev-1', $package->getReplaces()['coyote/package']->getConstraint()->getPrettyString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testPackageLinksReplaceInvalid(): void
|
||||||
|
{
|
||||||
|
$config = array(
|
||||||
|
'name' => 'acme/package',
|
||||||
|
'version' => 'dev-1',
|
||||||
|
'replace' => 'coyote/package',
|
||||||
|
);
|
||||||
|
|
||||||
|
$package = $this->loader->load($config);
|
||||||
|
$this->assertCount(0, $package->getReplaces());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue