From 05cc7fc8335106105160c0067fe341d223bdf3ff Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sun, 3 Dec 2023 11:44:35 +0100 Subject: [PATCH] [PHP 7.0] Skip mt_rand() replacement as not valuable --- .../FuncCall/RandomFunctionRector/Fixture/fixture.php.inc | 2 +- rules/Php70/Rector/FuncCall/RandomFunctionRector.php | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/rules-tests/Php70/Rector/FuncCall/RandomFunctionRector/Fixture/fixture.php.inc b/rules-tests/Php70/Rector/FuncCall/RandomFunctionRector/Fixture/fixture.php.inc index 7757f1987c8..614ccacef92 100644 --- a/rules-tests/Php70/Rector/FuncCall/RandomFunctionRector/Fixture/fixture.php.inc +++ b/rules-tests/Php70/Rector/FuncCall/RandomFunctionRector/Fixture/fixture.php.inc @@ -55,7 +55,7 @@ function randomFunction() random_int($a, \Other\Scope\mt_rand($a)); - $a = random_int(1, 2) + random_int(3, 4); + $a = random_int(1, 2) + mt_rand(3, 4); } ?> diff --git a/rules/Php70/Rector/FuncCall/RandomFunctionRector.php b/rules/Php70/Rector/FuncCall/RandomFunctionRector.php index 1c5fbfcdf03..c2523c8727f 100644 --- a/rules/Php70/Rector/FuncCall/RandomFunctionRector.php +++ b/rules/Php70/Rector/FuncCall/RandomFunctionRector.php @@ -26,14 +26,13 @@ final class RandomFunctionRector extends AbstractRector implements MinPhpVersion private const OLD_TO_NEW_FUNCTION_NAMES = [ 'getrandmax' => 'mt_getrandmax', 'srand' => 'mt_srand', - 'mt_rand' => 'random_int', 'rand' => 'random_int', ]; public function getRuleDefinition(): RuleDefinition { return new RuleDefinition( - 'Changes rand, srand, mt_rand and getrandmax to newer alternatives.', + 'Changes rand, srand, and getrandmax to newer alternatives', [new CodeSample('rand();', 'random_int();')] ); }