ArrayLoader: handle links where target is invalid numeric package name (#10663)

main
Stephan 2 years ago committed by GitHub
parent 9f8ee0e40a
commit 854aab5f03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -357,10 +357,10 @@ class ArrayLoader implements LoaderInterface
}
/**
* @param string $source source package name
* @param string $sourceVersion source package version (pretty version ideally)
* @param string $description link description (e.g. requires, replaces, ..)
* @param array<string, string> $links array of package name => constraint mappings
* @param string $source source package name
* @param string $sourceVersion source package version (pretty version ideally)
* @param string $description link description (e.g. requires, replaces, ..)
* @param array<string|int, string> $links array of package name => constraint mappings
*
* @return Link[]
*
@ -370,7 +370,7 @@ class ArrayLoader implements LoaderInterface
{
$res = array();
foreach ($links as $target => $constraint) {
$target = strtolower($target);
$target = strtolower((string) $target);
$res[$target] = $this->createLink($source, $sourceVersion, $description, $target, $constraint);
}

@ -315,6 +315,13 @@ class ArrayLoaderTest extends TestCase
$this->assertSame('6.6.6', $links['composer-plugin-api']->getConstraint()->getPrettyString());
}
public function testParseLinksIntegerTarget(): void
{
$links = $this->loader->parseLinks('Plugin', '9.9.9', Link::TYPE_REQUIRE, array('1' => 'dev-main'));
$this->assertArrayHasKey('1', $links);
}
public function testNoneStringVersion(): void
{
$config = array(

Loading…
Cancel
Save