1
0
Fork 0

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

pull/10669/head
Stephan 2022-03-29 11:46:51 +01:00 committed by GitHub
parent 9f8ee0e40a
commit 854aab5f03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 5 deletions

View File

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

View File

@ -315,6 +315,13 @@ class ArrayLoaderTest extends TestCase
$this->assertSame('6.6.6', $links['composer-plugin-api']->getConstraint()->getPrettyString()); $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 public function testNoneStringVersion(): void
{ {
$config = array( $config = array(