diff --git a/config/set/downgrade-php74.php b/config/set/downgrade-php74.php
index 74a113ad274..76067fa10a6 100644
--- a/config/set/downgrade-php74.php
+++ b/config/set/downgrade-php74.php
@@ -5,6 +5,7 @@ declare(strict_types=1);
use Rector\DowngradePhp74\Rector\Array_\DowngradeArraySpreadRector;
use Rector\DowngradePhp74\Rector\ArrowFunction\ArrowFunctionToAnonymousFunctionRector;
use Rector\DowngradePhp74\Rector\Coalesce\DowngradeNullCoalescingOperatorRector;
+use Rector\DowngradePhp74\Rector\FuncCall\DowngradeArrayMergeCallWithoutArgumentsRector;
use Rector\DowngradePhp74\Rector\FuncCall\DowngradeStripTagsCallWithArrayRector;
use Rector\DowngradePhp74\Rector\LNumber\DowngradeNumericLiteralSeparatorRector;
use Rector\DowngradePhp74\Rector\Property\DowngradeTypedPropertyRector;
@@ -18,4 +19,5 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services->set(DowngradeNumericLiteralSeparatorRector::class);
$services->set(DowngradeStripTagsCallWithArrayRector::class);
$services->set(DowngradeArraySpreadRector::class);
+ $services->set(DowngradeArrayMergeCallWithoutArgumentsRector::class);
};
diff --git a/docs/rector_rules_overview.md b/docs/rector_rules_overview.md
index 7c41f2fe112..5f8b3341be3 100644
--- a/docs/rector_rules_overview.md
+++ b/docs/rector_rules_overview.md
@@ -1,4 +1,4 @@
-# All 592 Rectors Overview
+# All 593 Rectors Overview
- [Projects](#projects)
---
@@ -19,7 +19,7 @@
- [DowngradePhp71](#downgradephp71) (3)
- [DowngradePhp72](#downgradephp72) (2)
- [DowngradePhp73](#downgradephp73) (1)
-- [DowngradePhp74](#downgradephp74) (6)
+- [DowngradePhp74](#downgradephp74) (7)
- [DowngradePhp80](#downgradephp80) (6)
- [DynamicTypeAnalysis](#dynamictypeanalysis) (3)
- [FileSystemRector](#filesystemrector) (1)
@@ -5072,6 +5072,29 @@ Replace arrow functions with anonymous functions
+### `DowngradeArrayMergeCallWithoutArgumentsRector`
+
+- class: [`Rector\DowngradePhp74\Rector\FuncCall\DowngradeArrayMergeCallWithoutArgumentsRector`](/rules/downgrade-php74/src/Rector/FuncCall/DowngradeArrayMergeCallWithoutArgumentsRector.php)
+- [test fixtures](/rules/downgrade-php74/tests/Rector/FuncCall/DowngradeArrayMergeCallWithoutArgumentsRector/Fixture)
+
+Add missing param to `array_merge` and `array_merge_recursive`
+
+```diff
+ class SomeClass
+ {
+- public function run()
++ public function run()
+ {
+- array_merge();
+- array_merge_recursive();
++ array_merge([]);
++ array_merge_recursive([]);
+ }
+ }
+```
+
+
+
### `DowngradeArraySpreadRector`
- class: [`Rector\DowngradePhp74\Rector\Array_\DowngradeArraySpreadRector`](/rules/downgrade-php74/src/Rector/Array_/DowngradeArraySpreadRector.php)
diff --git a/rules/downgrade-php74/src/Rector/FuncCall/DowngradeArrayMergeCallWithoutArgumentsRector.php b/rules/downgrade-php74/src/Rector/FuncCall/DowngradeArrayMergeCallWithoutArgumentsRector.php
new file mode 100644
index 00000000000..4634d1283cb
--- /dev/null
+++ b/rules/downgrade-php74/src/Rector/FuncCall/DowngradeArrayMergeCallWithoutArgumentsRector.php
@@ -0,0 +1,84 @@
+shouldRefactor($node)) {
+ return null;
+ }
+
+ $node->args = [new Arg(new Array_())];
+
+ return $node;
+ }
+
+ private function shouldRefactor(FuncCall $funcCall): bool
+ {
+ if (! $this->isNames($funcCall, ['array_merge', 'array_merge_recursive'])) {
+ return false;
+ }
+
+ // If param is provided, do nothing
+ if ($funcCall->args !== []) {
+ return false;
+ }
+
+ return true;
+ }
+}
diff --git a/rules/downgrade-php74/tests/Rector/FuncCall/DowngradeArrayMergeCallWithoutArgumentsRector/DowngradeArrayMergeCallWithoutArgumentsRectorTest.php b/rules/downgrade-php74/tests/Rector/FuncCall/DowngradeArrayMergeCallWithoutArgumentsRector/DowngradeArrayMergeCallWithoutArgumentsRectorTest.php
new file mode 100644
index 00000000000..937341d1b43
--- /dev/null
+++ b/rules/downgrade-php74/tests/Rector/FuncCall/DowngradeArrayMergeCallWithoutArgumentsRector/DowngradeArrayMergeCallWithoutArgumentsRectorTest.php
@@ -0,0 +1,38 @@
+doTestFileInfo($fileInfo);
+ }
+
+ public function provideData(): Iterator
+ {
+ return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
+ }
+
+ protected function getRectorClass(): string
+ {
+ return DowngradeArrayMergeCallWithoutArgumentsRector::class;
+ }
+
+ protected function getPhpVersion(): string
+ {
+ return PhpVersionFeature::BEFORE_STRIP_TAGS_WITH_ARRAY;
+ }
+}
diff --git a/rules/downgrade-php74/tests/Rector/FuncCall/DowngradeArrayMergeCallWithoutArgumentsRector/Fixture/array_merge.php.inc b/rules/downgrade-php74/tests/Rector/FuncCall/DowngradeArrayMergeCallWithoutArgumentsRector/Fixture/array_merge.php.inc
new file mode 100644
index 00000000000..d40c68d8f04
--- /dev/null
+++ b/rules/downgrade-php74/tests/Rector/FuncCall/DowngradeArrayMergeCallWithoutArgumentsRector/Fixture/array_merge.php.inc
@@ -0,0 +1,27 @@
+
+-----
+
diff --git a/rules/downgrade-php74/tests/Rector/FuncCall/DowngradeArrayMergeCallWithoutArgumentsRector/Fixture/array_merge_recursive.php.inc b/rules/downgrade-php74/tests/Rector/FuncCall/DowngradeArrayMergeCallWithoutArgumentsRector/Fixture/array_merge_recursive.php.inc
new file mode 100644
index 00000000000..8b09f9b4801
--- /dev/null
+++ b/rules/downgrade-php74/tests/Rector/FuncCall/DowngradeArrayMergeCallWithoutArgumentsRector/Fixture/array_merge_recursive.php.inc
@@ -0,0 +1,27 @@
+
+-----
+
diff --git a/rules/downgrade-php74/tests/Rector/FuncCall/DowngradeArrayMergeCallWithoutArgumentsRector/Fixture/skip_array.php.inc b/rules/downgrade-php74/tests/Rector/FuncCall/DowngradeArrayMergeCallWithoutArgumentsRector/Fixture/skip_array.php.inc
new file mode 100644
index 00000000000..2b311c59162
--- /dev/null
+++ b/rules/downgrade-php74/tests/Rector/FuncCall/DowngradeArrayMergeCallWithoutArgumentsRector/Fixture/skip_array.php.inc
@@ -0,0 +1,15 @@
+
diff --git a/rules/downgrade-php74/tests/Rector/FuncCall/DowngradeArrayMergeCallWithoutArgumentsRector/Fixture/skip_multiple_arguments.php.inc b/rules/downgrade-php74/tests/Rector/FuncCall/DowngradeArrayMergeCallWithoutArgumentsRector/Fixture/skip_multiple_arguments.php.inc
new file mode 100644
index 00000000000..c2e3b999b2d
--- /dev/null
+++ b/rules/downgrade-php74/tests/Rector/FuncCall/DowngradeArrayMergeCallWithoutArgumentsRector/Fixture/skip_multiple_arguments.php.inc
@@ -0,0 +1,22 @@
+
diff --git a/rules/downgrade-php74/tests/Rector/FuncCall/DowngradeArrayMergeCallWithoutArgumentsRector/Fixture/skip_variable.php.inc b/rules/downgrade-php74/tests/Rector/FuncCall/DowngradeArrayMergeCallWithoutArgumentsRector/Fixture/skip_variable.php.inc
new file mode 100644
index 00000000000..d9069c7851e
--- /dev/null
+++ b/rules/downgrade-php74/tests/Rector/FuncCall/DowngradeArrayMergeCallWithoutArgumentsRector/Fixture/skip_variable.php.inc
@@ -0,0 +1,16 @@
+
diff --git a/src/ValueObject/PhpVersionFeature.php b/src/ValueObject/PhpVersionFeature.php
index 7e2d592bac9..27f0d0796f3 100644
--- a/src/ValueObject/PhpVersionFeature.php
+++ b/src/ValueObject/PhpVersionFeature.php
@@ -226,4 +226,9 @@ final class PhpVersionFeature
* @var string
*/
public const IS_ITERABLE = '7.1';
+
+ /**
+ * @var string
+ */
+ public const BEFORE_ARRAY_MERGE_WITHOUT_ARGUMENTS = '7.3';
}