Replaces rand
, srand
, getrandmax
functions calls with their mt_*
analogs.
Warning
Using this rule is risky.
Risky when the configured functions are overridden.
Mapping between replaced functions with the new ones.
Allowed types: array
Default value: ['getrandmax' => 'mt_getrandmax', 'rand' => 'mt_rand', 'srand' => 'mt_srand']
Default configuration.
--- Original
+++ New
@@ -1,4 +1,4 @@
<?php
-$a = getrandmax();
-$a = rand($b, $c);
-$a = srand();
+$a = mt_getrandmax();
+$a = mt_rand($b, $c);
+$a = mt_srand();
With configuration: ['replacements' => ['getrandmax' => 'mt_getrandmax']]
.
--- Original
+++ New
@@ -1,4 +1,4 @@
<?php
-$a = getrandmax();
+$a = mt_getrandmax();
$a = rand($b, $c);
$a = srand();
With configuration: ['replacements' => ['rand' => 'random_int']]
.
--- Original
+++ New
@@ -1 +1 @@
-<?php $a = rand($b, $c);
+<?php $a = random_int($b, $c);
The rule is part of the following rule sets:
- @PHP70Migration:risky
Using the @PHP70Migration:risky rule set will enable the
random_api_migration
rule with the config below:['replacements' => ['mt_rand' => 'random_int', 'rand' => 'random_int']]
- @PHP71Migration:risky
Using the @PHP71Migration:risky rule set will enable the
random_api_migration
rule with the config below:['replacements' => ['mt_rand' => 'random_int', 'rand' => 'random_int']]
- @PHP74Migration:risky
Using the @PHP74Migration:risky rule set will enable the
random_api_migration
rule with the config below:['replacements' => ['mt_rand' => 'random_int', 'rand' => 'random_int']]
- @PHP80Migration:risky
Using the @PHP80Migration:risky rule set will enable the
random_api_migration
rule with the config below:['replacements' => ['mt_rand' => 'random_int', 'rand' => 'random_int']]