Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PHP 7.0] Skip mt_rand() replacement as not valuable #5315

Merged
merged 1 commit into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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