]> granicus.if.org Git - php/commitdiff
* Added PHP_RAND_MAX and PHP_MT_RAND_MAX constants
authorKalle Sommer Nielsen <kalle@php.net>
Fri, 1 Oct 2010 09:18:44 +0000 (09:18 +0000)
committerKalle Sommer Nielsen <kalle@php.net>
Fri, 1 Oct 2010 09:18:44 +0000 (09:18 +0000)
* Deprecated getrandmax() and mt_getrandmax() in favour of the new constants

# We should promote constants for static data like such instead of function calls
# maybe this was just an old left-over

NEWS
UPGRADING
ext/standard/basic_functions.c

diff --git a/NEWS b/NEWS
index 02f2cf4d0870ca3d0b3adb0d886a26aba070aefe..178909bedf41b723933a9bee3a93c11dcf5668ef 100644 (file)
--- a/NEWS
+++ b/NEWS
 - Improved the performance of unserialize(). (galaxy dot mipt at gmail dot com, 
   Kalle)
 
+- Added PHP_RAND_MAX & PHP_MT_RAND_MAX constants to get the maximum random 
+  range instead of their counterpart functions. (Kalle)
+
 - Removed legacy features:
   . allow_call_time_pass_reference. (Pierrick)
   . define_syslog_variables ini option and its associated function. (Kalle)
   PDO_mysql. (Johannes)
 
 - Deprecated mysql_list_dbs() (Request #50667). (Andrey)
+- Deprecated getrandmax() & mt_getrandmax() in favour of constants. (Kalle)
 
 - Implemented FR #52555 (Ability to get HTTP response code). (Paul Dragoonis)
 - Implemented FR #51295 (SQLite3::busyTimeout not existing). (Mark)
index 1b9430d9e29f48b5b603bb01f8e38607baf67be4..386934891f714f5559c92a9134187a325e12bf3e 100755 (executable)
--- a/UPGRADING
+++ b/UPGRADING
@@ -8,6 +8,7 @@ UPGRADE NOTES - PHP X.Y
 4. Changes made to existing methods
 5. Changes made to existing classes
 6. Deprecated
+     a. deprecated functions
 7. Extensions:
      a. moved out to PECL and actively maintained there
      b. no longer maintained
@@ -109,7 +110,10 @@ UPGRADE NOTES - PHP X.Y
 6. Deprecated
 =============
 
-- 
+    a. deprecated functions
+
+       - getrandmax()          -- use the PHP_RAND_MAX constant
+       - mt_getrandmax()       -- use the PHP_MT_RAND_MAX constant
 
 ==========
 7. Removed
@@ -237,6 +241,8 @@ UPGRADE NOTES - PHP X.Y
 
        - JSON_PRETTY_PRINT
        - JSON_UNESCAPED_SLASHES
+       - PHP_RAND_MAX
+       - PHP_MT_RAND_MAX
 
      g. New classes
 
index 0475cfca290125162e5a09f752408833b5ded729..916d85ce8084a6fc4fefcc8541ba863209870bc9 100644 (file)
@@ -33,6 +33,7 @@
 #include "ext/session/php_session.h"
 #include "zend_operators.h"
 #include "ext/standard/php_dns.h"
+#include "ext/standard/php_rand.h"
 #include "ext/standard/php_uuencode.h"
 
 #ifdef PHP_WIN32
@@ -2828,8 +2829,8 @@ const zend_function_entry basic_functions[] = { /* {{{ */
 
        PHP_FE(rand,                                                                                                                    arginfo_rand)
        PHP_FE(srand,                                                                                                                   arginfo_srand)
-       PHP_FE(getrandmax,                                                                                                              arginfo_getrandmax)
-       PHP_FE(mt_rand,                                                                                                                 arginfo_mt_rand)
+       PHP_DEP_FE(getrandmax,                                                                                                  arginfo_getrandmax)
+       PHP_DEP_FE(mt_rand,                                                                                                             arginfo_mt_rand)
        PHP_FE(mt_srand,                                                                                                                arginfo_mt_srand)
        PHP_FE(mt_getrandmax,                                                                                                   arginfo_mt_getrandmax)
 
@@ -3551,6 +3552,9 @@ PHP_MINIT_FUNCTION(basic) /* {{{ */
        REGISTER_MATH_CONSTANT(M_SQRT3);
        REGISTER_DOUBLE_CONSTANT("INF", php_get_inf(), CONST_CS | CONST_PERSISTENT);
        REGISTER_DOUBLE_CONSTANT("NAN", php_get_nan(), CONST_CS | CONST_PERSISTENT);
+       
+       REGISTER_MATH_CONSTANT(PHP_RAND_MAX);
+       REGISTER_MATH_CONSTANT(PHP_MT_RAND_MAX);
 
        REGISTER_LONG_CONSTANT("PHP_ROUND_HALF_UP", PHP_ROUND_HALF_UP, CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("PHP_ROUND_HALF_DOWN", PHP_ROUND_HALF_DOWN, CONST_CS | CONST_PERSISTENT);