@@ -410,13 +410,15 @@ PHP_FUNCTION(clamp)
410410 RETURN_THROWS ();
411411 }
412412
413- if (zend_compare (zmin , zmax ) > 0 ) {
414- zend_argument_value_error (2 , "must be smaller than or equal to argument #3 ($max)" );
415- RETURN_THROWS ();
416- }
413+ if (Z_TYPE_P (zmax ) != IS_NULL ) {
414+ if (zend_compare (zmin , zmax ) > 0 ) {
415+ zend_argument_value_error (2 , "must be smaller than or equal to argument #3 ($max)" );
416+ RETURN_THROWS ();
417+ }
417418
418- if (zend_compare (zmax , zvalue ) == -1 ) {
419- RETURN_COPY (zmax );
419+ if (zend_compare (zmax , zvalue ) == -1 ) {
420+ RETURN_COPY (zmax );
421+ }
420422 }
421423
422424 if (zend_compare (zvalue , zmin ) == -1 ) {
@@ -445,13 +447,15 @@ ZEND_FRAMELESS_FUNCTION(clamp, 3)
445447 RETURN_THROWS ();
446448 }
447449
448- if (zend_compare (zmin , zmax ) > 0 ) {
449- zend_argument_value_error (2 , "must be smaller than or equal to argument #3 ($max)" );
450- RETURN_THROWS ();
451- }
450+ if (Z_TYPE_P (zmax ) != IS_NULL ) {
451+ if (zend_compare (zmin , zmax ) > 0 ) {
452+ zend_argument_value_error (2 , "must be smaller than or equal to argument #3 ($max)" );
453+ RETURN_THROWS ();
454+ }
452455
453- if (zend_compare (zmax , zvalue ) == -1 ) {
454- RETURN_COPY (zmax );
456+ if (zend_compare (zmax , zvalue ) == -1 ) {
457+ RETURN_COPY (zmax );
458+ }
455459 }
456460
457461 if (zend_compare (zvalue , zmin ) == -1 ) {
0 commit comments