]> granicus.if.org Git - php/commitdiff
Mark rand/mt_rand args as UNKNOWN
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 9 Apr 2020 14:01:44 +0000 (16:01 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 9 Apr 2020 14:10:56 +0000 (16:10 +0200)
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
ext/standard/basic_functions_arginfo.h

index bde3924c5fcb476fa4d9cd1dc23f4cd16f5783ab..40b424040f1edab29243ca39783bd4f4cbe21922 100755 (executable)
@@ -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 {}
 
index 4ecc09fe438fcab62b637a98daa308a789b93e70..aca009456ee2059a70162287c95a4bc826012d3e 100755 (executable)
@@ -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