Mark rand/mt_rand args as UNKNOWN

The second argument should be mt_getrandmax(), not PHP_INT_MAX.
Additionally this function only accepts either zero or two arguments,
so err on the side of being conservative and mark both UNKNOWN.
This commit is contained in:
Nikita Popov 2020-04-09 16:01:44 +02:00
parent 1dcb559664
commit 258c4dfdb2
2 changed files with 4 additions and 4 deletions

View file

@ -1194,9 +1194,9 @@ function mt_srand(int $seed = 0, int $mode = MT_RAND_MT19937): void {}
/** @alias mt_srand */ /** @alias mt_srand */
function srand(int $seed = 0, int $mode = MT_RAND_MT19937): void {} function srand(int $seed = 0, int $mode = MT_RAND_MT19937): void {}
function rand(int $min = 0, int $max = PHP_INT_MAX): int {} function rand(int $min = UNKNOWN, int $max = UNKNOWN): int {}
function mt_rand(int $min = 0, int $max = PHP_INT_MAX): int {} function mt_rand(int $min = UNKNOWN, int $max = UNKNOWN): int {}
function mt_getrandmax(): int {} function mt_getrandmax(): int {}

View file

@ -1827,8 +1827,8 @@ ZEND_END_ARG_INFO()
#define arginfo_srand arginfo_mt_srand #define arginfo_srand arginfo_mt_srand
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_rand, 0, 0, IS_LONG, 0) ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_rand, 0, 0, IS_LONG, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, min, IS_LONG, 0, "0") ZEND_ARG_TYPE_INFO(0, min, IS_LONG, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, max, IS_LONG, 0, "PHP_INT_MAX") ZEND_ARG_TYPE_INFO(0, max, IS_LONG, 0)
ZEND_END_ARG_INFO() ZEND_END_ARG_INFO()
#define arginfo_mt_rand arginfo_rand #define arginfo_mt_rand arginfo_rand