From 5a28cd22d5477f74586391fd288ecc7c6882b26c Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Mon, 17 Feb 2020 15:17:08 +0100 Subject: [PATCH] Skip unpackaged args in ArraySpreadInsteadOfArrayMergeRector --- .../ArraySpreadInsteadOfArrayMergeRector.php | 6 +++++- .../Fixture/skip_spread_array_merge.php.inc | 20 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 rules/php-74/tests/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector/Fixture/skip_spread_array_merge.php.inc diff --git a/rules/php-74/src/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php b/rules/php-74/src/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php index 240b5be45ca..11c5c5ec281 100644 --- a/rules/php-74/src/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php +++ b/rules/php-74/src/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php @@ -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; } diff --git a/rules/php-74/tests/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector/Fixture/skip_spread_array_merge.php.inc b/rules/php-74/tests/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector/Fixture/skip_spread_array_merge.php.inc new file mode 100644 index 00000000000..3a7a09391c1 --- /dev/null +++ b/rules/php-74/tests/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector/Fixture/skip_spread_array_merge.php.inc @@ -0,0 +1,20 @@ +