diff --git a/src/wp-includes/pluggable.php b/src/wp-includes/pluggable.php index 0093f2a33f53d..46995a9e8a5d1 100644 --- a/src/wp-includes/pluggable.php +++ b/src/wp-includes/pluggable.php @@ -3054,10 +3054,11 @@ function wp_rand( $min = null, $max = null ) { global $rnd_value; /* - * Some misconfigured 32-bit environments (Entropy PHP, for example) - * truncate integers larger than PHP_INT_MAX to PHP_INT_MAX rather than overflowing them to floats. + * On 32-bit systems, 0xffffffff exceeds PHP_INT_MAX, so it is cast to a float explicitly. + * Some misconfigured 32-bit environments (Entropy PHP, for example) truncate integer literals + * larger than PHP_INT_MAX to PHP_INT_MAX rather than overflowing them to floats. */ - $max_random_number = 3000000000 === 2147483647 ? (float) '4294967295' : 4294967295; // 4294967295 = 0xffffffff + $max_random_number = PHP_INT_SIZE === 4 ? (float) '4294967295' : 4294967295; // 4294967295 = 0xffffffff if ( null === $min ) { $min = 0; diff --git a/tests/phpstan/baselines/identical.alwaysFalse.neon b/tests/phpstan/baselines/identical.alwaysFalse.neon deleted file mode 100644 index 0d305bff88893..0000000000000 --- a/tests/phpstan/baselines/identical.alwaysFalse.neon +++ /dev/null @@ -1,25 +0,0 @@ -# PHPStan baseline for the `identical.alwaysFalse` errors in WordPress core. -# -# https://phpstan.org/error-identifiers/identical.alwaysFalse -# -# Each entry is scoped to a single file and carries an exact occurrence count, -# so that a new instance is reported as a new error rather than being absorbed -# silently. Fixing an occurrence therefore means decrementing or removing its -# entry here as part of the same change. -# -# The goal is to empty this file and delete it. -# -# Generated by `composer phpstan:baselines`. Do not edit by hand. Regenerate with: -# -# composer phpstan:baselines -- --identifier=identical.alwaysFalse --config=phpstan.neon.dist -# -# This reruns the analysis with the baselines in this directory suppressed, so -# that their errors surface again, and rewrites only this file. - -parameters: - ignoreErrors: - - - message: '#^Strict comparison using \=\=\= between 3000000000 and 2147483647 will always evaluate to false\.$#' - identifier: identical.alwaysFalse - count: 1 - path: ../../../src/wp-includes/pluggable.php