Skip to content

Fix GH-10292 1st param of mt_srand() has UNKNOWN default on PHP <8.3 #10429

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

Closed
wants to merge 2 commits into from
Closed
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
4 changes: 2 additions & 2 deletions ext/standard/basic_functions.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -1548,10 +1548,10 @@ function quoted_printable_encode(string $string): string {}

/* mt_rand.c */

function mt_srand(int $seed = 0, int $mode = MT_RAND_MT19937): void {}
function mt_srand(int $seed = UNKNOWN, int $mode = MT_RAND_MT19937): void {}

/** @alias mt_srand */
function srand(int $seed = 0, int $mode = MT_RAND_MT19937): void {}
function srand(int $seed = UNKNOWN, int $mode = MT_RAND_MT19937): void {}

function rand(int $min = UNKNOWN, int $max = UNKNOWN): int {}

Expand Down
4 changes: 2 additions & 2 deletions ext/standard/basic_functions_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 87ed2b04b9b46ce3df78d6f9d6d62bd6b2ae8fe5 */
* Stub hash: eb6a3a2e3cf8f62e768d5d4968606438819e6cf0 */

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_set_time_limit, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, seconds, IS_LONG, 0)
Expand Down Expand Up @@ -1813,7 +1813,7 @@ ZEND_END_ARG_INFO()
#define arginfo_quoted_printable_encode arginfo_base64_encode

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mt_srand, 0, 0, IS_VOID, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, seed, IS_LONG, 0, "0")
ZEND_ARG_TYPE_INFO(0, seed, IS_LONG, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mode, IS_LONG, 0, "MT_RAND_MT19937")
ZEND_END_ARG_INFO()

Expand Down
13 changes: 13 additions & 0 deletions ext/standard/tests/general_functions/rand.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,21 @@ var_dump(rand(0,3));

var_dump(srand());
var_dump(srand(-1));
try {
srand(mode: MT_RAND_MT19937);
} catch (Error $e) {
echo $e->getMessage() . "\n";
}

var_dump(mt_srand());
var_dump(mt_srand(-1));

try {
mt_srand(mode: MT_RAND_MT19937);
} catch (Error $e) {
echo $e->getMessage() . "\n";
}

var_dump(getrandmax());

var_dump(mt_getrandmax());
Expand All @@ -32,8 +43,10 @@ int(%i)
int(%d)
NULL
NULL
srand(): Argument #1 ($seed) must be passed explicitly, because the default value is not known
NULL
NULL
mt_srand(): Argument #1 ($seed) must be passed explicitly, because the default value is not known
int(%d)
int(%d)
Done