From 59b1a33be2adf2d2119f66722928163c3e4f6ba6 Mon Sep 17 00:00:00 2001 From: kylekatarnls Date: Sat, 9 Aug 2025 15:24:13 +0200 Subject: [PATCH 1/6] Implement clamp function Co-authored-by: thinkverse --- ext/standard/basic_functions.stub.php | 6 +++ ext/standard/basic_functions_arginfo.h | 14 +++++++ ext/standard/math.c | 53 ++++++++++++++++++++++++++ ext/standard/tests/math/clamp.phpt | 49 ++++++++++++++++++++++++ 4 files changed, 122 insertions(+) create mode 100644 ext/standard/tests/math/clamp.phpt diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php index 7913ca0e00194..e27dca069c55b 100644 --- a/ext/standard/basic_functions.stub.php +++ b/ext/standard/basic_functions.stub.php @@ -1606,6 +1606,12 @@ function min(mixed $value, mixed ...$values): mixed {} */ function max(mixed $value, mixed ...$values): mixed {} +/** + * @compile-time-eval + * @frameless-function {"arity": 3} + */ +function clamp(mixed $value, mixed $min, mixed $max): mixed {} + function array_walk(array|object &$array, callable $callback, mixed $arg = UNKNOWN): true {} function array_walk_recursive(array|object &$array, callable $callback, mixed $arg = UNKNOWN): true {} diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h index 0a21d7d76426c..39e9131388288 100644 --- a/ext/standard/basic_functions_arginfo.h +++ b/ext/standard/basic_functions_arginfo.h @@ -138,6 +138,12 @@ ZEND_END_ARG_INFO() #define arginfo_max arginfo_min +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_clamp, 0, 3, IS_MIXED, 0) + ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0) + ZEND_ARG_TYPE_INFO(0, min, IS_MIXED, 0) + ZEND_ARG_TYPE_INFO(0, max, IS_MIXED, 0) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_array_walk, 0, 2, IS_TRUE, 0) ZEND_ARG_TYPE_MASK(1, array, MAY_BE_ARRAY|MAY_BE_OBJECT, NULL) ZEND_ARG_TYPE_INFO(0, callback, IS_CALLABLE, 0) @@ -2197,6 +2203,12 @@ static const zend_frameless_function_info frameless_function_infos_max[] = { { 0 }, }; +ZEND_FRAMELESS_FUNCTION(clamp, 3); +static const zend_frameless_function_info frameless_function_infos_clamp[] = { + { ZEND_FRAMELESS_FUNCTION_NAME(clamp, 3), 3 }, + { 0 }, +}; + ZEND_FRAMELESS_FUNCTION(in_array, 2); ZEND_FRAMELESS_FUNCTION(in_array, 3); static const zend_frameless_function_info frameless_function_infos_in_array[] = { @@ -2332,6 +2344,7 @@ ZEND_FUNCTION(current); ZEND_FUNCTION(key); ZEND_FUNCTION(min); ZEND_FUNCTION(max); +ZEND_FUNCTION(clamp); ZEND_FUNCTION(array_walk); ZEND_FUNCTION(array_walk_recursive); ZEND_FUNCTION(in_array); @@ -2925,6 +2938,7 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(key, arginfo_key) ZEND_RAW_FENTRY("min", zif_min, arginfo_min, ZEND_ACC_COMPILE_TIME_EVAL, frameless_function_infos_min, NULL) ZEND_RAW_FENTRY("max", zif_max, arginfo_max, ZEND_ACC_COMPILE_TIME_EVAL, frameless_function_infos_max, NULL) + ZEND_RAW_FENTRY("clamp", zif_clamp, arginfo_clamp, ZEND_ACC_COMPILE_TIME_EVAL, frameless_function_infos_clamp, NULL) ZEND_FE(array_walk, arginfo_array_walk) ZEND_FE(array_walk_recursive, arginfo_array_walk_recursive) ZEND_RAW_FENTRY("in_array", zif_in_array, arginfo_in_array, ZEND_ACC_COMPILE_TIME_EVAL, frameless_function_infos_in_array, NULL) diff --git a/ext/standard/math.c b/ext/standard/math.c index 142d473864f75..90a62e36cd908 100644 --- a/ext/standard/math.c +++ b/ext/standard/math.c @@ -389,6 +389,59 @@ PHP_FUNCTION(round) } /* }}} */ +/* {{{ Return the given value if in range of min and max */ +PHP_FUNCTION(clamp) +{ + zval *zvalue, *zmin, *zmax; + + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_ZVAL(zvalue) + Z_PARAM_ZVAL(zmin) + Z_PARAM_ZVAL(zmax) + ZEND_PARSE_PARAMETERS_END(); + + if (zend_compare(zmin, zmax) > 0) { + zend_argument_value_error(2, "must be smaller than or equal to argument #3 ($max)"); + RETURN_THROWS(); + } + + if (zend_compare(zmax, zvalue) == -1) { + RETURN_COPY(zmax); + } + + if (zend_compare(zvalue, zmin) == -1) { + RETURN_COPY(zmin); + } + + RETURN_COPY(zvalue); +} +/* }}} */ + +/* {{{ Return the given value if in range of min and max */ +ZEND_FRAMELESS_FUNCTION(clamp, 3) +{ + zval *zvalue, *zmin, *zmax; + Z_FLF_PARAM_ZVAL(1, zvalue); + Z_FLF_PARAM_ZVAL(2, zmin); + Z_FLF_PARAM_ZVAL(3, zmax); + + if (zend_compare(zmin, zmax) > 0) { + zend_argument_value_error(2, "must be smaller than or equal to argument #3 ($max)"); + RETURN_THROWS(); + } + + if (zend_compare(zmax, zvalue) == -1) { + RETURN_COPY_VALUE(zmax); + } + + if (zend_compare(zvalue, zmin) == -1) { + RETURN_COPY_VALUE(zmin); + } + + RETURN_COPY_VALUE(zvalue); +} +/* }}} */ + /* {{{ Returns the sine of the number in radians */ PHP_FUNCTION(sin) { diff --git a/ext/standard/tests/math/clamp.phpt b/ext/standard/tests/math/clamp.phpt new file mode 100644 index 0000000000000..cec0da9ea47b2 --- /dev/null +++ b/ext/standard/tests/math/clamp.phpt @@ -0,0 +1,49 @@ +--TEST-- +clamp() tests +--INI-- +precision=14 +date.timezone = UTC +--FILE-- +format('Y-m-d'), "\n"; +echo clamp(new \DateTimeImmutable('2025-08-20'), new \DateTimeImmutable('2025-08-15'), new \DateTimeImmutable('2025-09-15'))->format('Y-m-d'), "\n"; + +?> +--EXPECT-- +int(2) +int(1) +int(3) +int(2) +float(2.5) +float(2.5) +float(1.3) +float(3.141592653589793) +double(NAN) +int(4) +int(6) +int(7) +int(6) +string(1) "c" +string(1) "d" +2025-08-15 +2025-08-20 +2025-08-15 +2025-08-20 From 86169677c8069f92c9a90ef811f4d9c05639943a Mon Sep 17 00:00:00 2001 From: kylekatarnls Date: Sun, 10 Aug 2025 10:22:18 +0200 Subject: [PATCH 2/6] - Use a common function for normal and frameless implementations - Add tests for null and not-comparable cases - Fix object support for frameless clamp function - Improve NAN handling --- ext/standard/basic_functions_arginfo.h | 2 +- ext/standard/math.c | 59 ++++++++++++----------- ext/standard/tests/math/clamp.phpt | 66 ++++++++++++++++++++++---- 3 files changed, 89 insertions(+), 38 deletions(-) diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h index 39e9131388288..6f202c01463fd 100644 --- a/ext/standard/basic_functions_arginfo.h +++ b/ext/standard/basic_functions_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: f6bf6cdd07080c01d3a0cb08d71409d05b1084f9 */ + * Stub hash: 1a1667a5c59111f096a758d5bb4aa7cf3ec09cfe */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_set_time_limit, 0, 1, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, seconds, IS_LONG, 0) diff --git a/ext/standard/math.c b/ext/standard/math.c index 90a62e36cd908..5852e7d116167 100644 --- a/ext/standard/math.c +++ b/ext/standard/math.c @@ -389,31 +389,47 @@ PHP_FUNCTION(round) } /* }}} */ -/* {{{ Return the given value if in range of min and max */ -PHP_FUNCTION(clamp) +/* Return the given value if in range of min and max */ +static void php_math_clamp(zval *return_value, zval *value, zval *min, zval *max) { - zval *zvalue, *zmin, *zmax; + if (Z_TYPE_P(min) == IS_DOUBLE && UNEXPECTED(zend_isnan(Z_DVAL_P(min)))) { + zend_argument_value_error(2, "cannot be NAN"); + RETURN_THROWS(); + } - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_ZVAL(zvalue) - Z_PARAM_ZVAL(zmin) - Z_PARAM_ZVAL(zmax) - ZEND_PARSE_PARAMETERS_END(); + if (Z_TYPE_P(max) == IS_DOUBLE && UNEXPECTED(zend_isnan(Z_DVAL_P(max)))) { + zend_argument_value_error(3, "cannot be NAN"); + RETURN_THROWS(); + } - if (zend_compare(zmin, zmax) > 0) { + if (zend_compare(max, min) == -1) { zend_argument_value_error(2, "must be smaller than or equal to argument #3 ($max)"); RETURN_THROWS(); } - if (zend_compare(zmax, zvalue) == -1) { - RETURN_COPY(zmax); + if (zend_compare(max, value) == -1) { + RETURN_COPY(max); } - if (zend_compare(zvalue, zmin) == -1) { - RETURN_COPY(zmin); + if (zend_compare(value, min) == -1) { + RETURN_COPY(min); } - RETURN_COPY(zvalue); + RETURN_COPY(value); +} + +/* {{{ Return the given value if in range of min and max */ +PHP_FUNCTION(clamp) +{ + zval *zvalue, *zmin, *zmax; + + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_ZVAL(zvalue) + Z_PARAM_ZVAL(zmin) + Z_PARAM_ZVAL(zmax) + ZEND_PARSE_PARAMETERS_END(); + + php_math_clamp(return_value, zvalue, zmin, zmax); } /* }}} */ @@ -425,20 +441,7 @@ ZEND_FRAMELESS_FUNCTION(clamp, 3) Z_FLF_PARAM_ZVAL(2, zmin); Z_FLF_PARAM_ZVAL(3, zmax); - if (zend_compare(zmin, zmax) > 0) { - zend_argument_value_error(2, "must be smaller than or equal to argument #3 ($max)"); - RETURN_THROWS(); - } - - if (zend_compare(zmax, zvalue) == -1) { - RETURN_COPY_VALUE(zmax); - } - - if (zend_compare(zvalue, zmin) == -1) { - RETURN_COPY_VALUE(zmin); - } - - RETURN_COPY_VALUE(zvalue); + php_math_clamp(return_value, zvalue, zmin, zmax); } /* }}} */ diff --git a/ext/standard/tests/math/clamp.phpt b/ext/standard/tests/math/clamp.phpt index cec0da9ea47b2..c9953708217b0 100644 --- a/ext/standard/tests/math/clamp.phpt +++ b/ext/standard/tests/math/clamp.phpt @@ -15,16 +15,55 @@ var_dump(clamp(2.5, 1.3, 3.4)); var_dump(clamp(0, 1.3, 3.4)); var_dump(clamp(M_PI, -INF, INF)); var_dump(clamp(NAN, 4, 6)); -var_dump(clamp(4, NAN, 6)); -var_dump(clamp(8, NAN, 6)); -var_dump(clamp(7, 6, NAN)); -var_dump(clamp(4, 6, NAN)); var_dump(clamp("a", "c", "g")); var_dump(clamp("d", "c", "g")); echo clamp('2025-08-01', '2025-08-15', '2025-09-15'), "\n"; echo clamp('2025-08-20', '2025-08-15', '2025-09-15'), "\n"; echo clamp(new \DateTimeImmutable('2025-08-01'), new \DateTimeImmutable('2025-08-15'), new \DateTimeImmutable('2025-09-15'))->format('Y-m-d'), "\n"; echo clamp(new \DateTimeImmutable('2025-08-20'), new \DateTimeImmutable('2025-08-15'), new \DateTimeImmutable('2025-09-15'))->format('Y-m-d'), "\n"; +var_dump(clamp(null, -1, 1)); +var_dump(clamp(null, 1, 3)); +var_dump(clamp(null, -3, -1)); +var_dump(clamp(-9999, null, 10)); +var_dump(clamp(12, null, 10)); + +$a = new \InvalidArgumentException('a'); +$b = new \RuntimeException('b'); +$c = new \LogicException('c'); +echo clamp($a, $b, $c)::class, "\n"; +echo clamp($b, $a, $c)::class, "\n"; +echo clamp($c, $a, $b)::class, "\n"; + +try { + var_dump(clamp(4, NAN, 6)); +} catch (ValueError $error) { + echo $error->getMessage(), "\n"; +} + +try { + var_dump(clamp(7, 6, NAN)); +} catch (ValueError $error) { + echo $error->getMessage(), "\n"; +} + +try { + var_dump(clamp(1, 3, 2)); +} catch (ValueError $error) { + echo $error->getMessage(), "\n"; +} + + +try { + var_dump(clamp(-9999, 5, null)); +} catch (ValueError $error) { + echo $error->getMessage(), "\n"; +} + +try { + var_dump(clamp(12, -5, null)); +} catch (ValueError $error) { + echo $error->getMessage(), "\n"; +} ?> --EXPECT-- @@ -36,14 +75,23 @@ float(2.5) float(2.5) float(1.3) float(3.141592653589793) -double(NAN) -int(4) -int(6) -int(7) -int(6) +float(NAN) string(1) "c" string(1) "d" 2025-08-15 2025-08-20 2025-08-15 2025-08-20 +int(-1) +int(1) +int(-3) +int(-9999) +int(10) +InvalidArgumentException +RuntimeException +LogicException +clamp(): Argument #2 ($min) cannot be NAN +clamp(): Argument #3 ($max) cannot be NAN +clamp(): Argument #2 ($min) must be smaller than or equal to argument #3 ($max) +clamp(): Argument #2 ($min) must be smaller than or equal to argument #3 ($max) +clamp(): Argument #2 ($min) must be smaller than or equal to argument #3 ($max) From 2b80f92ab4631fa13db33845f41a72547be2fd1c Mon Sep 17 00:00:00 2001 From: kylekatarnls Date: Fri, 5 Dec 2025 23:04:49 +0100 Subject: [PATCH 3/6] Create tests triggering both frameless and dynamic variants --- ext/standard/tests/math/clamp.phpt | 106 +++++++++++++++-------------- 1 file changed, 56 insertions(+), 50 deletions(-) diff --git a/ext/standard/tests/math/clamp.phpt b/ext/standard/tests/math/clamp.phpt index c9953708217b0..2c5dcfc19a634 100644 --- a/ext/standard/tests/math/clamp.phpt +++ b/ext/standard/tests/math/clamp.phpt @@ -2,68 +2,69 @@ clamp() tests --INI-- precision=14 -date.timezone = UTC +date.timezone=UTC --FILE-- format('Y-m-d'), "\n"; -echo clamp(new \DateTimeImmutable('2025-08-20'), new \DateTimeImmutable('2025-08-15'), new \DateTimeImmutable('2025-09-15'))->format('Y-m-d'), "\n"; -var_dump(clamp(null, -1, 1)); -var_dump(clamp(null, 1, 3)); -var_dump(clamp(null, -3, -1)); -var_dump(clamp(-9999, null, 10)); -var_dump(clamp(12, null, 10)); +function make_clamp_fcc() { + return clamp(...); +} -$a = new \InvalidArgumentException('a'); -$b = new \RuntimeException('b'); -$c = new \LogicException('c'); -echo clamp($a, $b, $c)::class, "\n"; -echo clamp($b, $a, $c)::class, "\n"; -echo clamp($c, $a, $b)::class, "\n"; +function check_clamp_result($value, $min, $max) { + $flf = clamp($value, $min, $max); + $dyn = make_clamp_fcc()($value, $min, $max); + assert($flf === $dyn || (is_nan($flf) && is_nan($dyn))); -try { - var_dump(clamp(4, NAN, 6)); -} catch (ValueError $error) { - echo $error->getMessage(), "\n"; + return $flf; } -try { - var_dump(clamp(7, 6, NAN)); -} catch (ValueError $error) { - echo $error->getMessage(), "\n"; -} +function check_clamp_exception($value, $min, $max) { + try { + var_dump(clamp($value, $min, $max)); + } catch (ValueError $error) { + echo $error->getMessage(), "\n"; + } -try { - var_dump(clamp(1, 3, 2)); -} catch (ValueError $error) { - echo $error->getMessage(), "\n"; + try { + var_dump(make_clamp_fcc()($value, $min, $max)); + } catch (ValueError $error) { + echo $error->getMessage(), "\n"; + } } +var_dump(check_clamp_result(2, 1, 3)); +var_dump(check_clamp_result(0, 1, 3)); +var_dump(check_clamp_result(6, 1, 3)); +var_dump(check_clamp_result(2, 1.3, 3.4)); +var_dump(check_clamp_result(2.5, 1, 3)); +var_dump(check_clamp_result(2.5, 1.3, 3.4)); +var_dump(check_clamp_result(0, 1.3, 3.4)); +var_dump(check_clamp_result(M_PI, -INF, INF)); +var_dump(check_clamp_result(NAN, 4, 6)); +var_dump(check_clamp_result("a", "c", "g")); +var_dump(check_clamp_result("d", "c", "g")); +echo check_clamp_result('2025-08-01', '2025-08-15', '2025-09-15'), "\n"; +echo check_clamp_result('2025-08-20', '2025-08-15', '2025-09-15'), "\n"; +echo check_clamp_result(new \DateTimeImmutable('2025-08-01'), new \DateTimeImmutable('2025-08-15'), new \DateTimeImmutable('2025-09-15'))->format('Y-m-d'), "\n"; +echo check_clamp_result(new \DateTimeImmutable('2025-08-20'), new \DateTimeImmutable('2025-08-15'), new \DateTimeImmutable('2025-09-15'))->format('Y-m-d'), "\n"; +var_dump(check_clamp_result(null, -1, 1)); +var_dump(check_clamp_result(null, 1, 3)); +var_dump(check_clamp_result(null, -3, -1)); +var_dump(check_clamp_result(-9999, null, 10)); +var_dump(check_clamp_result(12, null, 10)); -try { - var_dump(clamp(-9999, 5, null)); -} catch (ValueError $error) { - echo $error->getMessage(), "\n"; -} +$a = new \InvalidArgumentException('a'); +$b = new \RuntimeException('b'); +$c = new \LogicException('c'); +echo check_clamp_result($a, $b, $c)::class, "\n"; +echo check_clamp_result($b, $a, $c)::class, "\n"; +echo check_clamp_result($c, $a, $b)::class, "\n"; -try { - var_dump(clamp(12, -5, null)); -} catch (ValueError $error) { - echo $error->getMessage(), "\n"; -} +check_clamp_exception(4, NAN, 6); +check_clamp_exception(7, 6, NAN); +check_clamp_exception(1, 3, 2); +check_clamp_exception(-9999, 5, null); +check_clamp_exception(12, -5, null); ?> --EXPECT-- @@ -91,7 +92,12 @@ InvalidArgumentException RuntimeException LogicException clamp(): Argument #2 ($min) cannot be NAN +clamp(): Argument #2 ($min) cannot be NAN +clamp(): Argument #3 ($max) cannot be NAN clamp(): Argument #3 ($max) cannot be NAN clamp(): Argument #2 ($min) must be smaller than or equal to argument #3 ($max) clamp(): Argument #2 ($min) must be smaller than or equal to argument #3 ($max) clamp(): Argument #2 ($min) must be smaller than or equal to argument #3 ($max) +clamp(): Argument #2 ($min) must be smaller than or equal to argument #3 ($max) +clamp(): Argument #2 ($min) must be smaller than or equal to argument #3 ($max) +clamp(): Argument #2 ($min) must be smaller than or equal to argument #3 ($max) From f1990e477f038b72b2d0655c5eb29559c32d4b38 Mon Sep 17 00:00:00 2001 From: kylekatarnls Date: Sat, 6 Dec 2025 10:38:08 +0100 Subject: [PATCH 4/6] Add changelog --- NEWS | 1 + UPGRADING | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/NEWS b/NEWS index 1ec90015ef21a..55b8cdddd4eac 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,7 @@ PHP NEWS request. (ilutov) . It is now possible to use reference assign on WeakMap without the key needing to be present beforehand. (ndossche) + . Added `clamp()`. (kylekatarnls, thinkverse) - Hash: . Upgrade xxHash to 0.8.2. (timwolla) diff --git a/UPGRADING b/UPGRADING index 7f0fcaf8943a8..7d13cdddc7b2a 100644 --- a/UPGRADING +++ b/UPGRADING @@ -66,6 +66,10 @@ PHP 8.6 UPGRADE NOTES 6. New Functions ======================================== +- Core: + . `clamp()` returns the given value if in range, else return the nearest bound. + RFC: https://wiki.php.net/rfc/clamp_v2 + ======================================== 7. New Classes and Interfaces ======================================== From a2b5253e83c2fe24ca8874e59cb379a6455891a6 Mon Sep 17 00:00:00 2001 From: kylekatarnls Date: Tue, 9 Dec 2025 16:27:50 +0100 Subject: [PATCH 5/6] [Review] rephrase error messages to use "must not" --- UPGRADING | 2 +- ext/standard/math.c | 4 ++-- ext/standard/tests/math/clamp.phpt | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/UPGRADING b/UPGRADING index 7d13cdddc7b2a..9b2b90c793507 100644 --- a/UPGRADING +++ b/UPGRADING @@ -66,7 +66,7 @@ PHP 8.6 UPGRADE NOTES 6. New Functions ======================================== -- Core: +- Standard: . `clamp()` returns the given value if in range, else return the nearest bound. RFC: https://wiki.php.net/rfc/clamp_v2 diff --git a/ext/standard/math.c b/ext/standard/math.c index 5852e7d116167..95384c06588ac 100644 --- a/ext/standard/math.c +++ b/ext/standard/math.c @@ -393,12 +393,12 @@ PHP_FUNCTION(round) static void php_math_clamp(zval *return_value, zval *value, zval *min, zval *max) { if (Z_TYPE_P(min) == IS_DOUBLE && UNEXPECTED(zend_isnan(Z_DVAL_P(min)))) { - zend_argument_value_error(2, "cannot be NAN"); + zend_argument_value_error(2, "must not be NAN"); RETURN_THROWS(); } if (Z_TYPE_P(max) == IS_DOUBLE && UNEXPECTED(zend_isnan(Z_DVAL_P(max)))) { - zend_argument_value_error(3, "cannot be NAN"); + zend_argument_value_error(3, "must not be NAN"); RETURN_THROWS(); } diff --git a/ext/standard/tests/math/clamp.phpt b/ext/standard/tests/math/clamp.phpt index 2c5dcfc19a634..58c6a176cf3df 100644 --- a/ext/standard/tests/math/clamp.phpt +++ b/ext/standard/tests/math/clamp.phpt @@ -91,10 +91,10 @@ int(10) InvalidArgumentException RuntimeException LogicException -clamp(): Argument #2 ($min) cannot be NAN -clamp(): Argument #2 ($min) cannot be NAN -clamp(): Argument #3 ($max) cannot be NAN -clamp(): Argument #3 ($max) cannot be NAN +clamp(): Argument #2 ($min) must not be NAN +clamp(): Argument #2 ($min) must not be NAN +clamp(): Argument #3 ($max) must not be NAN +clamp(): Argument #3 ($max) must not be NAN clamp(): Argument #2 ($min) must be smaller than or equal to argument #3 ($max) clamp(): Argument #2 ($min) must be smaller than or equal to argument #3 ($max) clamp(): Argument #2 ($min) must be smaller than or equal to argument #3 ($max) From b8f125c6085b29bf3ad259009015b1c6817d6960 Mon Sep 17 00:00:00 2001 From: Kyle Date: Thu, 11 Dec 2025 10:56:06 +0100 Subject: [PATCH 6/6] Enable assert() --- ext/standard/tests/math/clamp.phpt | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/standard/tests/math/clamp.phpt b/ext/standard/tests/math/clamp.phpt index 58c6a176cf3df..beb4c8d53148d 100644 --- a/ext/standard/tests/math/clamp.phpt +++ b/ext/standard/tests/math/clamp.phpt @@ -3,6 +3,7 @@ clamp() tests --INI-- precision=14 date.timezone=UTC +zend.assertions=1 --FILE--