1
0
Fork 0

ArrayLoader: fix integer index of branch alias (#10660)

pull/10669/head
Stephan 2022-03-29 11:37:07 +01:00 committed by GitHub
parent 1fff47bfc7
commit 9f8ee0e40a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View File

@ -421,6 +421,8 @@ class ArrayLoader implements LoaderInterface
if (isset($config['extra']['branch-alias']) && \is_array($config['extra']['branch-alias'])) { if (isset($config['extra']['branch-alias']) && \is_array($config['extra']['branch-alias'])) {
foreach ($config['extra']['branch-alias'] as $sourceBranch => $targetBranch) { foreach ($config['extra']['branch-alias'] as $sourceBranch => $targetBranch) {
$sourceBranch = (string) $sourceBranch;
// ensure it is an alias to a -dev package // ensure it is an alias to a -dev package
if ('-dev' !== substr($targetBranch, -4)) { if ('-dev' !== substr($targetBranch, -4)) {
continue; continue;

View File

@ -347,4 +347,23 @@ class ArrayLoaderTest extends TestCase
$this->assertSame('2019', $package->getSourceReference()); $this->assertSame('2019', $package->getSourceReference());
$this->assertSame('2019', $package->getDistReference()); $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));
}
} }