Do not apply non-string package link constraints in ArrayLoader (#11009)
parent
7ccf230390
commit
51774693c7
|
@ -364,6 +364,9 @@ class ArrayLoader implements LoaderInterface
|
||||||
{
|
{
|
||||||
$res = [];
|
$res = [];
|
||||||
foreach ($links as $target => $constraint) {
|
foreach ($links as $target => $constraint) {
|
||||||
|
if (!is_string($constraint)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$target = strtolower((string) $target);
|
$target = strtolower((string) $target);
|
||||||
$res[$target] = $this->createLink($source, $sourceVersion, $description, $target, $constraint);
|
$res[$target] = $this->createLink($source, $sourceVersion, $description, $target, $constraint);
|
||||||
}
|
}
|
||||||
|
|
|
@ -371,4 +371,35 @@ class ArrayLoaderTest extends TestCase
|
||||||
|
|
||||||
$this->assertNull($this->loader->getBranchAlias($config));
|
$this->assertNull($this->loader->getBranchAlias($config));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testPackageLinksRequire(): void
|
||||||
|
{
|
||||||
|
$config = array(
|
||||||
|
'name' => 'acme/package',
|
||||||
|
'version' => 'dev-1',
|
||||||
|
'require' => [
|
||||||
|
'foo/bar' => '1.0',
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
$package = $this->loader->load($config);
|
||||||
|
$this->assertArrayHasKey('foo/bar', $package->getRequires());
|
||||||
|
$this->assertSame('1.0', $package->getRequires()['foo/bar']->getConstraint()->getPrettyString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testPackageLinksRequireInvalid(): void
|
||||||
|
{
|
||||||
|
$config = array(
|
||||||
|
'name' => 'acme/package',
|
||||||
|
'version' => 'dev-1',
|
||||||
|
'require' => [
|
||||||
|
'foo/bar' => [
|
||||||
|
'random-string' => '1.0',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
$package = $this->loader->load($config);
|
||||||
|
$this->assertCount(0, $package->getRequires());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue