diff --git a/src/Composer/Package/Loader/ArrayLoader.php b/src/Composer/Package/Loader/ArrayLoader.php index 9a042d9f224c..618c397eea3c 100644 --- a/src/Composer/Package/Loader/ArrayLoader.php +++ b/src/Composer/Package/Loader/ArrayLoader.php @@ -357,10 +357,10 @@ private function configureCachedLinks(array &$linkCache, PackageInterface $packa } /** - * @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 $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 $links array of package name => constraint mappings * * @return Link[] * @@ -370,7 +370,7 @@ public function parseLinks(string $source, string $sourceVersion, string $descri { $res = array(); foreach ($links as $target => $constraint) { - $target = strtolower($target); + $target = strtolower((string) $target); $res[$target] = $this->createLink($source, $sourceVersion, $description, $target, $constraint); } diff --git a/tests/Composer/Test/Package/Loader/ArrayLoaderTest.php b/tests/Composer/Test/Package/Loader/ArrayLoaderTest.php index a3f5d28c6e40..eab43a3c630a 100644 --- a/tests/Composer/Test/Package/Loader/ArrayLoaderTest.php +++ b/tests/Composer/Test/Package/Loader/ArrayLoaderTest.php @@ -315,6 +315,13 @@ public function testPluginApiVersionDoesSupportSelfVersion(): void $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(