Skip to content

Commit

Permalink
[PHP 7.0] Skip mt_rand() replacement as not valuable
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Dec 3, 2023
1 parent 3832582 commit 05cc7fc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

?>
3 changes: 1 addition & 2 deletions rules/Php70/Rector/FuncCall/RandomFunctionRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();')]
);
}
Expand Down

0 comments on commit 05cc7fc

Please sign in to comment.