Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
random: Fix unknown
mt_srand()
compatibility for unknown modes (#13544
) PHP 8.1 and below interpreted unknown modes as `MT_RAND_MT19937`, but PHP 8.2+ interprets them as `MT_RAND_PHP`. Align the behavior with PHP 8.1 and below, because folks should be steered towards the standard mode.
- Loading branch information
Showing
3 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--TEST-- | ||
mt_srand(): Test unknown modes | ||
--FILE-- | ||
<?php | ||
// MT_RAND_MT19937 | ||
mt_srand(1, 0); | ||
var_dump(mt_rand()); | ||
// MT_RAND_PHP | ||
mt_srand(1, 1); | ||
var_dump(mt_rand()); | ||
// Unknown | ||
mt_srand(1, 2); | ||
var_dump(mt_rand()); | ||
// Equivalent to 0 when cast as unsigned 8-bit integer | ||
mt_srand(1, 256); | ||
var_dump(mt_rand()); | ||
?> | ||
--EXPECT-- | ||
int(895547922) | ||
int(1244335972) | ||
int(895547922) | ||
int(895547922) |