Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArrayLoader: fix integer index of branch alias #10660

Merged
merged 1 commit into from Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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));
}
}