Skip to content

Commit

Permalink
ArrayLoader: fix integer index of branch alias
Browse files Browse the repository at this point in the history
  • Loading branch information
glaubinix committed Mar 26, 2022
1 parent 61be158 commit f1371d3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Composer/Package/Loader/ArrayLoader.php
Expand Up @@ -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;
Expand Down
19 changes: 19 additions & 0 deletions tests/Composer/Test/Package/Loader/ArrayLoaderTest.php
Expand Up @@ -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));
}
}

0 comments on commit f1371d3

Please sign in to comment.