diff --git a/src/Composer/Package/Loader/ArrayLoader.php b/src/Composer/Package/Loader/ArrayLoader.php index 3d315045d..9a042d9f2 100644 --- a/src/Composer/Package/Loader/ArrayLoader.php +++ b/src/Composer/Package/Loader/ArrayLoader.php @@ -421,6 +421,8 @@ class ArrayLoader implements LoaderInterface if (isset($config['extra']['branch-alias']) && \is_array($config['extra']['branch-alias'])) { foreach ($config['extra']['branch-alias'] as $sourceBranch => $targetBranch) { + $sourceBranch = (string) $sourceBranch; + // ensure it is an alias to a -dev package if ('-dev' !== substr($targetBranch, -4)) { continue; diff --git a/tests/Composer/Test/Package/Loader/ArrayLoaderTest.php b/tests/Composer/Test/Package/Loader/ArrayLoaderTest.php index 2fb83698b..a3f5d28c6 100644 --- a/tests/Composer/Test/Package/Loader/ArrayLoaderTest.php +++ b/tests/Composer/Test/Package/Loader/ArrayLoaderTest.php @@ -347,4 +347,23 @@ class ArrayLoaderTest extends TestCase $this->assertSame('2019', $package->getSourceReference()); $this->assertSame('2019', $package->getDistReference()); } + + public function testBranchAliasIntegerIndex(): void + { + $config = array( + 'name' => 'acme/package', + 'version' => 'dev-1', + 'extra' => [ + 'branch-alias' => [ + '1' => '1.3-dev', + ], + ], + 'dist' => [ + 'type' => 'zip', + 'url' => 'https://example.org/', + ], + ); + + $this->assertNull($this->loader->getBranchAlias($config)); + } }