From 258c4dfdb2255fae480f9ba0a9b64a9680cea00f Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 9 Apr 2020 16:01:44 +0200 Subject: [PATCH] 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. --- ext/standard/basic_functions.stub.php | 4 ++-- ext/standard/basic_functions_arginfo.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php index bde3924c5f..40b424040f 100755 --- a/ext/standard/basic_functions.stub.php +++ b/ext/standard/basic_functions.stub.php @@ -1194,9 +1194,9 @@ function mt_srand(int $seed = 0, int $mode = MT_RAND_MT19937): void {} /** @alias mt_srand */ 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 {} diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h index 4ecc09fe43..aca009456e 100755 --- a/ext/standard/basic_functions_arginfo.h +++ b/ext/standard/basic_functions_arginfo.h @@ -1827,8 +1827,8 @@ ZEND_END_ARG_INFO() #define arginfo_srand arginfo_mt_srand 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_WITH_DEFAULT_VALUE(0, max, IS_LONG, 0, "PHP_INT_MAX") + ZEND_ARG_TYPE_INFO(0, min, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, max, IS_LONG, 0) ZEND_END_ARG_INFO() #define arginfo_mt_rand arginfo_rand -- 2.50.1