diff --git a/src/Composer/Package/Loader/ArrayLoader.php b/src/Composer/Package/Loader/ArrayLoader.php index 3d315045d965..9a042d9f224c 100644 --- a/src/Composer/Package/Loader/ArrayLoader.php +++ b/src/Composer/Package/Loader/ArrayLoader.php @@ -421,6 +421,8 @@ public function getBranchAlias(array $config): ?string 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 2fb83698b9c5..a3f5d28c6e40 100644 --- a/tests/Composer/Test/Package/Loader/ArrayLoaderTest.php +++ b/tests/Composer/Test/Package/Loader/ArrayLoaderTest.php @@ -347,4 +347,23 @@ public function testNoneStringSourceDistReference(): void $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)); + } }