Skip to content

Commit c6e098e

Browse files
committed
[phpstorm-stubs] remove Pure attribute on rand functions that can change global state
mt_rand both reads and modifies global RNG state internally. random_int()/random_bytes() would modify OS-level state. gmp_random_* modify random state in GMP. array_rand, shuffle, str_shuffle are the same. They all effectively call mt_rand() internally and change state
1 parent 205b3d2 commit c6e098e

File tree

4 files changed

+0
-6
lines changed

4 files changed

+0
-6
lines changed

gmp/gmp.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,6 @@ function gmp_prob_prime(GMP|string|int $num, int $repetitions = 10): int {}
391391
* or a numeric string provided that it is possible to convert the latter to a number.</p>
392392
* @return GMP A random GMP number.
393393
*/
394-
#[Pure(true)]
395394
function gmp_random_bits(int $bits): GMP {}
396395

397396
/**
@@ -401,7 +400,6 @@ function gmp_random_bits(int $bits): GMP {}
401400
* @param GMP|string|int $max <p>A GMP number representing the upper bound for the random number</p>
402401
* @return GMP A random GMP number.
403402
*/
404-
#[Pure(true)]
405403
function gmp_random_range(GMP|string|int $min, GMP|string|int $max): GMP {}
406404

407405
/**

standard/standard_1.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,6 @@ function strrchr(string $haystack, string $needle): string|false {}
358358
* </p>
359359
* @return string the shuffled string.
360360
*/
361-
#[Pure]
362361
function str_shuffle(string $string): string {}
363362

364363
/**

standard/standard_2.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,6 @@ function proc_nice(int $priority): bool {}
933933
* @return int A pseudo random value between min
934934
* (or 0) and max (or getrandmax, inclusive).
935935
*/
936-
#[Pure(true)]
937936
function rand(int $min = 0, int $max): int {}
938937

939938
/**
@@ -972,7 +971,6 @@ function getrandmax(): int {}
972971
* @return int A random integer value between min (or 0)
973972
* and max (or mt_getrandmax, inclusive)
974973
*/
975-
#[Pure(true)]
976974
function mt_rand(int $min = 0, int $max): int {}
977975

978976
/**

standard/standard_9.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ function array_change_key_case(array $array, int $case): array {}
223223
* of keys for the random entries. This is done so that you can pick
224224
* random keys as well as values out of the array.
225225
*/
226-
#[Pure(true)]
227226
function array_rand(array $array, int $num = 1): array|string|int {}
228227

229228
/**

0 commit comments

Comments
 (0)