Merge pull request #3130 from rectorphp/fix-array-merge

Fix missing array key in ArrayMergeOfNonArraysToSimpleArrayRector
This commit is contained in:
Tomas Votruba 2020-04-03 01:31:10 +02:00 committed by GitHub
commit 79f7fd52a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 1 deletions

View File

@ -83,7 +83,7 @@ PHP
}
foreach ($nestedArrayItem->items as $nestedArrayItemItem) {
$array->items[] = new ArrayItem($nestedArrayItemItem->value);
$array->items[] = new ArrayItem($nestedArrayItemItem->value, $nestedArrayItemItem->key);
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace Rector\CodeQuality\Tests\Rector\FuncCall\ArrayMergeOfNonArraysToSimpleArrayRector\Fixture;
class WithKeys
{
public function go()
{
$type = 't';
$query = 'q';
$res = array_merge(['results' => []], ['query' => $query, 'type' => $type]);
}
}
?>
-----
<?php
namespace Rector\CodeQuality\Tests\Rector\FuncCall\ArrayMergeOfNonArraysToSimpleArrayRector\Fixture;
class WithKeys
{
public function go()
{
$type = 't';
$query = 'q';
$res = ['results' => [], 'query' => $query, 'type' => $type];
}
}
?>