diff --git a/config/set/coding-style.php b/config/set/coding-style.php
index 957d6839446..0623bea330d 100644
--- a/config/set/coding-style.php
+++ b/config/set/coding-style.php
@@ -15,6 +15,7 @@ use Rector\CodingStyle\Rector\ClassMethod\NewlineBeforeNewAssignSetRector;
use Rector\CodingStyle\Rector\Closure\StaticClosureRector;
use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector;
use Rector\CodingStyle\Rector\Encapsed\WrapEncapsedVariableInCurlyBracesRector;
+use Rector\CodingStyle\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector;
use Rector\CodingStyle\Rector\FuncCall\CallUserFuncArrayToVariadicRector;
use Rector\CodingStyle\Rector\FuncCall\CallUserFuncToMethodCallRector;
use Rector\CodingStyle\Rector\FuncCall\ConsistentImplodeRector;
@@ -36,5 +37,5 @@ use Rector\Transform\Rector\FuncCall\FuncCallToConstFetchRector;
use Rector\Visibility\Rector\ClassMethod\ExplicitPublicClassMethodRector;
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->ruleWithConfiguration(FuncCallToConstFetchRector::class, ['php_sapi_name' => 'PHP_SAPI', 'pi' => 'M_PI']);
- $rectorConfig->rules([SeparateMultiUseImportsRector::class, PostIncDecToPreIncDecRector::class, NewlineAfterStatementRector::class, RemoveFinalFromConstRector::class, NullableCompareToNullRector::class, ConsistentImplodeRector::class, TernaryConditionVariableAssignmentRector::class, SymplifyQuoteEscapeRector::class, StringClassNameToClassConstantRector::class, CatchExceptionNameMatchingTypeRector::class, UseIncrementAssignRector::class, SplitDoubleAssignRector::class, EncapsedStringsToSprintfRector::class, WrapEncapsedVariableInCurlyBracesRector::class, NewlineBeforeNewAssignSetRector::class, AddArrayDefaultToArrayPropertyRector::class, MakeInheritedMethodVisibilitySameAsParentRector::class, CallUserFuncArrayToVariadicRector::class, VersionCompareFuncCallToConstantRector::class, StaticArrowFunctionRector::class, StaticClosureRector::class, CountArrayToEmptyArrayComparisonRector::class, CallUserFuncToMethodCallRector::class, FuncGetArgsToVariadicParamRector::class, StrictArraySearchRector::class, UseClassKeywordForClassNameResolutionRector::class, SplitGroupedPropertiesRector::class, SplitGroupedClassConstantsRector::class, ExplicitPublicClassMethodRector::class]);
+ $rectorConfig->rules([SeparateMultiUseImportsRector::class, PostIncDecToPreIncDecRector::class, NewlineAfterStatementRector::class, RemoveFinalFromConstRector::class, NullableCompareToNullRector::class, ConsistentImplodeRector::class, TernaryConditionVariableAssignmentRector::class, SymplifyQuoteEscapeRector::class, StringClassNameToClassConstantRector::class, CatchExceptionNameMatchingTypeRector::class, UseIncrementAssignRector::class, SplitDoubleAssignRector::class, EncapsedStringsToSprintfRector::class, WrapEncapsedVariableInCurlyBracesRector::class, NewlineBeforeNewAssignSetRector::class, AddArrayDefaultToArrayPropertyRector::class, MakeInheritedMethodVisibilitySameAsParentRector::class, CallUserFuncArrayToVariadicRector::class, VersionCompareFuncCallToConstantRector::class, StaticArrowFunctionRector::class, StaticClosureRector::class, CountArrayToEmptyArrayComparisonRector::class, CallUserFuncToMethodCallRector::class, FuncGetArgsToVariadicParamRector::class, StrictArraySearchRector::class, UseClassKeywordForClassNameResolutionRector::class, SplitGroupedPropertiesRector::class, SplitGroupedClassConstantsRector::class, ExplicitPublicClassMethodRector::class, ArraySpreadInsteadOfArrayMergeRector::class]);
};
diff --git a/docs/rector_rules_overview.md b/docs/rector_rules_overview.md
index a02caed7e16..e8c5154fc95 100644
--- a/docs/rector_rules_overview.md
+++ b/docs/rector_rules_overview.md
@@ -8,7 +8,7 @@
- [CodeQuality](#codequality) (72)
-- [CodingStyle](#codingstyle) (28)
+- [CodingStyle](#codingstyle) (29)
- [DeadCode](#deadcode) (42)
@@ -36,7 +36,7 @@
- [Php73](#php73) (9)
-- [Php74](#php74) (13)
+- [Php74](#php74) (12)
- [Php80](#php80) (16)
@@ -1597,6 +1597,32 @@ Adds array default value to property to prevent foreach over null error
+### ArraySpreadInsteadOfArrayMergeRector
+
+Change `array_merge()` to spread operator
+
+- class: [`Rector\CodingStyle\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector`](../rules/CodingStyle/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php)
+
+```diff
+ class SomeClass
+ {
+ public function run($iter1, $iter2)
+ {
+- $values = array_merge(iterator_to_array($iter1), iterator_to_array($iter2));
++ $values = [...$iter1, ...$iter2];
+
+ // Or to generalize to all iterables
+- $anotherValues = array_merge(
+- is_array($iter1) ? $iter1 : iterator_to_array($iter1),
+- is_array($iter2) ? $iter2 : iterator_to_array($iter2)
+- );
++ $anotherValues = [...$iter1, ...$iter2];
+ }
+ }
+```
+
+
+
### BinarySwitchToIfElseRector
Changes switch with 2 options to if-else
@@ -4483,32 +4509,6 @@ Change `array_key_exists()` on property to `property_exists()`
-### ArraySpreadInsteadOfArrayMergeRector
-
-Change `array_merge()` to spread operator
-
-- class: [`Rector\Php74\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector`](../rules/Php74/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php)
-
-```diff
- class SomeClass
- {
- public function run($iter1, $iter2)
- {
-- $values = array_merge(iterator_to_array($iter1), iterator_to_array($iter2));
-+ $values = [...$iter1, ...$iter2];
-
- // Or to generalize to all iterables
-- $anotherValues = array_merge(
-- is_array($iter1) ? $iter1 : iterator_to_array($iter1),
-- is_array($iter2) ? $iter2 : iterator_to_array($iter2)
-- );
-+ $anotherValues = [...$iter1, ...$iter2];
- }
- }
-```
-
-
-
### ClosureToArrowFunctionRector
Change closure to arrow function
diff --git a/rules/Php74/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php b/rules/CodingStyle/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php
similarity index 94%
rename from rules/Php74/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php
rename to rules/CodingStyle/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php
index 1b3cd8a4dce..fb3b7309ded 100644
--- a/rules/Php74/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php
+++ b/rules/CodingStyle/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php
@@ -1,7 +1,7 @@
$baseDir . '/rules/CodingStyle/Rector/Closure/StaticClosureRector.php',
'Rector\\CodingStyle\\Rector\\Encapsed\\EncapsedStringsToSprintfRector' => $baseDir . '/rules/CodingStyle/Rector/Encapsed/EncapsedStringsToSprintfRector.php',
'Rector\\CodingStyle\\Rector\\Encapsed\\WrapEncapsedVariableInCurlyBracesRector' => $baseDir . '/rules/CodingStyle/Rector/Encapsed/WrapEncapsedVariableInCurlyBracesRector.php',
+ 'Rector\\CodingStyle\\Rector\\FuncCall\\ArraySpreadInsteadOfArrayMergeRector' => $baseDir . '/rules/CodingStyle/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php',
'Rector\\CodingStyle\\Rector\\FuncCall\\CallUserFuncArrayToVariadicRector' => $baseDir . '/rules/CodingStyle/Rector/FuncCall/CallUserFuncArrayToVariadicRector.php',
'Rector\\CodingStyle\\Rector\\FuncCall\\CallUserFuncToMethodCallRector' => $baseDir . '/rules/CodingStyle/Rector/FuncCall/CallUserFuncToMethodCallRector.php',
'Rector\\CodingStyle\\Rector\\FuncCall\\ConsistentImplodeRector' => $baseDir . '/rules/CodingStyle/Rector/FuncCall/ConsistentImplodeRector.php',
@@ -1827,7 +1828,6 @@ return array(
'Rector\\Php74\\Rector\\Closure\\ClosureToArrowFunctionRector' => $baseDir . '/rules/Php74/Rector/Closure/ClosureToArrowFunctionRector.php',
'Rector\\Php74\\Rector\\Double\\RealToFloatTypeCastRector' => $baseDir . '/rules/Php74/Rector/Double/RealToFloatTypeCastRector.php',
'Rector\\Php74\\Rector\\FuncCall\\ArrayKeyExistsOnPropertyRector' => $baseDir . '/rules/Php74/Rector/FuncCall/ArrayKeyExistsOnPropertyRector.php',
- 'Rector\\Php74\\Rector\\FuncCall\\ArraySpreadInsteadOfArrayMergeRector' => $baseDir . '/rules/Php74/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php',
'Rector\\Php74\\Rector\\FuncCall\\FilterVarToAddSlashesRector' => $baseDir . '/rules/Php74/Rector/FuncCall/FilterVarToAddSlashesRector.php',
'Rector\\Php74\\Rector\\FuncCall\\MbStrrposEncodingArgumentPositionRector' => $baseDir . '/rules/Php74/Rector/FuncCall/MbStrrposEncodingArgumentPositionRector.php',
'Rector\\Php74\\Rector\\FuncCall\\MoneyFormatToNumberFormatRector' => $baseDir . '/rules/Php74/Rector/FuncCall/MoneyFormatToNumberFormatRector.php',
diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php
index 233b4619d6e..3cb2556c217 100644
--- a/vendor/composer/autoload_static.php
+++ b/vendor/composer/autoload_static.php
@@ -1342,6 +1342,7 @@ class ComposerStaticInit18ad0e678efbbb500e116f7c54cccdd4
'Rector\\CodingStyle\\Rector\\Closure\\StaticClosureRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/Closure/StaticClosureRector.php',
'Rector\\CodingStyle\\Rector\\Encapsed\\EncapsedStringsToSprintfRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/Encapsed/EncapsedStringsToSprintfRector.php',
'Rector\\CodingStyle\\Rector\\Encapsed\\WrapEncapsedVariableInCurlyBracesRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/Encapsed/WrapEncapsedVariableInCurlyBracesRector.php',
+ 'Rector\\CodingStyle\\Rector\\FuncCall\\ArraySpreadInsteadOfArrayMergeRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php',
'Rector\\CodingStyle\\Rector\\FuncCall\\CallUserFuncArrayToVariadicRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/FuncCall/CallUserFuncArrayToVariadicRector.php',
'Rector\\CodingStyle\\Rector\\FuncCall\\CallUserFuncToMethodCallRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/FuncCall/CallUserFuncToMethodCallRector.php',
'Rector\\CodingStyle\\Rector\\FuncCall\\ConsistentImplodeRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/FuncCall/ConsistentImplodeRector.php',
@@ -2045,7 +2046,6 @@ class ComposerStaticInit18ad0e678efbbb500e116f7c54cccdd4
'Rector\\Php74\\Rector\\Closure\\ClosureToArrowFunctionRector' => __DIR__ . '/../..' . '/rules/Php74/Rector/Closure/ClosureToArrowFunctionRector.php',
'Rector\\Php74\\Rector\\Double\\RealToFloatTypeCastRector' => __DIR__ . '/../..' . '/rules/Php74/Rector/Double/RealToFloatTypeCastRector.php',
'Rector\\Php74\\Rector\\FuncCall\\ArrayKeyExistsOnPropertyRector' => __DIR__ . '/../..' . '/rules/Php74/Rector/FuncCall/ArrayKeyExistsOnPropertyRector.php',
- 'Rector\\Php74\\Rector\\FuncCall\\ArraySpreadInsteadOfArrayMergeRector' => __DIR__ . '/../..' . '/rules/Php74/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php',
'Rector\\Php74\\Rector\\FuncCall\\FilterVarToAddSlashesRector' => __DIR__ . '/../..' . '/rules/Php74/Rector/FuncCall/FilterVarToAddSlashesRector.php',
'Rector\\Php74\\Rector\\FuncCall\\MbStrrposEncodingArgumentPositionRector' => __DIR__ . '/../..' . '/rules/Php74/Rector/FuncCall/MbStrrposEncodingArgumentPositionRector.php',
'Rector\\Php74\\Rector\\FuncCall\\MoneyFormatToNumberFormatRector' => __DIR__ . '/../..' . '/rules/Php74/Rector/FuncCall/MoneyFormatToNumberFormatRector.php',