Skip unpackaged args in ArraySpreadInsteadOfArrayMergeRector

This commit is contained in:
TomasVotruba 2020-02-17 15:17:08 +01:00
parent 679a5b5262
commit 5a28cd22d5
2 changed files with 25 additions and 1 deletions

View File

@ -100,8 +100,12 @@ PHP
$array = new Array_();
foreach ($funcCall->args as $arg) {
$value = $arg->value;
// cannot handle unpacked arguments
if ($arg->unpack) {
return null;
}
$value = $arg->value;
if ($this->shouldSkipArrayForInvalidTypeOrKeys($value)) {
return null;
}

View File

@ -0,0 +1,20 @@
<?php
namespace Rector\Php74\Tests\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector\Fixture;
use stdClass;
class SkipSpreadyArrayMerge
{
public function run()
{
$values = [
[new stdClass()],
[new stdClass]
];
$items = array_merge(...$values);
return array_merge($items, ...$values);
}
}