From 8e8a8c12592a9ab2508b8adbd0b5c055c39833e7 Mon Sep 17 00:00:00 2001 From: Sjoerd Langkemper Date: Fri, 16 Oct 2026 12:06:14 +0000 Subject: [PATCH] ext/standard: throw exception for invalid characters for number base This is about the situation where a character is not within the specified number base. E.g. only 0-9, a-f are allowed for hexadecimal, so what should `hexdec('z')` do? In the past, such characters were silently ignored. Since PHP 7.4 a deprecation notice would be generated. This commit changes that to a Exception. RFC: https://wiki.php.net/rfc/throw_error_for_invalid_characters_for_number_base --- NEWS | 3 + UPGRADING | 3 + ext/standard/math.c | 25 +- ext/standard/php_math.h | 2 +- .../tests/math/base_convert_basic.phpt | 330 +++++------------- .../tests/math/base_convert_improvements.phpt | 61 +++- .../tests/math/base_convert_variation1.phpt | 36 +- ext/standard/tests/math/bindec_basic.phpt | 52 +-- .../tests/math/bindec_basic_64bit.phpt | 54 +-- .../tests/math/bindec_variation1.phpt | 48 +-- .../tests/math/bindec_variation1_64bit.phpt | 40 +-- ext/standard/tests/math/hexdec.phpt | 41 ++- ext/standard/tests/math/hexdec_basic.phpt | 16 +- .../tests/math/hexdec_basic_64bit.phpt | 14 +- .../tests/math/hexdec_variation1.phpt | 42 +-- .../tests/math/hexdec_variation1_64bit.phpt | 32 +- ext/standard/tests/math/octdec_basic.phpt | 31 +- .../tests/math/octdec_basic_64bit.phpt | 34 +- .../tests/math/octdec_variation1.phpt | 44 +-- 19 files changed, 322 insertions(+), 586 deletions(-) diff --git a/NEWS b/NEWS index 67c44a4420e9..50f13cbb1e69 100644 --- a/NEWS +++ b/NEWS @@ -145,6 +145,9 @@ PHP NEWS especially UTF-8. (Nicolas Grekas) . Improved performance of htmlspecialchars() when nothing needs encoding. (Nicolas Grekas) + . bindec(), octdec(), hexdec() and base_convert() now throw an Exception + when the passed string contains characters that are invalid for the + specified number base. (Sjoerd Langkemper) - URI: . Fix casing of enum cases in UriHostType and UrlHostType to match the RFC diff --git a/UPGRADING b/UPGRADING index fd3efda9df7a..f3177ec69a9d 100644 --- a/UPGRADING +++ b/UPGRADING @@ -37,6 +37,9 @@ PHP 8.7 UPGRADE NOTES application terminate one attribute and append further ones. - Standard: + . bindec(), octdec(), hexdec() and base_convert() now throw an Exception + when the passed string contains characters that are invalid for the + specified number base. . The number of filters that can be chained in a php://filter URL is limited to 16 by default. Set the stream context option max_filter_count to change this. diff --git a/ext/standard/math.c b/ext/standard/math.c index 20286870c7c9..8ec427ce00a9 100644 --- a/ext/standard/math.c +++ b/ext/standard/math.c @@ -850,7 +850,7 @@ PHPAPI zend_long _php_math_basetolong(zval *arg, int base) /* * Convert a string representation of a base(2-36) number to a zval. */ -PHPAPI void _php_math_basetozval(zend_string *str, int base, zval *ret) +PHPAPI zend_result _php_math_basetozval(zend_string *str, int base, zval *ret) { zend_long num = 0; double fnum = 0; @@ -903,7 +903,6 @@ PHPAPI void _php_math_basetozval(zend_string *str, int base, zval *ret) num = num * base + c; break; } else { - zend_error(E_NOTICE, "Input number is larger than PHP_INT_MAX, precision has been lost in conversion"); fnum = (double)num; mode = 1; } @@ -914,14 +913,17 @@ PHPAPI void _php_math_basetozval(zend_string *str, int base, zval *ret) } if (invalidchars > 0) { - zend_error(E_DEPRECATED, "Invalid characters passed for attempted conversion, these have been ignored"); + zend_throw_exception_ex(NULL, 0, "Invalid characters passed for attempted conversion"); + return FAILURE; } if (mode == 1) { + zend_error(E_NOTICE, "Input number is larger than PHP_INT_MAX, precision has been lost in conversion"); ZVAL_DOUBLE(ret, fnum); } else { ZVAL_LONG(ret, num); } + return SUCCESS; } /* }}} */ @@ -1039,7 +1041,9 @@ PHP_FUNCTION(bindec) Z_PARAM_STR(arg) ZEND_PARSE_PARAMETERS_END(); - _php_math_basetozval(arg, 2, return_value); + if (SUCCESS != _php_math_basetozval(arg, 2, return_value)) { + RETURN_THROWS(); + } } /* }}} */ @@ -1052,7 +1056,9 @@ PHP_FUNCTION(hexdec) Z_PARAM_STR(arg) ZEND_PARSE_PARAMETERS_END(); - _php_math_basetozval(arg, 16, return_value); + if (SUCCESS != _php_math_basetozval(arg, 16, return_value)) { + RETURN_THROWS(); + } } /* }}} */ @@ -1065,7 +1071,9 @@ PHP_FUNCTION(octdec) Z_PARAM_STR(arg) ZEND_PARSE_PARAMETERS_END(); - _php_math_basetozval(arg, 8, return_value); + if (SUCCESS != _php_math_basetozval(arg, 8, return_value)) { + RETURN_THROWS(); + } } /* }}} */ @@ -1142,7 +1150,10 @@ PHP_FUNCTION(base_convert) RETURN_THROWS(); } - _php_math_basetozval(number, (int)frombase, &temp); + if (SUCCESS != _php_math_basetozval(number, (int)frombase, &temp)) { + RETURN_THROWS(); + } + result = _php_math_zvaltobase(&temp, (int)tobase); if (!result) { RETURN_THROWS(); diff --git a/ext/standard/php_math.h b/ext/standard/php_math.h index cb0b9db21599..7988c72a3853 100644 --- a/ext/standard/php_math.h +++ b/ext/standard/php_math.h @@ -22,7 +22,7 @@ PHPAPI zend_string *_php_math_number_format_ex(double d, int dec, const char *de PHPAPI zend_string *_php_math_number_format_long(zend_long num, zend_long dec, const char *dec_point, size_t dec_point_len, const char *thousand_sep, size_t thousand_sep_len); PHPAPI zend_string * _php_math_longtobase(zend_long arg, int base); PHPAPI zend_long _php_math_basetolong(zval *arg, int base); -PHPAPI void _php_math_basetozval(zend_string *str, int base, zval *ret); +PHPAPI zend_result _php_math_basetozval(zend_string *str, int base, zval *ret); PHPAPI zend_string * _php_math_zvaltobase(zval *arg, int base); #include diff --git a/ext/standard/tests/math/base_convert_basic.phpt b/ext/standard/tests/math/base_convert_basic.phpt index bdef339f3b37..2e2ca5684335 100644 --- a/ext/standard/tests/math/base_convert_basic.phpt +++ b/ext/standard/tests/math/base_convert_basic.phpt @@ -22,256 +22,130 @@ for ($f= 0; $f < count($frombase); $f++) { for ($t= 0; $t < count($tobase); $t++) { echo "......to base is ", $tobase[$t], "\n"; for ($i =0; $i < count($values); $i++){ - $res = base_convert($values[$i],$frombase[$f],$tobase[$t]); - echo ".........value= ", $values[$i], " res = ", $res, "\n"; + try { + $res = base_convert($values[$i],$frombase[$f],$tobase[$t]); + echo ".........value= ", $values[$i], " res = ", $res, "\n"; + } catch (Exception $e) { + echo "E........exc= ", $e::class, ': ', $e->getMessage(), "\n"; + } } } } ?> ---EXPECTF-- +--EXPECT-- ...from base is 2 ......to base is 2 .........value= 10 res = 10 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 27 res = 0 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 39 res = 0 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 3 res = 0 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 95 res = 0 +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion .........value= 10 res = 10 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 27 res = 0 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 39 res = 0 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 5F res = 0 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 3XYZ res = 0 +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion ......to base is 8 .........value= 10 res = 2 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 27 res = 0 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 39 res = 0 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 3 res = 0 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 95 res = 0 +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion .........value= 10 res = 2 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 27 res = 0 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 39 res = 0 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 5F res = 0 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 3XYZ res = 0 +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion ......to base is 10 .........value= 10 res = 2 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 27 res = 0 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 39 res = 0 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 3 res = 0 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 95 res = 0 +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion .........value= 10 res = 2 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 27 res = 0 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 39 res = 0 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 5F res = 0 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 3XYZ res = 0 +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion ......to base is 16 .........value= 10 res = 2 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 27 res = 0 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 39 res = 0 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 3 res = 0 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 95 res = 0 +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion .........value= 10 res = 2 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 27 res = 0 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 39 res = 0 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 5F res = 0 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 3XYZ res = 0 +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion ......to base is 36 .........value= 10 res = 2 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 27 res = 0 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 39 res = 0 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 3 res = 0 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 95 res = 0 +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion .........value= 10 res = 2 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 27 res = 0 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 39 res = 0 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 5F res = 0 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 3XYZ res = 0 +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion ...from base is 8 ......to base is 2 .........value= 10 res = 1000 .........value= 27 res = 10111 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 39 res = 11 +E........exc= Exception: Invalid characters passed for attempted conversion .........value= 3 res = 11 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 95 res = 101 +E........exc= Exception: Invalid characters passed for attempted conversion .........value= 10 res = 1000 .........value= 27 res = 10111 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 39 res = 11 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 5F res = 101 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 3XYZ res = 11 +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion ......to base is 8 .........value= 10 res = 10 .........value= 27 res = 27 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 39 res = 3 +E........exc= Exception: Invalid characters passed for attempted conversion .........value= 3 res = 3 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 95 res = 5 +E........exc= Exception: Invalid characters passed for attempted conversion .........value= 10 res = 10 .........value= 27 res = 27 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 39 res = 3 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 5F res = 5 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 3XYZ res = 3 +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion ......to base is 10 .........value= 10 res = 8 .........value= 27 res = 23 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 39 res = 3 +E........exc= Exception: Invalid characters passed for attempted conversion .........value= 3 res = 3 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 95 res = 5 +E........exc= Exception: Invalid characters passed for attempted conversion .........value= 10 res = 8 .........value= 27 res = 23 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 39 res = 3 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 5F res = 5 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 3XYZ res = 3 +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion ......to base is 16 .........value= 10 res = 8 .........value= 27 res = 17 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 39 res = 3 +E........exc= Exception: Invalid characters passed for attempted conversion .........value= 3 res = 3 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 95 res = 5 +E........exc= Exception: Invalid characters passed for attempted conversion .........value= 10 res = 8 .........value= 27 res = 17 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 39 res = 3 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 5F res = 5 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 3XYZ res = 3 +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion ......to base is 36 .........value= 10 res = 8 .........value= 27 res = n - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 39 res = 3 +E........exc= Exception: Invalid characters passed for attempted conversion .........value= 3 res = 3 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 95 res = 5 +E........exc= Exception: Invalid characters passed for attempted conversion .........value= 10 res = 8 .........value= 27 res = n - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 39 res = 3 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 5F res = 5 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 3XYZ res = 3 +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion ...from base is 10 ......to base is 2 @@ -283,12 +157,8 @@ Deprecated: Invalid characters passed for attempted conversion, these have been .........value= 10 res = 1010 .........value= 27 res = 11011 .........value= 39 res = 100111 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 5F res = 101 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 3XYZ res = 11 +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion ......to base is 8 .........value= 10 res = 12 .........value= 27 res = 33 @@ -298,12 +168,8 @@ Deprecated: Invalid characters passed for attempted conversion, these have been .........value= 10 res = 12 .........value= 27 res = 33 .........value= 39 res = 47 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 5F res = 5 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 3XYZ res = 3 +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion ......to base is 10 .........value= 10 res = 10 .........value= 27 res = 27 @@ -313,12 +179,8 @@ Deprecated: Invalid characters passed for attempted conversion, these have been .........value= 10 res = 10 .........value= 27 res = 27 .........value= 39 res = 39 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 5F res = 5 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 3XYZ res = 3 +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion ......to base is 16 .........value= 10 res = a .........value= 27 res = 1b @@ -328,12 +190,8 @@ Deprecated: Invalid characters passed for attempted conversion, these have been .........value= 10 res = a .........value= 27 res = 1b .........value= 39 res = 27 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 5F res = 5 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 3XYZ res = 3 +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion ......to base is 36 .........value= 10 res = a .........value= 27 res = r @@ -343,12 +201,8 @@ Deprecated: Invalid characters passed for attempted conversion, these have been .........value= 10 res = a .........value= 27 res = r .........value= 39 res = 13 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 5F res = 5 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 3XYZ res = 3 +E........exc= Exception: Invalid characters passed for attempted conversion +E........exc= Exception: Invalid characters passed for attempted conversion ...from base is 16 ......to base is 2 @@ -361,9 +215,7 @@ Deprecated: Invalid characters passed for attempted conversion, these have been .........value= 27 res = 100111 .........value= 39 res = 111001 .........value= 5F res = 1011111 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 3XYZ res = 11 +E........exc= Exception: Invalid characters passed for attempted conversion ......to base is 8 .........value= 10 res = 20 .........value= 27 res = 47 @@ -374,9 +226,7 @@ Deprecated: Invalid characters passed for attempted conversion, these have been .........value= 27 res = 47 .........value= 39 res = 71 .........value= 5F res = 137 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 3XYZ res = 3 +E........exc= Exception: Invalid characters passed for attempted conversion ......to base is 10 .........value= 10 res = 16 .........value= 27 res = 39 @@ -387,9 +237,7 @@ Deprecated: Invalid characters passed for attempted conversion, these have been .........value= 27 res = 39 .........value= 39 res = 57 .........value= 5F res = 95 - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 3XYZ res = 3 +E........exc= Exception: Invalid characters passed for attempted conversion ......to base is 16 .........value= 10 res = 10 .........value= 27 res = 27 @@ -400,9 +248,7 @@ Deprecated: Invalid characters passed for attempted conversion, these have been .........value= 27 res = 27 .........value= 39 res = 39 .........value= 5F res = 5f - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 3XYZ res = 3 +E........exc= Exception: Invalid characters passed for attempted conversion ......to base is 36 .........value= 10 res = g .........value= 27 res = 13 @@ -413,9 +259,7 @@ Deprecated: Invalid characters passed for attempted conversion, these have been .........value= 27 res = 13 .........value= 39 res = 1l .........value= 5F res = 2n - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -.........value= 3XYZ res = 3 +E........exc= Exception: Invalid characters passed for attempted conversion ...from base is 36 ......to base is 2 diff --git a/ext/standard/tests/math/base_convert_improvements.phpt b/ext/standard/tests/math/base_convert_improvements.phpt index eccf98853cfc..e49a1836aca3 100644 --- a/ext/standard/tests/math/base_convert_improvements.phpt +++ b/ext/standard/tests/math/base_convert_improvements.phpt @@ -12,15 +12,44 @@ echo base_convert("\r\nFF\t\n" , 16, 10) . "\n"; echo base_convert("0o7" , 8, 10) . "\n"; echo base_convert("0b1010" , 2, 10) . "\n"; -echo "======================================="; +echo "=======================================\n"; // These should fail -echo base_convert('fg', 16, 10); -echo base_convert('f 0xff ', 16, 10); -echo base_convert('1xff ', 16, 10); -echo base_convert(chr(0), 16, 10); -echo base_convert("0o7" , 9, 10); -echo base_convert("0 0" , 9, 10) . "\n"; +try { + echo base_convert('fg', 16, 10); +} catch (Exception $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; +} + +try { + echo base_convert('f 0xff ', 16, 10); +} catch (Exception $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; +} + +try { + echo base_convert('1xff ', 16, 10); +} catch (Exception $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; +} + +try { + echo base_convert(chr(0), 16, 10); +} catch (Exception $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; +} + +try { + echo base_convert("0o7" , 9, 10); +} catch (Exception $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; +} + +try { + echo base_convert("0 0" , 9, 10) . "\n"; +} catch (Exception $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; +} ?> --EXPECTF-- 255 @@ -33,15 +62,9 @@ echo base_convert("0 0" , 9, 10) . "\n"; 7 10 ======================================= -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -15 -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -61695 -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -511 -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -0 -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -7 -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -0 +Exception: Invalid characters passed for attempted conversion +Exception: Invalid characters passed for attempted conversion +Exception: Invalid characters passed for attempted conversion +Exception: Invalid characters passed for attempted conversion +Exception: Invalid characters passed for attempted conversion +Exception: Invalid characters passed for attempted conversion diff --git a/ext/standard/tests/math/base_convert_variation1.phpt b/ext/standard/tests/math/base_convert_variation1.phpt index f4b00e9293d0..bcc18bfa2c04 100644 --- a/ext/standard/tests/math/base_convert_variation1.phpt +++ b/ext/standard/tests/math/base_convert_variation1.phpt @@ -74,37 +74,25 @@ string(1) "1" string(2) "14" -- Iteration 4 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -string(2) "14" +Exception: Invalid characters passed for attempted conversion -- Iteration 5 -- string(11) "17777777777" -- Iteration 6 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -string(3) "151" +Exception: Invalid characters passed for attempted conversion -- Iteration 7 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -string(3) "151" +Exception: Invalid characters passed for attempted conversion -- Iteration 8 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -string(7) "4553207" +Exception: Invalid characters passed for attempted conversion -- Iteration 9 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -string(7) "4553207" +Exception: Invalid characters passed for attempted conversion -- Iteration 10 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -string(1) "5" +Exception: Invalid characters passed for attempted conversion -- Iteration 11 -- string(1) "1" @@ -128,19 +116,13 @@ string(1) "0" TypeError: base_convert(): Argument #1 ($num) must be of type string, array given -- Iteration 18 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -string(1) "0" +Exception: Invalid characters passed for attempted conversion -- Iteration 19 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -string(1) "0" +Exception: Invalid characters passed for attempted conversion -- Iteration 20 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -string(1) "0" +Exception: Invalid characters passed for attempted conversion -- Iteration 21 -- TypeError: base_convert(): Argument #1 ($num) must be of type string, resource given diff --git a/ext/standard/tests/math/bindec_basic.phpt b/ext/standard/tests/math/bindec_basic.phpt index d1197ed1645c..47c6453dec5f 100644 --- a/ext/standard/tests/math/bindec_basic.phpt +++ b/ext/standard/tests/math/bindec_basic.phpt @@ -29,50 +29,32 @@ $values = array(111000111, ); for ($i = 0; $i < count($values); $i++) { - $res = bindec($values[$i]); - var_dump($res); + try { + $res = bindec($values[$i]); + var_dump($res); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; + } } ?> --EXPECTF-- int(455) - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(0) - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(32766) - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(5) - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(129) +Exception: Invalid characters passed for attempted conversion +Exception: Invalid characters passed for attempted conversion +Exception: Invalid characters passed for attempted conversion +Exception: Invalid characters passed for attempted conversion int(455) int(224) int(2147483647) Notice: Input number is larger than PHP_INT_MAX, precision has been lost in conversion in %s on line %d float(2147483648) - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(129) - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(0) - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(13) - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(13) - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(26) - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(6) - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(0) +Exception: Invalid characters passed for attempted conversion +Exception: Invalid characters passed for attempted conversion +Exception: Invalid characters passed for attempted conversion +Exception: Invalid characters passed for attempted conversion +Exception: Invalid characters passed for attempted conversion +Exception: Invalid characters passed for attempted conversion +Exception: Invalid characters passed for attempted conversion int(1) int(0) diff --git a/ext/standard/tests/math/bindec_basic_64bit.phpt b/ext/standard/tests/math/bindec_basic_64bit.phpt index 8fece221c0ed..7bbab6f85ff2 100644 --- a/ext/standard/tests/math/bindec_basic_64bit.phpt +++ b/ext/standard/tests/math/bindec_basic_64bit.phpt @@ -29,48 +29,30 @@ $values = array(111000111, ); for ($i = 0; $i < count($values); $i++) { - $res = bindec($values[$i]); - var_dump($res); + try { + $res = bindec($values[$i]); + var_dump($res); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; + } } ?> ---EXPECTF-- +--EXPECT-- int(455) - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(0) - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(32766) - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(5) - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(129) +Exception: Invalid characters passed for attempted conversion +Exception: Invalid characters passed for attempted conversion +Exception: Invalid characters passed for attempted conversion +Exception: Invalid characters passed for attempted conversion int(455) int(224) int(2147483647) int(2147483648) - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(129) - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(0) - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(13) - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(13) - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(26) - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(6) - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(0) +Exception: Invalid characters passed for attempted conversion +Exception: Invalid characters passed for attempted conversion +Exception: Invalid characters passed for attempted conversion +Exception: Invalid characters passed for attempted conversion +Exception: Invalid characters passed for attempted conversion +Exception: Invalid characters passed for attempted conversion +Exception: Invalid characters passed for attempted conversion int(1) int(0) diff --git a/ext/standard/tests/math/bindec_variation1.phpt b/ext/standard/tests/math/bindec_variation1.phpt index 420ceeed7a6a..1ce32f066536 100644 --- a/ext/standard/tests/math/bindec_variation1.phpt +++ b/ext/standard/tests/math/bindec_variation1.phpt @@ -57,8 +57,8 @@ foreach($inputs as $input) { echo "\n-- Iteration $iterator --\n"; try { var_dump(bindec($input)); - } catch (TypeError $e) { - echo $e->getMessage(), "\n"; + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } $iterator++; }; @@ -74,39 +74,25 @@ int(0) int(1) -- Iteration 3 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(1) +Exception: Invalid characters passed for attempted conversion -- Iteration 4 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(0) +Exception: Invalid characters passed for attempted conversion -- Iteration 5 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(2) +Exception: Invalid characters passed for attempted conversion -- Iteration 6 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(2) +Exception: Invalid characters passed for attempted conversion -- Iteration 7 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(8) +Exception: Invalid characters passed for attempted conversion -- Iteration 8 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(1) +Exception: Invalid characters passed for attempted conversion -- Iteration 9 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(0) +Exception: Invalid characters passed for attempted conversion -- Iteration 10 -- int(1) @@ -127,22 +113,16 @@ int(0) int(0) -- Iteration 16 -- -bindec(): Argument #1 ($binary_string) must be of type string, array given +TypeError: bindec(): Argument #1 ($binary_string) must be of type string, array given -- Iteration 17 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(0) +Exception: Invalid characters passed for attempted conversion -- Iteration 18 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(0) +Exception: Invalid characters passed for attempted conversion -- Iteration 19 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(0) +Exception: Invalid characters passed for attempted conversion -- Iteration 20 -- -bindec(): Argument #1 ($binary_string) must be of type string, resource given +TypeError: bindec(): Argument #1 ($binary_string) must be of type string, resource given diff --git a/ext/standard/tests/math/bindec_variation1_64bit.phpt b/ext/standard/tests/math/bindec_variation1_64bit.phpt index 25f2ec9c7db0..746cc12503ea 100644 --- a/ext/standard/tests/math/bindec_variation1_64bit.phpt +++ b/ext/standard/tests/math/bindec_variation1_64bit.phpt @@ -74,39 +74,25 @@ int(0) int(1) -- Iteration 3 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(1) +Exception: Invalid characters passed for attempted conversion -- Iteration 4 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(0) +Exception: Invalid characters passed for attempted conversion -- Iteration 5 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(2) +Exception: Invalid characters passed for attempted conversion -- Iteration 6 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(2) +Exception: Invalid characters passed for attempted conversion -- Iteration 7 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(8) +Exception: Invalid characters passed for attempted conversion -- Iteration 8 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(1) +Exception: Invalid characters passed for attempted conversion -- Iteration 9 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(0) +Exception: Invalid characters passed for attempted conversion -- Iteration 10 -- int(1) @@ -130,19 +116,13 @@ int(0) TypeError: bindec(): Argument #1 ($binary_string) must be of type string, array given -- Iteration 17 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(0) +Exception: Invalid characters passed for attempted conversion -- Iteration 18 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(0) +Exception: Invalid characters passed for attempted conversion -- Iteration 19 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(0) +Exception: Invalid characters passed for attempted conversion -- Iteration 20 -- TypeError: bindec(): Argument #1 ($binary_string) must be of type string, resource given diff --git a/ext/standard/tests/math/hexdec.phpt b/ext/standard/tests/math/hexdec.phpt index 1f8b57d83fd0..7bc8c833515b 100644 --- a/ext/standard/tests/math/hexdec.phpt +++ b/ext/standard/tests/math/hexdec.phpt @@ -7,9 +7,31 @@ precision=14 var_dump(hexdec("012345")); var_dump(hexdec("12345")); -var_dump(hexdec("q12345")); -var_dump(hexdec("12345+?!")); -var_dump(hexdec("12345q")); + +try { + var_dump(hexdec("q12345")); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; +} + +try { + var_dump(hexdec("12345+?!")); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; +} + +try { + var_dump(hexdec("12345q")); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; +} + +try { + var_dump(hexdec("11111111111111111z")); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; +} + var_dump(hexdec("12345678901234567")); var_dump(hexdec("17fffffffffffffff")); @@ -17,15 +39,10 @@ var_dump(hexdec("17fffffffffffffff")); --EXPECTF-- int(74565) int(74565) - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(74565) - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(74565) - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(74565) +Exception: Invalid characters passed for attempted conversion +Exception: Invalid characters passed for attempted conversion +Exception: Invalid characters passed for attempted conversion +Exception: Invalid characters passed for attempted conversion Notice: Input number is larger than PHP_INT_MAX, precision has been lost in conversion in %s on line %d float(2.0988295476557332E+19) diff --git a/ext/standard/tests/math/hexdec_basic.phpt b/ext/standard/tests/math/hexdec_basic.phpt index f1fd76778bfd..f518b74ad860 100644 --- a/ext/standard/tests/math/hexdec_basic.phpt +++ b/ext/standard/tests/math/hexdec_basic.phpt @@ -25,8 +25,12 @@ $values = array(0x123abc, false, ); for ($i = 0; $i < count($values); $i++) { - $res = hexdec($values[$i]); - var_dump($res); + try { + $res = hexdec($values[$i]); + var_dump($res); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; + } } ?> --EXPECTF-- @@ -44,14 +48,10 @@ int(2147483647) Notice: Input number is larger than PHP_INT_MAX, precision has been lost in conversion in %s on line %d float(2147483648) - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(1194684) +Exception: Invalid characters passed for attempted conversion int(3215381) int(3215381) - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(3215379) +Exception: Invalid characters passed for attempted conversion int(51446064) int(18279) int(70199) diff --git a/ext/standard/tests/math/hexdec_basic_64bit.phpt b/ext/standard/tests/math/hexdec_basic_64bit.phpt index fd6d53b60198..e011bce1c2af 100644 --- a/ext/standard/tests/math/hexdec_basic_64bit.phpt +++ b/ext/standard/tests/math/hexdec_basic_64bit.phpt @@ -29,7 +29,11 @@ $values = array(0x123abc, foreach($values as $value) { echo "\n-- hexdec $value --\n"; - var_dump(hexdec($value)); + try { + var_dump(hexdec($value)); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; + } }; ?> @@ -61,9 +65,7 @@ int(2147483647) int(2147483648) -- hexdec 0x123XYZABC -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(1194684) +Exception: Invalid characters passed for attempted conversion -- hexdec 311015 -- int(3215381) @@ -72,9 +74,7 @@ int(3215381) int(3215381) -- hexdec 31101.3 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(3215379) +Exception: Invalid characters passed for attempted conversion -- hexdec 3110130 -- int(51446064) diff --git a/ext/standard/tests/math/hexdec_variation1.phpt b/ext/standard/tests/math/hexdec_variation1.phpt index cf0d4e81411c..da22d403a18c 100644 --- a/ext/standard/tests/math/hexdec_variation1.phpt +++ b/ext/standard/tests/math/hexdec_variation1.phpt @@ -61,8 +61,8 @@ foreach($inputs as $input) { echo "\n-- Iteration $iterator --\n"; try { var_dump(hexdec($input)); - } catch (TypeError $e) { - echo $e->getMessage(), "\n"; + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; } $iterator++; }; @@ -81,9 +81,7 @@ int(1) int(74565) -- Iteration 4 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(9029) +Exception: Invalid characters passed for attempted conversion -- Iteration 5 -- @@ -96,14 +94,10 @@ Notice: Input number is larger than PHP_INT_MAX, precision has been lost in conv float(285960729238) -- Iteration 7 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(261) +Exception: Invalid characters passed for attempted conversion -- Iteration 8 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(261) +Exception: Invalid characters passed for attempted conversion -- Iteration 9 -- @@ -111,16 +105,10 @@ Notice: Input number is larger than PHP_INT_MAX, precision has been lost in conv float(20015998341120) -- Iteration 10 -- - -Notice: Input number is larger than PHP_INT_MAX, precision has been lost in conversion in %s on line %d - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -float(1250999896553) +Exception: Invalid characters passed for attempted conversion -- Iteration 11 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(5) +Exception: Invalid characters passed for attempted conversion -- Iteration 12 -- int(1) @@ -141,22 +129,16 @@ int(0) int(0) -- Iteration 18 -- -hexdec(): Argument #1 ($hex_string) must be of type string, array given +TypeError: hexdec(): Argument #1 ($hex_string) must be of type string, array given -- Iteration 19 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(2748) +Exception: Invalid characters passed for attempted conversion -- Iteration 20 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(2748) +Exception: Invalid characters passed for attempted conversion -- Iteration 21 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(2748) +Exception: Invalid characters passed for attempted conversion -- Iteration 22 -- -hexdec(): Argument #1 ($hex_string) must be of type string, resource given +TypeError: hexdec(): Argument #1 ($hex_string) must be of type string, resource given diff --git a/ext/standard/tests/math/hexdec_variation1_64bit.phpt b/ext/standard/tests/math/hexdec_variation1_64bit.phpt index c4c2a716d3f6..70d89ba69eb1 100644 --- a/ext/standard/tests/math/hexdec_variation1_64bit.phpt +++ b/ext/standard/tests/math/hexdec_variation1_64bit.phpt @@ -81,9 +81,7 @@ int(1) int(74565) -- Iteration 4 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(9029) +Exception: Invalid characters passed for attempted conversion -- Iteration 5 -- int(285960729237) @@ -92,27 +90,19 @@ int(285960729237) int(285960729238) -- Iteration 7 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(261) +Exception: Invalid characters passed for attempted conversion -- Iteration 8 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(261) +Exception: Invalid characters passed for attempted conversion -- Iteration 9 -- int(20015998341120) -- Iteration 10 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(1250999896553) +Exception: Invalid characters passed for attempted conversion -- Iteration 11 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(5) +Exception: Invalid characters passed for attempted conversion -- Iteration 12 -- int(1) @@ -136,19 +126,13 @@ int(0) TypeError: hexdec(): Argument #1 ($hex_string) must be of type string, array given -- Iteration 19 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(2748) +Exception: Invalid characters passed for attempted conversion -- Iteration 20 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(2748) +Exception: Invalid characters passed for attempted conversion -- Iteration 21 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(2748) +Exception: Invalid characters passed for attempted conversion -- Iteration 22 -- TypeError: hexdec(): Argument #1 ($hex_string) must be of type string, resource given diff --git a/ext/standard/tests/math/octdec_basic.phpt b/ext/standard/tests/math/octdec_basic.phpt index 935cb23e1d35..e2414e7f509f 100644 --- a/ext/standard/tests/math/octdec_basic.phpt +++ b/ext/standard/tests/math/octdec_basic.phpt @@ -25,23 +25,20 @@ $values = array(01234567, ); for ($i = 0; $i < count($values); $i++) { - $res = octdec($values[$i]); - var_dump($res); + try { + $res = octdec($values[$i]); + var_dump($res); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; + } } ?> --EXPECTF-- -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(14489) +Exception: Invalid characters passed for attempted conversion int(253) - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(36947879) - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(4618484) - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(4104) +Exception: Invalid characters passed for attempted conversion +Exception: Invalid characters passed for attempted conversion +Exception: Invalid characters passed for attempted conversion int(5349) int(342391) int(375) @@ -49,13 +46,9 @@ int(2147483647) Notice: Input number is larger than PHP_INT_MAX, precision has been lost in conversion in %s on line %d float(2147483648) - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(668) +Exception: Invalid characters passed for attempted conversion int(5349) - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(102923) +Exception: Invalid characters passed for attempted conversion int(823384) int(1) int(0) diff --git a/ext/standard/tests/math/octdec_basic_64bit.phpt b/ext/standard/tests/math/octdec_basic_64bit.phpt index 4051d9be6323..886cc317fa52 100644 --- a/ext/standard/tests/math/octdec_basic_64bit.phpt +++ b/ext/standard/tests/math/octdec_basic_64bit.phpt @@ -28,37 +28,29 @@ $values = array(01234567, ); for ($i = 0; $i < count($values); $i++) { - $res = octdec($values[$i]); - var_dump($res); + try { + $res = octdec($values[$i]); + var_dump($res); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage() . "\n"; + } } ?> ---EXPECTF-- +--EXPECT-- *** Testing octdec() : basic functionality *** - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(14489) +Exception: Invalid characters passed for attempted conversion int(253) - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(36947879) - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(4618484) - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(4104) +Exception: Invalid characters passed for attempted conversion +Exception: Invalid characters passed for attempted conversion +Exception: Invalid characters passed for attempted conversion int(5349) int(342391) int(375) int(2147483647) int(2147483648) - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(668) +Exception: Invalid characters passed for attempted conversion int(5349) - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(102923) +Exception: Invalid characters passed for attempted conversion int(823384) int(1) int(0) diff --git a/ext/standard/tests/math/octdec_variation1.phpt b/ext/standard/tests/math/octdec_variation1.phpt index 214875b7638d..d3a8a80093a2 100644 --- a/ext/standard/tests/math/octdec_variation1.phpt +++ b/ext/standard/tests/math/octdec_variation1.phpt @@ -78,44 +78,28 @@ int(1) int(5349) -- Iteration 4 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(1253) +Exception: Invalid characters passed for attempted conversion -- Iteration 5 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(1134037) +Exception: Invalid characters passed for attempted conversion -- Iteration 6 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(1134038) +Exception: Invalid characters passed for attempted conversion -- Iteration 7 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(69) +Exception: Invalid characters passed for attempted conversion -- Iteration 8 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(69) +Exception: Invalid characters passed for attempted conversion -- Iteration 9 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(175304192) +Exception: Invalid characters passed for attempted conversion -- Iteration 10 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(342391) +Exception: Invalid characters passed for attempted conversion -- Iteration 11 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(5) +Exception: Invalid characters passed for attempted conversion -- Iteration 12 -- int(1) @@ -139,19 +123,13 @@ int(0) TypeError: octdec(): Argument #1 ($octal_string) must be of type string, array given -- Iteration 19 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(0) +Exception: Invalid characters passed for attempted conversion -- Iteration 20 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(0) +Exception: Invalid characters passed for attempted conversion -- Iteration 21 -- - -Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d -int(0) +Exception: Invalid characters passed for attempted conversion -- Iteration 22 -- TypeError: octdec(): Argument #1 ($octal_string) must be of type string, resource given