wp-includes/compat.php:715Polyfill for clamp() function added in PHP 8.6.
$valuemixed$minmixed$maxmixedmixed function clamp( $value, $min, $max ) { $throw_value_error = static function ( string $message ) { // The ValueError class was introduced in PHP 8, so in 7.4 throw InvalidArgumentException instead. if ( ! class_exists( 'ValueError', false ) ) { throw new InvalidArgumentException( $message ); } throw new ValueError( $message ); }; if ( is_float( $min ) && is_nan( $min ) ) { $throw_value_error( 'clamp(): Argument #2 ($min) must not be NAN' ); } if ( is_float( $max ) && is_nan( $max ) ) { $throw_value_error( 'clamp(): Argument #3 ($max) must not be NAN' ); } if ( $max < $min ) { $throw_value_error( 'clamp(): Argument #2 ($min) must be smaller than or equal to argument #3 ($max)' ); } /* * The upper bound is checked before the lower bound to match the order in PHP's * implementation. Comparison in PHP is not transitive when operands of different * types are mixed (for example, comparing against a bool coerces both operands to * bool), so both bounds can compare as exceeded at once, and the first check wins. */ if ( $value > $max ) { return $max; } if ( $value < $min ) { return $min; } return $value; }Introduced in 7.1.0.
Signature, return type and hooks compared across 1 parsed release.
src/wp-includes/compat.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.