mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-24 03:35:01 +01:00
Merge pull request #2872 from rectorphp/array-spread
Skip unpackaged args in ArraySpreadInsteadOfArrayMergeRector
This commit is contained in:
commit
efe1de4fe7
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user