diff --git a/language-snippets.ent b/language-snippets.ent index 302a9c81131d..0cd4af3d9e1c 100644 --- a/language-snippets.ent +++ b/language-snippets.ent @@ -31,6 +31,19 @@ highly discouraged.'> '> + + + This function uses the global Mt19937 (“Mersenne Twister”) instance as the source of randomness and thus shares its state with all other functions using the global Mt19937. + Using any of these functions advances the sequence for all the other functions, regardless of scope. + + + Generating repeatable sequences by seeding mt_srand or srand with a known value will also yield repeatable output from this function. + + + Prefer using Random\Randomizer methods in all newly written code. + +'> + Because the Mt19937 (“Mersenne Twister”) engine accepts only a single 32 bit integer as the diff --git a/reference/array/functions/array-rand.xml b/reference/array/functions/array-rand.xml index 5dad19274d4c..6c2156f9075e 100644 --- a/reference/array/functions/array-rand.xml +++ b/reference/array/functions/array-rand.xml @@ -17,6 +17,7 @@ key (or keys) of the random entries. &caution.cryptographically-insecure; + &caution.mt19937-global-state; &reftitle.parameters; diff --git a/reference/array/functions/shuffle.xml b/reference/array/functions/shuffle.xml index 5e24f8943ea5..1d61fcfcfecb 100644 --- a/reference/array/functions/shuffle.xml +++ b/reference/array/functions/shuffle.xml @@ -15,6 +15,7 @@ This function shuffles (randomizes the order of the elements in) an array. &caution.cryptographically-insecure; + &caution.mt19937-global-state; &reftitle.parameters; diff --git a/reference/random/functions/mt-rand.xml b/reference/random/functions/mt-rand.xml index b4c3a460c825..f769e8118078 100644 --- a/reference/random/functions/mt-rand.xml +++ b/reference/random/functions/mt-rand.xml @@ -35,6 +35,7 @@ 15). &caution.cryptographically-insecure; + &caution.mt19937-global-state; &reftitle.parameters; diff --git a/reference/random/functions/rand.xml b/reference/random/functions/rand.xml index ec55b6bb2f1f..a59edaf5cad3 100644 --- a/reference/random/functions/rand.xml +++ b/reference/random/functions/rand.xml @@ -25,6 +25,7 @@ 15). &caution.cryptographically-insecure; + &caution.mt19937-global-state; Prior to PHP 7.1.0, getrandmax was only 32767 on some diff --git a/reference/strings/functions/str-shuffle.xml b/reference/strings/functions/str-shuffle.xml index 4d2489c04847..fd2aac6ee4d2 100644 --- a/reference/strings/functions/str-shuffle.xml +++ b/reference/strings/functions/str-shuffle.xml @@ -17,6 +17,7 @@ of all possible is created. &caution.cryptographically-insecure; + &caution.mt19937-global-state;