From a70ae1b3d2d865768b1b968431070e3e42176772 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Tue, 2 Feb 2021 23:51:49 +0000 Subject: [PATCH 01/61] Warn on implicit float to int conversions. --- Zend/Optimizer/sccp.c | 9 + Zend/tests/array_offset.phpt | 4 + Zend/tests/bug72347.phpt | 3 +- Zend/tests/constant_expressions_dynamic.phpt | 2 + Zend/tests/empty_str_offset.phpt | 20 +- .../explicit_casts_should_not_warn.phpt | 34 ++++ .../no_warning_compatible_float_literals.phpt | 93 ++++++++++ ...ning_compatible_string_float_literals.phpt | 73 ++++++++ ...patible_float_literals_assignment_ops.phpt | 42 +++++ .../no_warnings_compatible_float_vars.phpt | 117 ++++++++++++ ...warnings_compatible_string_float_vars.phpt | 94 ++++++++++ ...g_float_does_not_fit_zend_long_arrays.phpt | 55 ++++++ ..._float_does_not_fit_zend_long_strings.phpt | 87 +++++++++ ...es_not_fit_zend_long_write_variation1.phpt | 28 +++ ...es_not_fit_zend_long_write_variation2.phpt | 28 +++ .../float_to_int/warnings_float_literals.phpt | 144 +++++++++++++++ ...arnings_float_literals_assignment_ops.phpt | 54 ++++++ .../float_to_int/warnings_float_vars.phpt | 173 ++++++++++++++++++ .../warnings_string_float_literals.phpt | 102 +++++++++++ ..._string_float_literals_assignment_ops.phpt | 54 ++++++ .../warnings_string_float_vars.phpt | 129 +++++++++++++ Zend/tests/isset_array.phpt | 2 + Zend/tests/isset_str_offset.phpt | 18 +- Zend/tests/list_keyed_conversions.phpt | 1 + Zend/tests/not_001.phpt | 3 +- Zend/tests/offset_array.phpt | 2 + .../tests/type_declarations/scalar_basic.phpt | 2 + .../scalar_return_basic_64bit.phpt | 2 + Zend/zend_API.c | 13 +- Zend/zend_ast.c | 2 +- Zend/zend_compile.c | 6 +- Zend/zend_execute.c | 10 +- Zend/zend_operators.c | 39 +++- Zend/zend_operators.h | 20 +- Zend/zend_vm_def.h | 6 +- Zend/zend_vm_execute.h | 52 +++--- ext/opcache/jit/zend_jit_helpers.c | 10 +- ext/spl/spl_array.c | 2 +- ext/spl/spl_engine.c | 2 +- ext/standard/array.c | 3 +- ext/standard/tests/file/file.inc | 6 +- ext/standard/tests/file/flock_variation.phpt | 31 ---- ext/standard/tests/strings/bug47842.phpt | 2 + 43 files changed, 1484 insertions(+), 95 deletions(-) create mode 100644 Zend/tests/float_to_int/explicit_casts_should_not_warn.phpt create mode 100644 Zend/tests/float_to_int/no_warning_compatible_float_literals.phpt create mode 100644 Zend/tests/float_to_int/no_warning_compatible_string_float_literals.phpt create mode 100644 Zend/tests/float_to_int/no_warnings_compatible_float_literals_assignment_ops.phpt create mode 100644 Zend/tests/float_to_int/no_warnings_compatible_float_vars.phpt create mode 100644 Zend/tests/float_to_int/no_warnings_compatible_string_float_vars.phpt create mode 100644 Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_arrays.phpt create mode 100644 Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_strings.phpt create mode 100644 Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_write_variation1.phpt create mode 100644 Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_write_variation2.phpt create mode 100644 Zend/tests/float_to_int/warnings_float_literals.phpt create mode 100644 Zend/tests/float_to_int/warnings_float_literals_assignment_ops.phpt create mode 100644 Zend/tests/float_to_int/warnings_float_vars.phpt create mode 100644 Zend/tests/float_to_int/warnings_string_float_literals.phpt create mode 100644 Zend/tests/float_to_int/warnings_string_float_literals_assignment_ops.phpt create mode 100644 Zend/tests/float_to_int/warnings_string_float_vars.phpt diff --git a/Zend/Optimizer/sccp.c b/Zend/Optimizer/sccp.c index 66688b3424505..7e43004591e69 100644 --- a/Zend/Optimizer/sccp.c +++ b/Zend/Optimizer/sccp.c @@ -426,6 +426,9 @@ static inline int fetch_array_elem(zval **result, zval *op1, zval *op2) { *result = zend_hash_index_find(Z_ARR_P(op1), Z_LVAL_P(op2)); return SUCCESS; case IS_DOUBLE: + if (!is_long_compatible(Z_DVAL_P(op2))) { + return FAILURE; + } *result = zend_hash_index_find(Z_ARR_P(op1), zend_dval_to_lval(Z_DVAL_P(op2))); return SUCCESS; case IS_STRING: @@ -509,6 +512,9 @@ static inline int ct_eval_del_array_elem(zval *result, zval *key) { zend_hash_index_del(Z_ARR_P(result), Z_LVAL_P(key)); break; case IS_DOUBLE: + if (!is_long_compatible(Z_DVAL_P(key))) { + return FAILURE; + } zend_hash_index_del(Z_ARR_P(result), zend_dval_to_lval(Z_DVAL_P(key))); break; case IS_STRING: @@ -550,6 +556,9 @@ static inline int ct_eval_add_array_elem(zval *result, zval *value, zval *key) { break; case IS_DOUBLE: SEPARATE_ARRAY(result); + if (!is_long_compatible(Z_DVAL_P(key))) { + return FAILURE; + } value = zend_hash_index_update( Z_ARR_P(result), zend_dval_to_lval(Z_DVAL_P(key)), value); break; diff --git a/Zend/tests/array_offset.phpt b/Zend/tests/array_offset.phpt index 6126db9748fd6..657f3b41d4087 100644 --- a/Zend/tests/array_offset.phpt +++ b/Zend/tests/array_offset.phpt @@ -13,9 +13,13 @@ echo "Done\n"; --EXPECTF-- Warning: Undefined array key -1 in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d + Warning: Undefined array key -1 in %s on line %d Warning: Undefined array key -1 in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d + Warning: Undefined array key -1 in %s on line %d Done diff --git a/Zend/tests/bug72347.phpt b/Zend/tests/bug72347.phpt index b86457207df5e..100ff51fb70e5 100644 --- a/Zend/tests/bug72347.phpt +++ b/Zend/tests/bug72347.phpt @@ -12,6 +12,7 @@ function test() : int { } var_dump(test()); ?> ---EXPECT-- +--EXPECTF-- +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d float(1.5) int(1) diff --git a/Zend/tests/constant_expressions_dynamic.phpt b/Zend/tests/constant_expressions_dynamic.phpt index fff9f74e524d1..2dfb75f7bab8a 100644 --- a/Zend/tests/constant_expressions_dynamic.phpt +++ b/Zend/tests/constant_expressions_dynamic.phpt @@ -46,6 +46,8 @@ var_dump( ?> --EXPECTF-- Warning: A non-numeric value encountered in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d int(3) string(4) "1foo" bool(false) diff --git a/Zend/tests/empty_str_offset.phpt b/Zend/tests/empty_str_offset.phpt index f89987109df5b..77723dfa614e4 100644 --- a/Zend/tests/empty_str_offset.phpt +++ b/Zend/tests/empty_str_offset.phpt @@ -62,7 +62,7 @@ var_dump(empty($str[$f])); print "done\n"; ?> ---EXPECT-- +--EXPECTF-- - empty --- bool(false) bool(true) @@ -98,14 +98,32 @@ bool(true) - null --- bool(false) - double --- + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d bool(false) + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d bool(true) + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d bool(true) + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d bool(false) + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d bool(false) + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d bool(false) + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d bool(false) + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d bool(false) + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d bool(true) - array --- bool(true) diff --git a/Zend/tests/float_to_int/explicit_casts_should_not_warn.phpt b/Zend/tests/float_to_int/explicit_casts_should_not_warn.phpt new file mode 100644 index 0000000000000..3136958a4b9d7 --- /dev/null +++ b/Zend/tests/float_to_int/explicit_casts_should_not_warn.phpt @@ -0,0 +1,34 @@ +--TEST-- +Explicit (int) cast must not warn +--FILE-- + +--EXPECT-- +int(3) +int(3) +int(0) +int(0) +int(0) +int(3) +int(3) +int(9223372036854775807) +int(9223372036854775807) +int(0) diff --git a/Zend/tests/float_to_int/no_warning_compatible_float_literals.phpt b/Zend/tests/float_to_int/no_warning_compatible_float_literals.phpt new file mode 100644 index 0000000000000..8d34adb8a0d9d --- /dev/null +++ b/Zend/tests/float_to_int/no_warning_compatible_float_literals.phpt @@ -0,0 +1,93 @@ +--TEST-- +Implicit float to int conversions should not warn for literals if float has a fractional part equal to 0 +--FILE-- +> 3; +var_dump($var); +$var = 3 << 1.0; +var_dump($var); +$var = 3 >> 1.0; +var_dump($var); + +echo 'Modulo:' . \PHP_EOL; +$var = 6.0 % 2; +var_dump($var); +$var = 9 % 2.0; +var_dump($var); + +echo 'Offset access:' . \PHP_EOL; +echo 'Arrays:' . \PHP_EOL; +$array = ['a', 'b', 'c']; +var_dump($array[1.0]); +$array[2.0] = 'z'; +var_dump($array); + +/* Strings are handled differently and always warn on non integer keys */ + +echo 'Function calls:' . \PHP_EOL; +function foo(int $a) { + return $a; +} +var_dump(foo(1.0)); + +var_dump(chr(60.0)); + +echo 'Function returns:' . \PHP_EOL; +function bar(): int { + return 3.0; +} +var_dump(bar()); + +echo 'Typed property assignment:' . \PHP_EOL; +class Test { + public int $a; +} + +$instance = new Test(); +$instance->a = 1.0; +var_dump($instance->a); + +?> +--EXPECT-- +Bitwise ops: +int(-2) +int(3) +int(1) +int(2) +int(8) +int(0) +int(6) +int(1) +Modulo: +int(0) +int(1) +Offset access: +Arrays: +string(1) "b" +array(3) { + [0]=> + string(1) "a" + [1]=> + string(1) "b" + [2]=> + string(1) "z" +} +Function calls: +int(1) +string(1) "<" +Function returns: +int(3) +Typed property assignment: +int(1) diff --git a/Zend/tests/float_to_int/no_warning_compatible_string_float_literals.phpt b/Zend/tests/float_to_int/no_warning_compatible_string_float_literals.phpt new file mode 100644 index 0000000000000..b51511b74dcc1 --- /dev/null +++ b/Zend/tests/float_to_int/no_warning_compatible_string_float_literals.phpt @@ -0,0 +1,73 @@ +--TEST-- +Implicit string float to int conversions should not warn for literals if float has a fractional part equal to 0 +--FILE-- +> 3; +var_dump($var); +$var = 3 << '1.0'; +var_dump($var); +$var = 3 >> '1.0'; +var_dump($var); + +echo 'Modulo:' . \PHP_EOL; +$var = '6.0' % 2; +var_dump($var); +$var = 9 % '2.0'; +var_dump($var); + +/* Float string array keys are never normalized to an integer value */ +/* Strings are handled differently and always warn on non integer keys */ + +echo 'Function calls:' . \PHP_EOL; +function foo(int $a) { + return $a; +} +var_dump(foo('1.0')); + +var_dump(chr('60.0')); + +echo 'Function returns:' . \PHP_EOL; +function bar(): int { + return '3.0'; +} +var_dump(bar()); + +echo 'Typed property assignment:' . \PHP_EOL; +class Test { + public int $a; +} + +$instance = new Test(); +$instance->a = '1.0'; +var_dump($instance->a); + +?> +--EXPECT-- +Bitwise ops: +int(3) +int(1) +int(2) +int(8) +int(0) +int(6) +int(1) +Modulo: +int(0) +int(1) +Function calls: +int(1) +string(1) "<" +Function returns: +int(3) +Typed property assignment: +int(1) diff --git a/Zend/tests/float_to_int/no_warnings_compatible_float_literals_assignment_ops.phpt b/Zend/tests/float_to_int/no_warnings_compatible_float_literals_assignment_ops.phpt new file mode 100644 index 0000000000000..82f8c381f15d2 --- /dev/null +++ b/Zend/tests/float_to_int/no_warnings_compatible_float_literals_assignment_ops.phpt @@ -0,0 +1,42 @@ +--TEST-- +Implicit float to int conversions should not warn for literals in combined assingment operetor if float has a fractional part equal to 0 +--FILE-- +>= 1.0; +var_dump($var); + +echo 'Modulo:' . \PHP_EOL; +$var = 9; +$var %= 2.0; +var_dump($var); + +?> +--EXPECT-- +Bitwise ops: +int(3) +int(1) +int(2) +int(6) +int(1) +Modulo: +int(1) diff --git a/Zend/tests/float_to_int/no_warnings_compatible_float_vars.phpt b/Zend/tests/float_to_int/no_warnings_compatible_float_vars.phpt new file mode 100644 index 0000000000000..e6007ce7d3af9 --- /dev/null +++ b/Zend/tests/float_to_int/no_warnings_compatible_float_vars.phpt @@ -0,0 +1,117 @@ +--TEST-- +Implicit float to int conversions should not warn for variables if float has a fractional part equal to 0 +--FILE-- +> 3; +var_dump($var); + +$var = $float; +$var <<= 3; +var_dump($var); + +$var = $float; +$var >>= 3; +var_dump($var); + +$var = 3 << $float; +var_dump($var); + +$var = 3 >> $float; +var_dump($var); + +echo 'Modulo:' . \PHP_EOL; +$modFloat = 6.0; +$var = $modFloat % 2; +var_dump($var); + +$modFloat = 2.0; +$var = 9 % $modFloat; +var_dump($var); + +echo 'Offset access:' . \PHP_EOL; +$offsetAccess = 2.0; +echo 'Arrays:' . \PHP_EOL; +$array = ['a', 'b', 'c']; +var_dump($array[$float]); +$array[$offsetAccess] = 'z'; +var_dump($array); + +echo 'Function calls:' . \PHP_EOL; +function foo(int $a) { + return $a; +} +var_dump(foo($float)); + +$cp = 60.0; +var_dump(chr($cp)); + +echo 'Function returns:' . \PHP_EOL; +function bar(): int { + $var = 3.0; + return $var; +} +var_dump(bar()); + +echo 'Typed property assignment:' . \PHP_EOL; +class Test { + public int $a; +} + +$instance = new Test(); +$instance->a = $float; +var_dump($instance->a); + +?> +--EXPECT-- +Bitwise ops: +int(-2) +int(3) +int(1) +int(2) +int(8) +int(0) +int(8) +int(0) +int(6) +int(1) +Modulo: +int(0) +int(1) +Offset access: +Arrays: +string(1) "b" +array(3) { + [0]=> + string(1) "a" + [1]=> + string(1) "b" + [2]=> + string(1) "z" +} +Function calls: +int(1) +string(1) "<" +Function returns: +int(3) +Typed property assignment: +int(1) diff --git a/Zend/tests/float_to_int/no_warnings_compatible_string_float_vars.phpt b/Zend/tests/float_to_int/no_warnings_compatible_string_float_vars.phpt new file mode 100644 index 0000000000000..3c80e3ad42a48 --- /dev/null +++ b/Zend/tests/float_to_int/no_warnings_compatible_string_float_vars.phpt @@ -0,0 +1,94 @@ +--TEST-- +Implicit string float to int conversions should not warn for variables if float has a fractional part equal to 0 +--FILE-- +> 3; +var_dump($var); + +$var = $float; +$var <<= 3; +var_dump($var); + +$var = $float; +$var >>= 3; +var_dump($var); + +$var = 3 << $float; +var_dump($var); + +$var = 3 >> $float; +var_dump($var); + +echo 'Modulo:' . \PHP_EOL; +$modFloat = '6.0'; +$var = $modFloat % 2; +var_dump($var); + +$modFloat = '2.0'; +$var = 9 % $modFloat; +var_dump($var); + +echo 'Function calls:' . \PHP_EOL; +function foo(int $a) { + return $a; +} +var_dump(foo($float)); + +$cp = '60.0'; +var_dump(chr($cp)); + +echo 'Function returns:' . \PHP_EOL; +function bar(): int { + $var = '3.0'; + return $var; +} +var_dump(bar()); + +echo 'Typed property assignment:' . \PHP_EOL; +class Test { + public int $a; +} + +$instance = new Test(); +$instance->a = $float; +var_dump($instance->a); + +?> +--EXPECT-- +Bitwise ops: +int(3) +int(1) +int(2) +int(8) +int(0) +int(8) +int(0) +int(6) +int(1) +Modulo: +int(0) +int(1) +Function calls: +int(1) +string(1) "<" +Function returns: +int(3) +Typed property assignment: +int(1) diff --git a/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_arrays.phpt b/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_arrays.phpt new file mode 100644 index 0000000000000..0ec518b646883 --- /dev/null +++ b/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_arrays.phpt @@ -0,0 +1,55 @@ +--TEST-- +Implicit float to int conversions when float too large should warn, array variant +--FILE-- + 'Large float', (string) 10e120 => 'String large float']; +$arrayDynamic = [$float => 'Large float', $string_float => 'String large float']; + +var_dump($arrayConstant); +var_dump($arrayDynamic); + +$array = ['0', '1', '2']; +var_dump($array[10e120]); +var_dump($array[(string) 10e120]); +var_dump($array[$float]); +var_dump($array[$string_float]); + +?> +--EXPECTF-- +int(0) +int(9223372036854775807) + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +array(2) { + [0]=> + string(11) "Large float" + ["1.0E+121"]=> + string(18) "String large float" +} +array(2) { + [0]=> + string(11) "Large float" + ["1.0E+121"]=> + string(18) "String large float" +} + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +string(1) "0" + +Warning: Undefined array key "1.0E+121" in %s on line %d +NULL + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +string(1) "0" + +Warning: Undefined array key "1.0E+121" in %s on line %d +NULL diff --git a/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_strings.phpt b/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_strings.phpt new file mode 100644 index 0000000000000..a72758616097d --- /dev/null +++ b/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_strings.phpt @@ -0,0 +1,87 @@ +--TEST-- +Implicit float to int conversions when float too large should warn, array variant +--FILE-- + +--EXPECTF-- +int(0) +int(9223372036854775807) +Attempt to read +Float + +Warning: String offset cast occurred in %s on line %d +string(1) "H" +Float variable + +Warning: String offset cast occurred in %s on line %d +string(1) "H" +Float casted to string compile + +Warning: Uninitialized string offset 9223372036854775807 in %s on line %d +TypeError +Float string variable + +Warning: Uninitialized string offset 9223372036854775807 in %s on line %d +TypeError +Attempt to assign +Float + +Warning: String offset cast occurred in %s on line %d +string(34) "Eere is some text for good measure" +Float variable + +Warning: String offset cast occurred in %s on line %d +string(34) "Eere is some text for good measure" diff --git a/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_write_variation1.phpt b/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_write_variation1.phpt new file mode 100644 index 0000000000000..c504b4df97ca6 --- /dev/null +++ b/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_write_variation1.phpt @@ -0,0 +1,28 @@ +--TEST-- +Implicit float to int conversions when float too large should warn, array variant +--FILE-- + +--EXPECTF-- +Float casted to string compile + +Warning: Uncaught TypeError: Cannot access offset of type string on string in %s:%d +Stack trace: +#0 {main} + thrown in %s on line %d + +Fatal error: Allowed memory size of %d bytes exhausted at %s:141 (tried to allocate %d bytes) in %s on line %d diff --git a/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_write_variation2.phpt b/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_write_variation2.phpt new file mode 100644 index 0000000000000..dfc0e4c824a00 --- /dev/null +++ b/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_write_variation2.phpt @@ -0,0 +1,28 @@ +--TEST-- +Implicit float to int conversions when float too large should warn, array variant +--FILE-- + +--EXPECTF-- +Float string variable + +Warning: Uncaught TypeError: Cannot access offset of type string on string in %s:%d +Stack trace: +#0 {main} + thrown in %s on line %d + +Fatal error: Allowed memory size of %d bytes exhausted at %s:141 (tried to allocate %d bytes) in %s on line %d diff --git a/Zend/tests/float_to_int/warnings_float_literals.phpt b/Zend/tests/float_to_int/warnings_float_literals.phpt new file mode 100644 index 0000000000000..a55c7991e1163 --- /dev/null +++ b/Zend/tests/float_to_int/warnings_float_literals.phpt @@ -0,0 +1,144 @@ +--TEST-- +Implicit float to int conversions should warn for literals +--XFAIL-- +Double warning for internal calls +--FILE-- +> 3; +var_dump($var); +$var = 3 << 1.5; +var_dump($var); +$var = 3 >> 1.5; +var_dump($var); + +echo 'Modulo:' . \PHP_EOL; +// 2 warnings in total +$var = 6.5 % 2; +var_dump($var); +$var = 9 % 2.5; +var_dump($var); + +echo 'Offset access:' . \PHP_EOL; +echo 'Arrays:' . \PHP_EOL; +// 2 warnings in total +$array = ['a', 'b', 'c']; +var_dump($array[1.5]); +$array[2.5] = 'z'; +var_dump($array); + +echo 'Strings:' . \PHP_EOL; +// 2 warnings in total +$string = 'php'; +var_dump($string[1.5]); +$string[2.5] = 'z'; +var_dump($string); + +echo 'Function calls:' . \PHP_EOL; +function foo(int $a) { + return $a; +} +var_dump(foo(1.5)); + +// TODO: Why are two warnings generated here? +var_dump(chr(60.5)); + +echo 'Function returns:' . \PHP_EOL; +function bar(): int { + return 3.5; +} +var_dump(bar()); + +echo 'Typed property assignment:' . \PHP_EOL; +class Test { + public int $a; +} + +$instance = new Test(); +$instance->a = 1.5; +var_dump($instance->a); + +?> +--EXPECTF-- +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Bitwise ops: +int(-2) +int(3) +int(1) +int(2) +int(8) +int(0) +int(6) +int(1) +Modulo: +int(0) +int(1) +Offset access: +Arrays: + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +string(1) "b" + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +array(3) { + [0]=> + string(1) "a" + [1]=> + string(1) "b" + [2]=> + string(1) "z" +} +Strings: + +Warning: String offset cast occurred in %s on line %d +string(1) "h" + +Warning: String offset cast occurred in %s on line %d +string(3) "phz" +Function calls: + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +int(1) + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +string(1) "<" +Function returns: + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +int(3) +Typed property assignment: + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +int(1) diff --git a/Zend/tests/float_to_int/warnings_float_literals_assignment_ops.phpt b/Zend/tests/float_to_int/warnings_float_literals_assignment_ops.phpt new file mode 100644 index 0000000000000..f309961e68495 --- /dev/null +++ b/Zend/tests/float_to_int/warnings_float_literals_assignment_ops.phpt @@ -0,0 +1,54 @@ +--TEST-- +Implicit float to int conversions should warn for literals in combined assingment operetor +--FILE-- +>= 1.5; +var_dump($var); + +echo 'Modulo:' . \PHP_EOL; +$var = 9; +$var %= 2.5; +var_dump($var); + +?> +--EXPECTF-- +Bitwise ops: + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +int(3) + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +int(1) + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +int(2) + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +int(6) + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +int(1) +Modulo: + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +int(1) diff --git a/Zend/tests/float_to_int/warnings_float_vars.phpt b/Zend/tests/float_to_int/warnings_float_vars.phpt new file mode 100644 index 0000000000000..8b35ba91ee683 --- /dev/null +++ b/Zend/tests/float_to_int/warnings_float_vars.phpt @@ -0,0 +1,173 @@ +--TEST-- +Implicit float to int conversions should warn for variables +--XFAIL-- +Double warning for internal calls +--FILE-- +> 3; +var_dump($var); + +$var = $float; +$var <<= 3; +var_dump($var); + +$var = $float; +$var >>= 3; +var_dump($var); + +$var = 3 << $float; +var_dump($var); + +$var = 3 >> $float; +var_dump($var); + +echo 'Modulo:' . \PHP_EOL; +$modFloat = 6.5; +$var = $modFloat % 2; +var_dump($var); + +$modFloat = 2.5; +$var = 9 % $modFloat; +var_dump($var); + +echo 'Offset access:' . \PHP_EOL; +$offsetAccess = 2.5; +echo 'Arrays:' . \PHP_EOL; +// 2 warnings in total +$array = ['a', 'b', 'c']; +var_dump($array[$float]); +$array[$offsetAccess] = 'z'; +var_dump($array); + +echo 'Strings:' . \PHP_EOL; +// 2 warnings in total +$string = 'php'; +var_dump($string[$float]); +$string[$offsetAccess] = 'z'; +var_dump($string); + +echo 'Function calls:' . \PHP_EOL; +function foo(int $a) { + return $a; +} +var_dump(foo($float)); + +// TODO: Why are two warnings generated here? +$cp = 60.5; +var_dump(chr($cp)); + +echo 'Function returns:' . \PHP_EOL; +function bar(): int { + $var = 3.5; + return $var; +} +var_dump(bar()); + +echo 'Typed property assignment:' . \PHP_EOL; +class Test { + public int $a; +} + +$instance = new Test(); +$instance->a = $float; +var_dump($instance->a); + +?> +--EXPECTF-- +Bitwise ops: + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +int(-2) + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +int(3) + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +int(1) + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +int(2) + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +int(8) + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +int(0) + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +int(8) + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +int(0) + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +int(6) + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +int(1) +Modulo: + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +int(0) + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +int(1) +Offset access: +Arrays: + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +string(1) "b" + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +array(3) { + [0]=> + string(1) "a" + [1]=> + string(1) "b" + [2]=> + string(1) "z" +} +Strings: + +Warning: String offset cast occurred in %s on line %d +string(1) "h" + +Warning: String offset cast occurred in %s on line %d +string(3) "phz" +Function calls: + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +int(1) + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +string(1) "<" +Function returns: + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +int(3) +Typed property assignment: + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +int(1) diff --git a/Zend/tests/float_to_int/warnings_string_float_literals.phpt b/Zend/tests/float_to_int/warnings_string_float_literals.phpt new file mode 100644 index 0000000000000..cbba22f9f98c1 --- /dev/null +++ b/Zend/tests/float_to_int/warnings_string_float_literals.phpt @@ -0,0 +1,102 @@ +--TEST-- +Implicit string float to int conversions should warn for literals +--XFAIL-- +Double warning for internal calls +--FILE-- +> 3; +var_dump($var); +$var = 3 << '1.5'; +var_dump($var); +$var = 3 >> '1.5'; +var_dump($var); + +echo 'Modulo:' . \PHP_EOL; +// 2 warnings in total +$var = '6.5' % 2; +var_dump($var); +$var = 9 % '2.5'; +var_dump($var); + +echo 'Function calls:' . \PHP_EOL; +function foo(int $a) { + return $a; +} +var_dump(foo('1.5')); + +// TODO: Why are two warnings generated here? +var_dump(chr('60.5')); + +echo 'Function returns:' . \PHP_EOL; +function bar(): int { + return '3.5'; +} +var_dump(bar()); + +echo 'Typed property assignment:' . \PHP_EOL; +class Test { + public int $a; +} + +$instance = new Test(); +$instance->a = '1.5'; +var_dump($instance->a); + +?> +--EXPECTF-- +Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +Bitwise ops: +int(3) +int(1) +int(2) +int(8) +int(0) +int(6) +int(1) +Modulo: +int(0) +int(1) +Function calls: + +Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +int(1) + +Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +string(1) "<" +Function returns: + +Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +int(3) +Typed property assignment: + +Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +int(1) diff --git a/Zend/tests/float_to_int/warnings_string_float_literals_assignment_ops.phpt b/Zend/tests/float_to_int/warnings_string_float_literals_assignment_ops.phpt new file mode 100644 index 0000000000000..f203dde2e8d4d --- /dev/null +++ b/Zend/tests/float_to_int/warnings_string_float_literals_assignment_ops.phpt @@ -0,0 +1,54 @@ +--TEST-- +Implicit float to int conversions should warn for literals in combined assingment operetor +--FILE-- +>= '1.5'; +var_dump($var); + +echo 'Modulo:' . \PHP_EOL; +$var = 9; +$var %= '2.5'; +var_dump($var); + +?> +--EXPECTF-- +Bitwise ops: + +Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +int(3) + +Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +int(1) + +Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +int(2) + +Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +int(6) + +Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +int(1) +Modulo: + +Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +int(1) diff --git a/Zend/tests/float_to_int/warnings_string_float_vars.phpt b/Zend/tests/float_to_int/warnings_string_float_vars.phpt new file mode 100644 index 0000000000000..e741e10bc705f --- /dev/null +++ b/Zend/tests/float_to_int/warnings_string_float_vars.phpt @@ -0,0 +1,129 @@ +--TEST-- +Implicit float string to int conversions should warn for variables +--XFAIL-- +Double warning for internal calls +--FILE-- +> 3; +var_dump($var); + +$var = $float; +$var <<= 3; +var_dump($var); + +$var = $float; +$var >>= 3; +var_dump($var); + +$var = 3 << $float; +var_dump($var); + +$var = 3 >> $float; +var_dump($var); + +echo 'Modulo:' . \PHP_EOL; +$modFloat = '6.5'; +$var = $modFloat % 2; +var_dump($var); + +$modFloat = '2.5'; +$var = 9 % $modFloat; +var_dump($var); + +echo 'Function calls:' . \PHP_EOL; +function foo(int $a) { + return $a; +} +var_dump(foo($float)); + +// TODO: Why are two warnings generated here? +$cp = '60.5'; +var_dump(chr($cp)); + +echo 'Function returns:' . \PHP_EOL; +function bar(): int { + $var = '3.5'; + return $var; +} +var_dump(bar()); + +echo 'Typed property assignment:' . \PHP_EOL; +class Test { + public int $a; +} + +$instance = new Test(); +$instance->a = $float; +var_dump($instance->a); + +?> +--EXPECTF-- +Bitwise ops: + +Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +int(3) + +Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +int(1) + +Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +int(2) + +Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +int(8) + +Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +int(0) + +Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +int(8) + +Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +int(0) + +Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +int(6) + +Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +int(1) +Modulo: + +Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +int(0) + +Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +int(1) +Function calls: + +Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +int(1) + +Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +string(1) "<" +Function returns: + +Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +int(3) +Typed property assignment: + +Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +int(1) diff --git a/Zend/tests/isset_array.phpt b/Zend/tests/isset_array.phpt index c7c1876410d71..83db3d640d07c 100644 --- a/Zend/tests/isset_array.phpt +++ b/Zend/tests/isset_array.phpt @@ -38,6 +38,8 @@ try { bool(true) bool(true) bool(true) + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d bool(true) bool(false) bool(false) diff --git a/Zend/tests/isset_str_offset.phpt b/Zend/tests/isset_str_offset.phpt index 5f7b72771f593..98867f8b23d2c 100644 --- a/Zend/tests/isset_str_offset.phpt +++ b/Zend/tests/isset_str_offset.phpt @@ -60,7 +60,7 @@ var_dump(isset($str[$f])); print "done\n"; ?> ---EXPECT-- +--EXPECTF-- - isset --- bool(true) bool(false) @@ -95,13 +95,29 @@ bool(false) - null --- bool(true) - double --- + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d bool(true) + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d bool(false) + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d bool(true) + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d bool(true) + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d bool(true) + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d bool(true) + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d bool(true) + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d bool(false) - array --- bool(false) diff --git a/Zend/tests/list_keyed_conversions.phpt b/Zend/tests/list_keyed_conversions.phpt index 6b213d60f41d8..6e13d5c7078e4 100644 --- a/Zend/tests/list_keyed_conversions.phpt +++ b/Zend/tests/list_keyed_conversions.phpt @@ -21,6 +21,7 @@ list(STDIN => $resource) = []; ?> --EXPECTF-- +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d string(0) "" int(1) int(0) diff --git a/Zend/tests/not_001.phpt b/Zend/tests/not_001.phpt index 2d7f85a8b4b1c..8307c0d2aead5 100644 --- a/Zend/tests/not_001.phpt +++ b/Zend/tests/not_001.phpt @@ -16,7 +16,8 @@ var_dump(bin2hex($s1)); echo "Done\n"; ?> ---EXPECT-- +--EXPECTF-- +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d int(-24) string(8) "8c90929a" Done diff --git a/Zend/tests/offset_array.phpt b/Zend/tests/offset_array.phpt index bd6baa1651635..343107b1182ce 100644 --- a/Zend/tests/offset_array.phpt +++ b/Zend/tests/offset_array.phpt @@ -34,6 +34,8 @@ echo "Done\n"; ?> --EXPECTF-- int(2) + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d int(1) Warning: Undefined array key "" in %s on line %d diff --git a/Zend/tests/type_declarations/scalar_basic.phpt b/Zend/tests/type_declarations/scalar_basic.phpt index 908f1a18b248e..8b3865efa7dc7 100644 --- a/Zend/tests/type_declarations/scalar_basic.phpt +++ b/Zend/tests/type_declarations/scalar_basic.phpt @@ -6,6 +6,7 @@ Scalar type basics $errnames = [ E_NOTICE => 'E_NOTICE', E_WARNING => 'E_WARNING', + E_DEPRECATED => 'E_DEPRECATED' ]; set_error_handler(function (int $errno, string $errmsg, string $file, int $line) use ($errnames) { echo "$errnames[$errno]: $errmsg on line $line\n"; @@ -71,6 +72,7 @@ int(1) int(1) *** Trying float(1.5) +E_DEPRECATED: Implicit conversion to int from non-compatible float on line %d int(1) *** Trying string(2) "1a" diff --git a/Zend/tests/type_declarations/scalar_return_basic_64bit.phpt b/Zend/tests/type_declarations/scalar_return_basic_64bit.phpt index e49b9f5b2ad36..f9622dbca68bd 100644 --- a/Zend/tests/type_declarations/scalar_return_basic_64bit.phpt +++ b/Zend/tests/type_declarations/scalar_return_basic_64bit.phpt @@ -8,6 +8,7 @@ Return scalar type basics $errnames = [ E_NOTICE => 'E_NOTICE', E_WARNING => 'E_WARNING', + E_DEPRECATED => 'E_DEPRECATED', ]; set_error_handler(function (int $errno, string $errmsg, string $file, int $line) use ($errnames) { echo "$errnames[$errno]: $errmsg on line $line\n"; @@ -70,6 +71,7 @@ int(1) *** Trying float(1) int(1) *** Trying float(1.5) +E_DEPRECATED: Implicit conversion to int from non-compatible float on line %d int(1) *** Trying string(2) "1a" *** Caught {closure}(): Return value must be of type int, string returned in %s on line %d diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 1e062534ce0f6..d6736efaaa643 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -503,7 +503,7 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest, if (UNEXPECTED(!ZEND_DOUBLE_FITS_LONG(Z_DVAL_P(arg)))) { return 0; } else { - *dest = zend_dval_to_lval(Z_DVAL_P(arg)); + *dest = zend_dval_to_lval_safe(Z_DVAL_P(arg)); } } else if (EXPECTED(Z_TYPE_P(arg) == IS_STRING)) { double d; @@ -516,9 +516,14 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest, } if (UNEXPECTED(!ZEND_DOUBLE_FITS_LONG(d))) { return 0; - } else { - *dest = zend_dval_to_lval(d); } + + /* This only checks for a fractional part as if doesn't fit it already throws a TypeError + * Manually check to get correct warning text mentioning string origin */ + if (!is_long_compatible(d)) { + zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float-string"); + } + *dest = zend_dval_to_lval(d); } else { return 0; } @@ -1971,7 +1976,7 @@ ZEND_API zend_result array_set_zval_key(HashTable *ht, zval *key, zval *value) / result = zend_hash_index_update(ht, Z_LVAL_P(key), value); break; case IS_DOUBLE: - result = zend_hash_index_update(ht, zend_dval_to_lval(Z_DVAL_P(key)), value); + result = zend_hash_index_update(ht, zend_dval_to_lval_safe(Z_DVAL_P(key)), value); break; default: zend_type_error("Illegal offset type"); diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c index 0d4a9dff5aaff..e222e4bd74019 100644 --- a/Zend/zend_ast.c +++ b/Zend/zend_ast.c @@ -465,7 +465,7 @@ static zend_result zend_ast_add_array_element(zval *result, zval *offset, zval * zend_hash_index_update(Z_ARRVAL_P(result), 1, expr); break; case IS_DOUBLE: - zend_hash_index_update(Z_ARRVAL_P(result), zend_dval_to_lval(Z_DVAL_P(offset)), expr); + zend_hash_index_update(Z_ARRVAL_P(result), zend_dval_to_lval_safe(Z_DVAL_P(offset)), expr); break; case IS_RESOURCE: zend_error(E_WARNING, "Resource ID#%d used as offset, casting to integer (%d)", Z_RES_HANDLE_P(offset), Z_RES_HANDLE_P(offset)); diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 17b78fac2806a..9e24dfb3269a8 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -8197,12 +8197,12 @@ ZEND_API bool zend_binary_op_produces_error(uint32_t opcode, zval *op1, zval *op return 1; } - if ((opcode == ZEND_MOD && zval_get_long(op2) == 0) + if ((opcode == ZEND_MOD && zval_get_long_func(op2, /* lax */ true) == 0) || (opcode == ZEND_DIV && zval_get_double(op2) == 0.0)) { /* Division by zero throws an error. */ return 1; } - if ((opcode == ZEND_SL || opcode == ZEND_SR) && zval_get_long(op2) < 0) { + if ((opcode == ZEND_SL || opcode == ZEND_SR) && zval_get_long_func(op2, /* lax */ true) < 0) { /* Shift by negative number throws an error. */ return 1; } @@ -8355,7 +8355,7 @@ static bool zend_try_ct_eval_array(zval *result, zend_ast *ast) /* {{{ */ break; case IS_DOUBLE: zend_hash_index_update(Z_ARRVAL_P(result), - zend_dval_to_lval(Z_DVAL_P(key)), value); + zend_dval_to_lval_safe(Z_DVAL_P(key)), value); break; case IS_FALSE: zend_hash_index_update(Z_ARRVAL_P(result), 0, value); diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 1b0dd4f232afa..ed8d5c581ec62 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -1470,7 +1470,7 @@ static zend_never_inline zend_long zend_check_string_offset(zval *dim, int type break; } - offset = zval_get_long_func(dim); + offset = zval_get_long_func(dim, /* lax */ true); } else { offset = Z_LVAL_P(dim); } @@ -2133,7 +2133,7 @@ static zend_never_inline zend_uchar slow_index_convert(HashTable *ht, const zval value->str = ZSTR_EMPTY_ALLOC(); return IS_STRING; case IS_DOUBLE: - value->lval = zend_dval_to_lval(Z_DVAL_P(dim)); + value->lval = zend_dval_to_lval_safe(Z_DVAL_P(dim)); return IS_LONG; case IS_RESOURCE: zend_use_resource_as_offset(dim); @@ -2452,7 +2452,7 @@ static zend_always_inline void zend_fetch_dimension_address_read(zval *result, z break; } - offset = zval_get_long_func(dim); + offset = zval_get_long_func(dim, /* is_lax */ true); } else { offset = Z_LVAL_P(dim); } @@ -2543,7 +2543,7 @@ static zend_never_inline zval* ZEND_FASTCALL zend_find_array_dim_slow(HashTable zend_ulong hval; if (Z_TYPE_P(offset) == IS_DOUBLE) { - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_lval_safe(Z_DVAL_P(offset)); num_idx: return zend_hash_index_find(ht, hval); } else if (Z_TYPE_P(offset) == IS_NULL) { @@ -2667,7 +2667,7 @@ static zend_never_inline bool ZEND_FASTCALL zend_array_key_exists_fast(HashTable key = Z_REFVAL_P(key); goto try_again; } else if (Z_TYPE_P(key) == IS_DOUBLE) { - hval = zend_dval_to_lval(Z_DVAL_P(key)); + hval = zend_dval_to_lval_safe(Z_DVAL_P(key)); goto num_key; } else if (Z_TYPE_P(key) == IS_FALSE) { hval = 0; diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 2df256cc52c81..ceda8892e1b35 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -304,6 +304,12 @@ static zend_never_inline zend_long ZEND_FASTCALL zendi_try_get_long(zval *op, bo case IS_TRUE: return 1; case IS_DOUBLE: + if (!is_long_compatible(Z_DVAL_P(op))) { + zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float"); + if (UNEXPECTED(EG(exception))) { + *failed = 1; + } + } return zend_dval_to_lval(Z_DVAL_P(op)); case IS_STRING: { @@ -333,7 +339,13 @@ static zend_never_inline zend_long ZEND_FASTCALL zendi_try_get_long(zval *op, bo * We use use saturating conversion to emulate strtol()'s * behaviour. */ - return zend_dval_to_lval_cap(dval); + if (!is_long_compatible(dval)) { + zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float-string"); + if (UNEXPECTED(EG(exception))) { + *failed = 1; + } + } + return zend_dval_to_lval_cap(dval); } } case IS_OBJECT: @@ -431,6 +443,7 @@ static zend_never_inline zend_long ZEND_FASTCALL zendi_try_get_long(zval *op, bo } \ } while (0); +/* TODO Should this warn? */ ZEND_API void ZEND_FASTCALL convert_to_long(zval *op) /* {{{ */ { zend_long tmp; @@ -457,7 +470,7 @@ ZEND_API void ZEND_FASTCALL convert_to_long(zval *op) /* {{{ */ case IS_STRING: { zend_string *str = Z_STR_P(op); - ZVAL_LONG(op, zval_get_long(op)); + ZVAL_LONG(op, zval_get_long_ex(op, /* is lax */ true)); zend_string_release_ex(str, 0); } break; @@ -792,7 +805,7 @@ ZEND_API void ZEND_FASTCALL convert_to_object(zval *op) /* {{{ */ } /* }}} */ -ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op) /* {{{ */ +ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op, bool is_lax) /* {{{ */ { try_again: switch (Z_TYPE_P(op)) { @@ -807,6 +820,13 @@ ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op) /* {{{ */ case IS_LONG: return Z_LVAL_P(op); case IS_DOUBLE: + if (EXPECTED(!is_lax)) { + if (!is_long_compatible(Z_DVAL_P(op))) { + zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float"); + // TODO Need to handle this here? + //if (UNEXPECTED(EG(exception))) {} + } + } return zend_dval_to_lval(Z_DVAL_P(op)); case IS_STRING: { @@ -823,7 +843,15 @@ ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op) /* {{{ */ * We use saturating conversion to emulate strtol()'s * behaviour. */ - return zend_dval_to_lval_cap(dval); + /* Most usages are expected to not be (int) casts */ + if (EXPECTED(!is_lax)) { + if (!is_long_compatible(dval)) { + zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float-string"); + // TODO Need to handle this here? + //if (UNEXPECTED(EG(exception))) {} + } + } + return zend_dval_to_lval_cap(dval); } } case IS_ARRAY: @@ -1456,7 +1484,8 @@ ZEND_API zend_result ZEND_FASTCALL bitwise_not_function(zval *result, zval *op1) ZVAL_LONG(result, ~Z_LVAL_P(op1)); return SUCCESS; case IS_DOUBLE: - ZVAL_LONG(result, ~zend_dval_to_lval(Z_DVAL_P(op1))); + // TODO Handle manually in case deprecation notice promoted to Exception? + ZVAL_LONG(result, ~zend_dval_to_lval_safe(Z_DVAL_P(op1))); return SUCCESS; case IS_STRING: { size_t i; diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index 3fe8b0e384ea4..c7e7ff9bbda85 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -122,6 +122,7 @@ static zend_always_inline zend_long zend_dval_to_lval(double d) } #endif +/* Used to convert a string float to integer during an (int) cast */ static zend_always_inline zend_long zend_dval_to_lval_cap(double d) { if (UNEXPECTED(!zend_finite(d)) || UNEXPECTED(zend_isnan(d))) { @@ -133,6 +134,18 @@ static zend_always_inline zend_long zend_dval_to_lval_cap(double d) } /* }}} */ +static zend_always_inline bool is_long_compatible(double d) { + return ((double)(zend_long) d == d); +} + +static zend_always_inline zend_long zend_dval_to_lval_safe(double d) +{ + if (!is_long_compatible(d)) { + zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float"); + } + return zend_dval_to_lval(d); +} + #define ZEND_IS_DIGIT(c) ((c) >= '0' && (c) <= '9') #define ZEND_IS_XDIGIT(c) (((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f')) @@ -267,13 +280,16 @@ ZEND_API void ZEND_FASTCALL convert_to_boolean(zval *op); ZEND_API void ZEND_FASTCALL convert_to_array(zval *op); ZEND_API void ZEND_FASTCALL convert_to_object(zval *op); -ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op); +ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op, bool is_lax); ZEND_API double ZEND_FASTCALL zval_get_double_func(zval *op); ZEND_API zend_string* ZEND_FASTCALL zval_get_string_func(zval *op); ZEND_API zend_string* ZEND_FASTCALL zval_try_get_string_func(zval *op); static zend_always_inline zend_long zval_get_long(zval *op) { - return EXPECTED(Z_TYPE_P(op) == IS_LONG) ? Z_LVAL_P(op) : zval_get_long_func(op); + return EXPECTED(Z_TYPE_P(op) == IS_LONG) ? Z_LVAL_P(op) : zval_get_long_func(op, 0); +} +static zend_always_inline zend_long zval_get_long_ex(zval *op, bool is_lax) { + return EXPECTED(Z_TYPE_P(op) == IS_LONG) ? Z_LVAL_P(op) : zval_get_long_func(op, is_lax); } static zend_always_inline double zval_get_double(zval *op) { return EXPECTED(Z_TYPE_P(op) == IS_DOUBLE) ? Z_DVAL_P(op) : zval_get_double_func(op); diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 23186d939333e..ec2bbd76fbab2 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -5937,7 +5937,7 @@ ZEND_VM_C_LABEL(num_index): str = ZSTR_EMPTY_ALLOC(); ZEND_VM_C_GOTO(str_index); } else if (Z_TYPE_P(offset) == IS_DOUBLE) { - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_lval_safe(Z_DVAL_P(offset)); ZEND_VM_C_GOTO(num_index); } else if (Z_TYPE_P(offset) == IS_FALSE) { hval = 0; @@ -6117,7 +6117,7 @@ ZEND_VM_COLD_CONST_HANDLER(51, ZEND_CAST, CONST|TMP|VAR|CV, ANY, TYPE) switch (opline->extended_value) { case IS_LONG: - ZVAL_LONG(result, zval_get_long(expr)); + ZVAL_LONG(result, zval_get_long_ex(expr, /* lax */ true)); break; case IS_DOUBLE: ZVAL_DOUBLE(result, zval_get_double(expr)); @@ -6420,7 +6420,7 @@ ZEND_VM_C_LABEL(num_index_dim): offset = Z_REFVAL_P(offset); ZEND_VM_C_GOTO(offset_again); } else if (Z_TYPE_P(offset) == IS_DOUBLE) { - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_lval_safe(Z_DVAL_P(offset)); ZEND_VM_C_GOTO(num_index_dim); } else if (Z_TYPE_P(offset) == IS_NULL) { key = ZSTR_EMPTY_ALLOC(); diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index bf12fd20dc781..d5cf4dc8bd5ae 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -4736,7 +4736,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CAST_SPEC_CONST_H switch (opline->extended_value) { case IS_LONG: - ZVAL_LONG(result, zval_get_long(expr)); + ZVAL_LONG(result, zval_get_long_ex(expr, /* lax */ true)); break; case IS_DOUBLE: ZVAL_DOUBLE(result, zval_get_double(expr)); @@ -7128,7 +7128,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_C str = ZSTR_EMPTY_ALLOC(); goto str_index; } else if (Z_TYPE_P(offset) == IS_DOUBLE) { - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_lval_safe(Z_DVAL_P(offset)); goto num_index; } else if (Z_TYPE_P(offset) == IS_FALSE) { hval = 0; @@ -9321,7 +9321,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_T str = ZSTR_EMPTY_ALLOC(); goto str_index; } else if (Z_TYPE_P(offset) == IS_DOUBLE) { - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_lval_safe(Z_DVAL_P(offset)); goto num_index; } else if (Z_TYPE_P(offset) == IS_FALSE) { hval = 0; @@ -10241,7 +10241,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_U str = ZSTR_EMPTY_ALLOC(); goto str_index; } else if (Z_TYPE_P(offset) == IS_DOUBLE) { - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_lval_safe(Z_DVAL_P(offset)); goto num_index; } else if (Z_TYPE_P(offset) == IS_FALSE) { hval = 0; @@ -11670,7 +11670,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_C str = ZSTR_EMPTY_ALLOC(); goto str_index; } else if (Z_TYPE_P(offset) == IS_DOUBLE) { - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_lval_safe(Z_DVAL_P(offset)); goto num_index; } else if (Z_TYPE_P(offset) == IS_FALSE) { hval = 0; @@ -18958,7 +18958,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CAST_SPEC_TMP_HANDLER(ZEND_OPC switch (opline->extended_value) { case IS_LONG: - ZVAL_LONG(result, zval_get_long(expr)); + ZVAL_LONG(result, zval_get_long_ex(expr, /* lax */ true)); break; case IS_DOUBLE: ZVAL_DOUBLE(result, zval_get_double(expr)); @@ -19620,7 +19620,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_CON str = ZSTR_EMPTY_ALLOC(); goto str_index; } else if (Z_TYPE_P(offset) == IS_DOUBLE) { - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_lval_safe(Z_DVAL_P(offset)); goto num_index; } else if (Z_TYPE_P(offset) == IS_FALSE) { hval = 0; @@ -20059,7 +20059,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_TMP str = ZSTR_EMPTY_ALLOC(); goto str_index; } else if (Z_TYPE_P(offset) == IS_DOUBLE) { - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_lval_safe(Z_DVAL_P(offset)); goto num_index; } else if (Z_TYPE_P(offset) == IS_FALSE) { hval = 0; @@ -20519,7 +20519,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_UNU str = ZSTR_EMPTY_ALLOC(); goto str_index; } else if (Z_TYPE_P(offset) == IS_DOUBLE) { - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_lval_safe(Z_DVAL_P(offset)); goto num_index; } else if (Z_TYPE_P(offset) == IS_FALSE) { hval = 0; @@ -20918,7 +20918,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_CV_ str = ZSTR_EMPTY_ALLOC(); goto str_index; } else if (Z_TYPE_P(offset) == IS_DOUBLE) { - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_lval_safe(Z_DVAL_P(offset)); goto num_index; } else if (Z_TYPE_P(offset) == IS_FALSE) { hval = 0; @@ -21572,7 +21572,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CAST_SPEC_VAR_HANDLER(ZEND_OPC switch (opline->extended_value) { case IS_LONG: - ZVAL_LONG(result, zval_get_long(expr)); + ZVAL_LONG(result, zval_get_long_ex(expr, /* lax */ true)); break; case IS_DOUBLE: ZVAL_DOUBLE(result, zval_get_double(expr)); @@ -24437,7 +24437,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_CON str = ZSTR_EMPTY_ALLOC(); goto str_index; } else if (Z_TYPE_P(offset) == IS_DOUBLE) { - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_lval_safe(Z_DVAL_P(offset)); goto num_index; } else if (Z_TYPE_P(offset) == IS_FALSE) { hval = 0; @@ -24526,7 +24526,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_CONST_HANDL offset = Z_REFVAL_P(offset); goto offset_again; } else if (Z_TYPE_P(offset) == IS_DOUBLE) { - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_lval_safe(Z_DVAL_P(offset)); goto num_index_dim; } else if (Z_TYPE_P(offset) == IS_NULL) { key = ZSTR_EMPTY_ALLOC(); @@ -26612,7 +26612,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_TMP str = ZSTR_EMPTY_ALLOC(); goto str_index; } else if (Z_TYPE_P(offset) == IS_DOUBLE) { - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_lval_safe(Z_DVAL_P(offset)); goto num_index; } else if (Z_TYPE_P(offset) == IS_FALSE) { hval = 0; @@ -26701,7 +26701,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_TMPVAR_HAND offset = Z_REFVAL_P(offset); goto offset_again; } else if (Z_TYPE_P(offset) == IS_DOUBLE) { - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_lval_safe(Z_DVAL_P(offset)); goto num_index_dim; } else if (Z_TYPE_P(offset) == IS_NULL) { key = ZSTR_EMPTY_ALLOC(); @@ -28469,7 +28469,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_UNU str = ZSTR_EMPTY_ALLOC(); goto str_index; } else if (Z_TYPE_P(offset) == IS_DOUBLE) { - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_lval_safe(Z_DVAL_P(offset)); goto num_index; } else if (Z_TYPE_P(offset) == IS_FALSE) { hval = 0; @@ -30612,7 +30612,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_CV_ str = ZSTR_EMPTY_ALLOC(); goto str_index; } else if (Z_TYPE_P(offset) == IS_DOUBLE) { - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_lval_safe(Z_DVAL_P(offset)); goto num_index; } else if (Z_TYPE_P(offset) == IS_FALSE) { hval = 0; @@ -30701,7 +30701,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_CV_HANDLER( offset = Z_REFVAL_P(offset); goto offset_again; } else if (Z_TYPE_P(offset) == IS_DOUBLE) { - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_lval_safe(Z_DVAL_P(offset)); goto num_index_dim; } else if (Z_TYPE_P(offset) == IS_NULL) { key = ZSTR_EMPTY_ALLOC(); @@ -38100,7 +38100,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CAST_SPEC_CV_HANDLER(ZEND_OPCO switch (opline->extended_value) { case IS_LONG: - ZVAL_LONG(result, zval_get_long(expr)); + ZVAL_LONG(result, zval_get_long_ex(expr, /* lax */ true)); break; case IS_DOUBLE: ZVAL_DOUBLE(result, zval_get_double(expr)); @@ -41855,7 +41855,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_CONS str = ZSTR_EMPTY_ALLOC(); goto str_index; } else if (Z_TYPE_P(offset) == IS_DOUBLE) { - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_lval_safe(Z_DVAL_P(offset)); goto num_index; } else if (Z_TYPE_P(offset) == IS_FALSE) { hval = 0; @@ -41944,7 +41944,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_CONST_HANDLE offset = Z_REFVAL_P(offset); goto offset_again; } else if (Z_TYPE_P(offset) == IS_DOUBLE) { - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_lval_safe(Z_DVAL_P(offset)); goto num_index_dim; } else if (Z_TYPE_P(offset) == IS_NULL) { key = ZSTR_EMPTY_ALLOC(); @@ -45323,7 +45323,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_TMPV str = ZSTR_EMPTY_ALLOC(); goto str_index; } else if (Z_TYPE_P(offset) == IS_DOUBLE) { - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_lval_safe(Z_DVAL_P(offset)); goto num_index; } else if (Z_TYPE_P(offset) == IS_FALSE) { hval = 0; @@ -45412,7 +45412,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_TMPVAR_HANDL offset = Z_REFVAL_P(offset); goto offset_again; } else if (Z_TYPE_P(offset) == IS_DOUBLE) { - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_lval_safe(Z_DVAL_P(offset)); goto num_index_dim; } else if (Z_TYPE_P(offset) == IS_NULL) { key = ZSTR_EMPTY_ALLOC(); @@ -47063,7 +47063,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_UNUS str = ZSTR_EMPTY_ALLOC(); goto str_index; } else if (Z_TYPE_P(offset) == IS_DOUBLE) { - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_lval_safe(Z_DVAL_P(offset)); goto num_index; } else if (Z_TYPE_P(offset) == IS_FALSE) { hval = 0; @@ -50428,7 +50428,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_CV_H str = ZSTR_EMPTY_ALLOC(); goto str_index; } else if (Z_TYPE_P(offset) == IS_DOUBLE) { - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_lval_safe(Z_DVAL_P(offset)); goto num_index; } else if (Z_TYPE_P(offset) == IS_FALSE) { hval = 0; @@ -50517,7 +50517,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_CV_HANDLER(Z offset = Z_REFVAL_P(offset); goto offset_again; } else if (Z_TYPE_P(offset) == IS_DOUBLE) { - hval = zend_dval_to_lval(Z_DVAL_P(offset)); + hval = zend_dval_to_lval_safe(Z_DVAL_P(offset)); goto num_index_dim; } else if (Z_TYPE_P(offset) == IS_NULL) { key = ZSTR_EMPTY_ALLOC(); diff --git a/ext/opcache/jit/zend_jit_helpers.c b/ext/opcache/jit/zend_jit_helpers.c index 99e48fd793198..55ff82f5d63fb 100644 --- a/ext/opcache/jit/zend_jit_helpers.c +++ b/ext/opcache/jit/zend_jit_helpers.c @@ -399,7 +399,7 @@ static void ZEND_FASTCALL zend_jit_fetch_dim_r_helper(zend_array *ht, zval *dim, offset_key = ZSTR_EMPTY_ALLOC(); goto str_index; case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(dim)); + hval = zend_dval_to_lval_safe(Z_DVAL_P(dim)); goto num_index; case IS_RESOURCE: zend_error(E_WARNING, "Resource ID#%d used as offset, casting to integer (%d)", Z_RES_HANDLE_P(dim), Z_RES_HANDLE_P(dim)); @@ -464,7 +464,7 @@ static void ZEND_FASTCALL zend_jit_fetch_dim_is_helper(zend_array *ht, zval *dim offset_key = ZSTR_EMPTY_ALLOC(); goto str_index; case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(dim)); + hval = zend_dval_to_lval_safe(Z_DVAL_P(dim)); goto num_index; case IS_RESOURCE: zend_error(E_WARNING, "Resource ID#%d used as offset, casting to integer (%d)", Z_RES_HANDLE_P(dim), Z_RES_HANDLE_P(dim)); @@ -527,7 +527,7 @@ static int ZEND_FASTCALL zend_jit_fetch_dim_isset_helper(zend_array *ht, zval *d offset_key = ZSTR_EMPTY_ALLOC(); goto str_index; case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(dim)); + hval = zend_dval_to_lval_safe(Z_DVAL_P(dim)); goto num_index; case IS_RESOURCE: zend_error(E_WARNING, "Resource ID#%d used as offset, casting to integer (%d)", Z_RES_HANDLE_P(dim), Z_RES_HANDLE_P(dim)); @@ -594,7 +594,7 @@ static zval* ZEND_FASTCALL zend_jit_fetch_dim_rw_helper(zend_array *ht, zval *di offset_key = ZSTR_EMPTY_ALLOC(); goto str_index; case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(dim)); + hval = zend_dval_to_lval_safe(Z_DVAL_P(dim)); goto num_index; case IS_RESOURCE: zend_error(E_WARNING, "Resource ID#%d used as offset, casting to integer (%d)", Z_RES_HANDLE_P(dim), Z_RES_HANDLE_P(dim)); @@ -667,7 +667,7 @@ static zval* ZEND_FASTCALL zend_jit_fetch_dim_w_helper(zend_array *ht, zval *dim offset_key = ZSTR_EMPTY_ALLOC(); goto str_index; case IS_DOUBLE: - hval = zend_dval_to_lval(Z_DVAL_P(dim)); + hval = zend_dval_to_lval_safe(Z_DVAL_P(dim)); goto num_index; case IS_RESOURCE: zend_error(E_WARNING, "Resource ID#%d used as offset, casting to integer (%d)", Z_RES_HANDLE_P(dim), Z_RES_HANDLE_P(dim)); diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index 43d4c28e683f9..2b7375ead15b7 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -310,7 +310,7 @@ static zend_result get_hash_key(spl_hash_key *key, spl_array_object *intern, zva break; case IS_DOUBLE: key->key = NULL; - key->h = (zend_long) Z_DVAL_P(offset); + key->h = zend_dval_to_lval_safe(Z_DVAL_P(offset)); break; case IS_FALSE: key->key = NULL; diff --git a/ext/spl/spl_engine.c b/ext/spl/spl_engine.c index b7423df9d4f0d..f9a371838453d 100644 --- a/ext/spl/spl_engine.c +++ b/ext/spl/spl_engine.c @@ -41,7 +41,7 @@ PHPAPI zend_long spl_offset_convert_to_long(zval *offset) /* {{{ */ } break; case IS_DOUBLE: - return zend_dval_to_lval(Z_DVAL_P(offset)); + return zend_dval_to_lval_safe(Z_DVAL_P(offset)); case IS_LONG: return Z_LVAL_P(offset); case IS_FALSE: diff --git a/ext/standard/array.c b/ext/standard/array.c index a04125db870df..31476f7dac01d 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -6052,7 +6052,8 @@ PHP_FUNCTION(array_key_exists) RETVAL_BOOL(zend_hash_exists(ht, ZSTR_EMPTY_ALLOC())); break; case IS_DOUBLE: - RETVAL_BOOL(zend_hash_index_exists(ht, zend_dval_to_lval(Z_DVAL_P(key)))); + /* TODO Should this warn or not? */ + RETVAL_BOOL(zend_hash_index_exists(ht, zend_dval_to_lval_safe(Z_DVAL_P(key)))); break; case IS_FALSE: RETVAL_BOOL(zend_hash_index_exists(ht, 0)); diff --git a/ext/standard/tests/file/file.inc b/ext/standard/tests/file/file.inc index 08825f450268e..0292bea118281 100644 --- a/ext/standard/tests/file/file.inc +++ b/ext/standard/tests/file/file.inc @@ -68,7 +68,7 @@ function fill_buffer(&$buffer, $fill_type, $fill_size) { return false; } - $tmp_buff = str_repeat($data, ($fill_size/$size_divider) + $add_value ); + $tmp_buff = str_repeat($data, (int)(($fill_size/$size_divider) + $add_value) ); if ( strlen($tmp_buff) > $fill_size ) { $buffer = substr($tmp_buff, 0, $fill_size); @@ -128,7 +128,7 @@ function fill_file($file_handle, $fill_type, $file_size) { if ( $size <= $chunk_size ) { $chunk_size = $size; } - $num_values = str_repeat($data, ($chunk_size/$size_divider) + $add_value ); + $num_values = str_repeat($data, (int) (($chunk_size/$size_divider) + $add_value) ); $bytes_written = fwrite($file_handle, $num_values, $chunk_size); if ( $bytes_written != $chunk_size ) { return false; @@ -136,7 +136,7 @@ function fill_file($file_handle, $fill_type, $file_size) { $size -= $chunk_size; } while ( $size > 0 ); } else { - $num_values = str_repeat($data, ($chunk_size/$size_divider) + $add_value ); + $num_values = str_repeat($data, (int) (($chunk_size/$size_divider) + $add_value) ); $bytes_written = fwrite($file_handle, $num_values, $file_size); if ( $bytes_written != $file_size ) { return false; diff --git a/ext/standard/tests/file/flock_variation.phpt b/ext/standard/tests/file/flock_variation.phpt index f4a51999592b4..1d73e90d254d4 100644 --- a/ext/standard/tests/file/flock_variation.phpt +++ b/ext/standard/tests/file/flock_variation.phpt @@ -18,7 +18,6 @@ $operations = array( LOCK_UN, 1, 2, - 2.234, TRUE ); @@ -332,35 +331,5 @@ bool(true) bool(true) -- Inner iteration 13 in 8 -- bool(true) ---- Outer iteration 9 --- -bool(true) --- Inner iteration 0 in 9 -- -bool(true) --- Inner iteration 1 in 9 -- -bool(true) --- Inner iteration 2 in 9 -- -bool(true) --- Inner iteration 3 in 9 -- -bool(true) --- Inner iteration 4 in 9 -- -bool(true) --- Inner iteration 5 in 9 -- -bool(true) --- Inner iteration 6 in 9 -- -bool(true) --- Inner iteration 7 in 9 -- -bool(true) --- Inner iteration 8 in 9 -- -bool(true) --- Inner iteration 9 in 9 -- -bool(true) --- Inner iteration 10 in 9 -- -bool(true) --- Inner iteration 11 in 9 -- -bool(true) --- Inner iteration 12 in 9 -- -bool(true) --- Inner iteration 13 in 9 -- -bool(true) *** Done *** diff --git a/ext/standard/tests/strings/bug47842.phpt b/ext/standard/tests/strings/bug47842.phpt index 4ac9da6d830cd..2cda861fd2c74 100644 --- a/ext/standard/tests/strings/bug47842.phpt +++ b/ext/standard/tests/strings/bug47842.phpt @@ -30,5 +30,7 @@ sscanf 32-bit unsign int '4294967295' (2^32)-1 = 4294967295 sscanf 64-bit signed int '9223372036854775807' (2^63)-1 = 9223372036854775807 sscanf 64-bit unsign int '18446744073709551615' (2^64)-1 = 18446744073709551615 printf 64-bit signed int '9223372036854775807' (2^63)-1 = 9223372036854775807 + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d printf 64-bit signed int '18446744073709551615' (2^64)-1 = 0 Done From 6a0ddf86a2ec35d976609f1bc813ec2119a13347 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sat, 20 Feb 2021 11:05:38 +0000 Subject: [PATCH 02/61] Fix JIT --- ext/opcache/jit/zend_jit_helpers.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/opcache/jit/zend_jit_helpers.c b/ext/opcache/jit/zend_jit_helpers.c index 55ff82f5d63fb..53b921439fd67 100644 --- a/ext/opcache/jit/zend_jit_helpers.c +++ b/ext/opcache/jit/zend_jit_helpers.c @@ -736,7 +736,7 @@ static zend_never_inline zend_long zend_check_string_offset(zval *dim/*, int typ break; } - return _zval_get_long_func(dim); + return zval_get_long_func(dim, /* is_lax */ true); } static zend_always_inline zend_string* zend_jit_fetch_dim_str_offset(zend_string *str, zend_long offset) @@ -803,7 +803,7 @@ static void ZEND_FASTCALL zend_jit_fetch_dim_str_is_helper(zend_string *str, zva break; } - offset = _zval_get_long_func(dim); + offset = zval_get_long_func(dim, /* is_lax */ true); } else { offset = Z_LVAL_P(dim); } From 48e3acacd75ec855dd11cf02cd61d1e3f3d1c383 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sat, 20 Feb 2021 11:57:56 +0000 Subject: [PATCH 03/61] Fix double deprecation notice in debug builds Also fix memory exhaustion test text to be valid on prod builds --- ...es_not_fit_zend_long_write_variation1.phpt | 2 +- ...es_not_fit_zend_long_write_variation2.phpt | 2 +- .../float_to_int/warnings_float_literals.phpt | 5 ----- .../float_to_int/warnings_float_vars.phpt | 5 ----- .../warnings_string_float_literals.phpt | 5 ----- .../warnings_string_float_vars.phpt | 5 ----- Zend/zend_API.c | 19 ++++++++++++++++--- Zend/zend_execute.c | 7 ++++--- 8 files changed, 22 insertions(+), 28 deletions(-) diff --git a/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_write_variation1.phpt b/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_write_variation1.phpt index c504b4df97ca6..1073d15d22a83 100644 --- a/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_write_variation1.phpt +++ b/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_write_variation1.phpt @@ -25,4 +25,4 @@ Stack trace: #0 {main} thrown in %s on line %d -Fatal error: Allowed memory size of %d bytes exhausted at %s:141 (tried to allocate %d bytes) in %s on line %d +Fatal error: Allowed memory size of %d bytes exhausted %S(tried to allocate %d bytes) in %s on line %d diff --git a/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_write_variation2.phpt b/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_write_variation2.phpt index dfc0e4c824a00..0da42a2957526 100644 --- a/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_write_variation2.phpt +++ b/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_write_variation2.phpt @@ -25,4 +25,4 @@ Stack trace: #0 {main} thrown in %s on line %d -Fatal error: Allowed memory size of %d bytes exhausted at %s:141 (tried to allocate %d bytes) in %s on line %d +Fatal error: Allowed memory size of %d bytes exhausted %S(tried to allocate %d bytes) in %s on line %d diff --git a/Zend/tests/float_to_int/warnings_float_literals.phpt b/Zend/tests/float_to_int/warnings_float_literals.phpt index a55c7991e1163..ea73ef82c969b 100644 --- a/Zend/tests/float_to_int/warnings_float_literals.phpt +++ b/Zend/tests/float_to_int/warnings_float_literals.phpt @@ -1,7 +1,5 @@ --TEST-- Implicit float to int conversions should warn for literals ---XFAIL-- -Double warning for internal calls --FILE-- Date: Sat, 20 Feb 2021 13:54:55 +0000 Subject: [PATCH 04/61] Fix test --- .../union_int_string_type_arg.phpt | 28 +++++++++++ Zend/tests/operator_unsupported_types.phpt | 46 ++++++++++++++++++- .../runtime_compile_time_binary_operands.phpt | 1 + .../iterator_to_array_nonscalar_keys.phpt | 3 +- 4 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 Zend/tests/float_to_int/union_int_string_type_arg.phpt diff --git a/Zend/tests/float_to_int/union_int_string_type_arg.phpt b/Zend/tests/float_to_int/union_int_string_type_arg.phpt new file mode 100644 index 0000000000000..799328d60213e --- /dev/null +++ b/Zend/tests/float_to_int/union_int_string_type_arg.phpt @@ -0,0 +1,28 @@ +--TEST-- +Union of int|string shouldn't warn if string semantics are used +--FILE-- + +--EXPECTF-- +int(1) + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +int(1) +string(3) "NAN" +string(8) "1.0E+121" +string(3) "INF" diff --git a/Zend/tests/operator_unsupported_types.phpt b/Zend/tests/operator_unsupported_types.phpt index 94e23ec60376a..10c521024dff6 100644 --- a/Zend/tests/operator_unsupported_types.phpt +++ b/Zend/tests/operator_unsupported_types.phpt @@ -31,13 +31,13 @@ $legalValues = [ 'true', 'false', '2', - '3.5', + '3.5', // Semi-legal for certain ops '"123"', '"123foo"', // Semi-legal ]; set_error_handler(function($errno, $errstr) { - assert($errno == E_WARNING); + assert($errno == E_WARNING || $errno == E_DEPRECATED); echo "Warning: $errstr\n"; }); @@ -453,6 +453,7 @@ Unsupported operand types: bool % array Unsupported operand types: array % int Unsupported operand types: int % array Unsupported operand types: array % float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float % array Unsupported operand types: array % string Unsupported operand types: string % array @@ -468,6 +469,7 @@ Unsupported operand types: bool % stdClass Unsupported operand types: stdClass % int Unsupported operand types: int % stdClass Unsupported operand types: stdClass % float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float % stdClass Unsupported operand types: stdClass % string Unsupported operand types: string % stdClass @@ -483,6 +485,7 @@ Unsupported operand types: bool % resource Unsupported operand types: resource % int Unsupported operand types: int % resource Unsupported operand types: resource % float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float % resource Unsupported operand types: resource % string Unsupported operand types: string % resource @@ -498,6 +501,7 @@ Unsupported operand types: bool % string Unsupported operand types: string % int Unsupported operand types: int % string Unsupported operand types: string % float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float % string Unsupported operand types: string % string Unsupported operand types: string % string @@ -605,6 +609,7 @@ Unsupported operand types: bool << array Unsupported operand types: array << int Unsupported operand types: int << array Unsupported operand types: array << float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float << array Unsupported operand types: array << string Unsupported operand types: string << array @@ -620,6 +625,7 @@ Unsupported operand types: bool << stdClass Unsupported operand types: stdClass << int Unsupported operand types: int << stdClass Unsupported operand types: stdClass << float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float << stdClass Unsupported operand types: stdClass << string Unsupported operand types: string << stdClass @@ -635,6 +641,7 @@ Unsupported operand types: bool << resource Unsupported operand types: resource << int Unsupported operand types: int << resource Unsupported operand types: resource << float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float << resource Unsupported operand types: resource << string Unsupported operand types: string << resource @@ -650,6 +657,7 @@ Unsupported operand types: bool << string Unsupported operand types: string << int Unsupported operand types: int << string Unsupported operand types: string << float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float << string Unsupported operand types: string << string Unsupported operand types: string << string @@ -681,6 +689,7 @@ Unsupported operand types: bool >> array Unsupported operand types: array >> int Unsupported operand types: int >> array Unsupported operand types: array >> float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float >> array Unsupported operand types: array >> string Unsupported operand types: string >> array @@ -696,6 +705,7 @@ Unsupported operand types: bool >> stdClass Unsupported operand types: stdClass >> int Unsupported operand types: int >> stdClass Unsupported operand types: stdClass >> float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float >> stdClass Unsupported operand types: stdClass >> string Unsupported operand types: string >> stdClass @@ -711,6 +721,7 @@ Unsupported operand types: bool >> resource Unsupported operand types: resource >> int Unsupported operand types: int >> resource Unsupported operand types: resource >> float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float >> resource Unsupported operand types: resource >> string Unsupported operand types: string >> resource @@ -726,6 +737,7 @@ Unsupported operand types: bool >> string Unsupported operand types: string >> int Unsupported operand types: int >> string Unsupported operand types: string >> float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float >> string Unsupported operand types: string >> string Unsupported operand types: string >> string @@ -757,6 +769,7 @@ Unsupported operand types: bool & array Unsupported operand types: array & int Unsupported operand types: int & array Unsupported operand types: array & float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float & array Unsupported operand types: array & string Unsupported operand types: string & array @@ -800,6 +813,7 @@ Unsupported operand types: bool & string Unsupported operand types: string & int Unsupported operand types: int & string Unsupported operand types: string & float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float & string No error for "foo" & "123" No error for "123" & "foo" @@ -830,6 +844,7 @@ Unsupported operand types: bool | array Unsupported operand types: array | int Unsupported operand types: int | array Unsupported operand types: array | float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float | array Unsupported operand types: array | string Unsupported operand types: string | array @@ -873,6 +888,7 @@ Unsupported operand types: bool | string Unsupported operand types: string | int Unsupported operand types: int | string Unsupported operand types: string | float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float | string No error for "foo" | "123" No error for "123" | "foo" @@ -903,6 +919,7 @@ Unsupported operand types: bool ^ array Unsupported operand types: array ^ int Unsupported operand types: int ^ array Unsupported operand types: array ^ float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float ^ array Unsupported operand types: array ^ string Unsupported operand types: string ^ array @@ -946,6 +963,7 @@ Unsupported operand types: bool ^ string Unsupported operand types: string ^ int Unsupported operand types: int ^ string Unsupported operand types: string ^ float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float ^ string No error for "foo" ^ "123" No error for "123" ^ "foo" @@ -1449,6 +1467,7 @@ Unsupported operand types: bool % array Unsupported operand types: array % int Unsupported operand types: int % array Unsupported operand types: array % float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float % array Unsupported operand types: array % string Unsupported operand types: string % array @@ -1464,6 +1483,7 @@ Unsupported operand types: bool % stdClass Unsupported operand types: stdClass % int Unsupported operand types: int % stdClass Unsupported operand types: stdClass % float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float % stdClass Unsupported operand types: stdClass % string Unsupported operand types: string % stdClass @@ -1479,6 +1499,7 @@ Unsupported operand types: bool % resource Unsupported operand types: resource % int Unsupported operand types: int % resource Unsupported operand types: resource % float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float % resource Unsupported operand types: resource % string Unsupported operand types: string % resource @@ -1494,6 +1515,7 @@ Unsupported operand types: bool % string Unsupported operand types: string % int Unsupported operand types: int % string Unsupported operand types: string % float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float % string Unsupported operand types: string % string Unsupported operand types: string % string @@ -1601,6 +1623,7 @@ Unsupported operand types: bool << array Unsupported operand types: array << int Unsupported operand types: int << array Unsupported operand types: array << float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float << array Unsupported operand types: array << string Unsupported operand types: string << array @@ -1616,6 +1639,7 @@ Unsupported operand types: bool << stdClass Unsupported operand types: stdClass << int Unsupported operand types: int << stdClass Unsupported operand types: stdClass << float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float << stdClass Unsupported operand types: stdClass << string Unsupported operand types: string << stdClass @@ -1631,6 +1655,7 @@ Unsupported operand types: bool << resource Unsupported operand types: resource << int Unsupported operand types: int << resource Unsupported operand types: resource << float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float << resource Unsupported operand types: resource << string Unsupported operand types: string << resource @@ -1646,6 +1671,7 @@ Unsupported operand types: bool << string Unsupported operand types: string << int Unsupported operand types: int << string Unsupported operand types: string << float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float << string Unsupported operand types: string << string Unsupported operand types: string << string @@ -1677,6 +1703,7 @@ Unsupported operand types: bool >> array Unsupported operand types: array >> int Unsupported operand types: int >> array Unsupported operand types: array >> float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float >> array Unsupported operand types: array >> string Unsupported operand types: string >> array @@ -1692,6 +1719,7 @@ Unsupported operand types: bool >> stdClass Unsupported operand types: stdClass >> int Unsupported operand types: int >> stdClass Unsupported operand types: stdClass >> float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float >> stdClass Unsupported operand types: stdClass >> string Unsupported operand types: string >> stdClass @@ -1707,6 +1735,7 @@ Unsupported operand types: bool >> resource Unsupported operand types: resource >> int Unsupported operand types: int >> resource Unsupported operand types: resource >> float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float >> resource Unsupported operand types: resource >> string Unsupported operand types: string >> resource @@ -1722,6 +1751,7 @@ Unsupported operand types: bool >> string Unsupported operand types: string >> int Unsupported operand types: int >> string Unsupported operand types: string >> float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float >> string Unsupported operand types: string >> string Unsupported operand types: string >> string @@ -1753,6 +1783,7 @@ Unsupported operand types: bool & array Unsupported operand types: array & int Unsupported operand types: int & array Unsupported operand types: array & float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float & array Unsupported operand types: array & string Unsupported operand types: string & array @@ -1768,6 +1799,7 @@ Unsupported operand types: bool & stdClass Unsupported operand types: stdClass & int Unsupported operand types: int & stdClass Unsupported operand types: stdClass & float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float & stdClass Unsupported operand types: stdClass & string Unsupported operand types: string & stdClass @@ -1783,6 +1815,7 @@ Unsupported operand types: bool & resource Unsupported operand types: resource & int Unsupported operand types: int & resource Unsupported operand types: resource & float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float & resource Unsupported operand types: resource & string Unsupported operand types: string & resource @@ -1798,6 +1831,7 @@ Unsupported operand types: bool & string Unsupported operand types: string & int Unsupported operand types: int & string Unsupported operand types: string & float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float & string No error for "foo" &= "123" No error for "123" &= "foo" @@ -1828,6 +1862,7 @@ Unsupported operand types: bool | array Unsupported operand types: array | int Unsupported operand types: int | array Unsupported operand types: array | float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float | array Unsupported operand types: array | string Unsupported operand types: string | array @@ -1843,6 +1878,7 @@ Unsupported operand types: bool | stdClass Unsupported operand types: stdClass | int Unsupported operand types: int | stdClass Unsupported operand types: stdClass | float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float | stdClass Unsupported operand types: stdClass | string Unsupported operand types: string | stdClass @@ -1858,6 +1894,7 @@ Unsupported operand types: bool | resource Unsupported operand types: resource | int Unsupported operand types: int | resource Unsupported operand types: resource | float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float | resource Unsupported operand types: resource | string Unsupported operand types: string | resource @@ -1873,6 +1910,7 @@ Unsupported operand types: bool | string Unsupported operand types: string | int Unsupported operand types: int | string Unsupported operand types: string | float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float | string No error for "foo" |= "123" No error for "123" |= "foo" @@ -1903,6 +1941,7 @@ Unsupported operand types: bool ^ array Unsupported operand types: array ^ int Unsupported operand types: int ^ array Unsupported operand types: array ^ float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float ^ array Unsupported operand types: array ^ string Unsupported operand types: string ^ array @@ -1918,6 +1957,7 @@ Unsupported operand types: bool ^ stdClass Unsupported operand types: stdClass ^ int Unsupported operand types: int ^ stdClass Unsupported operand types: stdClass ^ float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float ^ stdClass Unsupported operand types: stdClass ^ string Unsupported operand types: string ^ stdClass @@ -1933,6 +1973,7 @@ Unsupported operand types: bool ^ resource Unsupported operand types: resource ^ int Unsupported operand types: int ^ resource Unsupported operand types: resource ^ float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float ^ resource Unsupported operand types: resource ^ string Unsupported operand types: string ^ resource @@ -1948,6 +1989,7 @@ Unsupported operand types: bool ^ string Unsupported operand types: string ^ int Unsupported operand types: int ^ string Unsupported operand types: string ^ float +Warning: Implicit conversion to int from non-compatible float Unsupported operand types: float ^ string No error for "foo" ^= "123" No error for "123" ^= "foo" diff --git a/Zend/tests/runtime_compile_time_binary_operands.phpt b/Zend/tests/runtime_compile_time_binary_operands.phpt index 14195141b111e..f1f04e078a811 100644 --- a/Zend/tests/runtime_compile_time_binary_operands.phpt +++ b/Zend/tests/runtime_compile_time_binary_operands.phpt @@ -2,6 +2,7 @@ Test binary operands exposing the same behavior at compile as at run time --INI-- memory_limit=256M +error_reporting=E_ALL & ~E_DEPRECATED --FILE-- ---EXPECT-- +--EXPECTF-- +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d Illegal offset type From 74ab99ccc1cb51cb6d0c892f572edf4b515069e9 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sat, 20 Feb 2021 17:01:41 +0000 Subject: [PATCH 05/61] Remove some ZPP checks --- ext/date/tests/getdate_variation6.phpt | 101 ----------- ext/date/tests/gmmktime_variation9.phpt | 68 ------- .../tests/gmmktime_variation9_64bits.phpt | 58 ------ ext/imap/tests/imap_fetch_overview_error.phpt | 31 ++++ .../tests/imap_fetch_overview_variation3.phpt | 70 -------- ext/imap/tests/imap_fetchbody_variation4.phpt | 74 -------- .../tests/imap_fetchheader_variation3.phpt | 71 -------- ext/intl/tests/collator_get_locale2.phpt | 2 - ext/posix/tests/posix_ttyname_variation4.phpt | 40 ----- .../SplFixedArray__construct_param_float.phpt | 14 -- .../SplFixedArray_offsetExists_integer.phpt | 8 - .../SplFixedArray_offsetGet_integer.phpt | 19 -- .../SplFixedArray_setSize_param_float.phpt | 19 -- ext/standard/tests/math/mt_rand_basic.phpt | 36 +--- ext/standard/tests/math/rand_basic.phpt | 37 +--- .../xml_parser_set_option_variation3.phpt | 170 ------------------ ext/zlib/tests/gzfile_variation11.phpt | 128 ------------- ext/zlib/tests/readgzfile_variation11.phpt | 63 ------- 18 files changed, 33 insertions(+), 976 deletions(-) delete mode 100644 ext/date/tests/getdate_variation6.phpt delete mode 100644 ext/date/tests/gmmktime_variation9.phpt delete mode 100644 ext/date/tests/gmmktime_variation9_64bits.phpt create mode 100644 ext/imap/tests/imap_fetch_overview_error.phpt delete mode 100644 ext/imap/tests/imap_fetch_overview_variation3.phpt delete mode 100644 ext/imap/tests/imap_fetchbody_variation4.phpt delete mode 100644 ext/imap/tests/imap_fetchheader_variation3.phpt delete mode 100644 ext/posix/tests/posix_ttyname_variation4.phpt delete mode 100644 ext/spl/tests/SplFixedArray__construct_param_float.phpt delete mode 100644 ext/spl/tests/SplFixedArray_offsetExists_integer.phpt delete mode 100644 ext/spl/tests/SplFixedArray_offsetGet_integer.phpt delete mode 100644 ext/spl/tests/SplFixedArray_setSize_param_float.phpt delete mode 100644 ext/xml/tests/xml_parser_set_option_variation3.phpt delete mode 100644 ext/zlib/tests/gzfile_variation11.phpt delete mode 100644 ext/zlib/tests/readgzfile_variation11.phpt diff --git a/ext/date/tests/getdate_variation6.phpt b/ext/date/tests/getdate_variation6.phpt deleted file mode 100644 index a6ed34184a60f..0000000000000 --- a/ext/date/tests/getdate_variation6.phpt +++ /dev/null @@ -1,101 +0,0 @@ ---TEST-- -Test getdate() function : usage variation - Passing strings containing numbers ---FILE-- - '0', - 'String 10.5' => "10.5", - 'String -10.5' => '-10.5', -); - -// loop through each element of the array for timestamp -foreach($inputs as $key => $value) { - echo "\n--$key--\n"; - var_dump( getdate($value) ); -}; -?> ---EXPECT-- -*** Testing getdate() : usage variation *** - ---String 0-- -array(11) { - ["seconds"]=> - int(0) - ["minutes"]=> - int(30) - ["hours"]=> - int(5) - ["mday"]=> - int(1) - ["wday"]=> - int(4) - ["mon"]=> - int(1) - ["year"]=> - int(1970) - ["yday"]=> - int(0) - ["weekday"]=> - string(8) "Thursday" - ["month"]=> - string(7) "January" - [0]=> - int(0) -} - ---String 10.5-- -array(11) { - ["seconds"]=> - int(10) - ["minutes"]=> - int(30) - ["hours"]=> - int(5) - ["mday"]=> - int(1) - ["wday"]=> - int(4) - ["mon"]=> - int(1) - ["year"]=> - int(1970) - ["yday"]=> - int(0) - ["weekday"]=> - string(8) "Thursday" - ["month"]=> - string(7) "January" - [0]=> - int(10) -} - ---String -10.5-- -array(11) { - ["seconds"]=> - int(50) - ["minutes"]=> - int(29) - ["hours"]=> - int(5) - ["mday"]=> - int(1) - ["wday"]=> - int(4) - ["mon"]=> - int(1) - ["year"]=> - int(1970) - ["yday"]=> - int(0) - ["weekday"]=> - string(8) "Thursday" - ["month"]=> - string(7) "January" - [0]=> - int(-10) -} diff --git a/ext/date/tests/gmmktime_variation9.phpt b/ext/date/tests/gmmktime_variation9.phpt deleted file mode 100644 index dea8e93fab674..0000000000000 --- a/ext/date/tests/gmmktime_variation9.phpt +++ /dev/null @@ -1,68 +0,0 @@ ---TEST-- -Test gmmktime() function : usage variation - Passing positive and negative float values to arguments 32 bits. ---SKIPIF-- - ---FILE-- - 123456, - 'float -123456' => -123456, - 'float -10.5' => -10.5, -); - -// loop through each element of the array for min -foreach($inputs as $key =>$value) { - echo "\n--$key--\n"; - var_dump( gmmktime($value, $min, $sec, $mon, $day, $year) ); - var_dump( gmmktime($hour, $value, $sec, $mon, $day, $year) ); - var_dump( gmmktime($hour, $min, $value, $mon, $day, $year) ); - var_dump( gmmktime($hour, $min, $sec, $value, $day, $year) ); - var_dump( gmmktime($hour, $min, $sec, $mon, $value, $value) ); -} -?> ---EXPECTF-- -*** Testing gmmktime() : usage variation *** - ---float 123456-- -int(1662595688) -int(1225589768) -int(1218306336) - -Warning: gmmktime(): Epoch doesn't fit in a PHP integer in %s on line %d -bool(false) - -Warning: gmmktime(): Epoch doesn't fit in a PHP integer in %s on line %d -bool(false) - ---float -123456-- -int(773712488) -int(1210775048) -int(1218059424) - -Warning: gmmktime(): Epoch doesn't fit in a PHP integer in %s on line %d -bool(false) - -Warning: gmmktime(): Epoch doesn't fit in a PHP integer in %s on line %d -bool(false) - ---float -10.5-- -int(1218118088) -int(1218181808) -int(1218182870) -int(1170922088) - -Warning: gmmktime(): Epoch doesn't fit in a PHP integer in %s on line %d -bool(false) diff --git a/ext/date/tests/gmmktime_variation9_64bits.phpt b/ext/date/tests/gmmktime_variation9_64bits.phpt deleted file mode 100644 index 9c7e8dcc76c0b..0000000000000 --- a/ext/date/tests/gmmktime_variation9_64bits.phpt +++ /dev/null @@ -1,58 +0,0 @@ ---TEST-- -Test gmmktime() function : usage variation - Passing positive and negative float values to arguments 64 bits. ---SKIPIF-- - ---FILE-- - 123456, - 'float -123456' => -123456, - 'float -10.5' => -10.5, -); - -// loop through each element of the array for min -foreach($inputs as $key =>$value) { - echo "\n--$key--\n"; - var_dump( gmmktime($value, $min, $sec, $mon, $day, $year) ); - var_dump( gmmktime($hour, $value, $sec, $mon, $day, $year) ); - var_dump( gmmktime($hour, $min, $value, $mon, $day, $year) ); - var_dump( gmmktime($hour, $min, $sec, $value, $day, $year) ); - var_dump( gmmktime($hour, $min, $sec, $mon, $value, $value) ); -} -?> ---EXPECT-- - *** Testing gmmktime() : usage variation *** - ---float 123456-- -int(1662595688) -int(1225589768) -int(1218306336) -int(325855037288) -int(3844412784488) - ---float -123456-- -int(773712488) -int(1210775048) -int(1218059424) -int(-323460834712) -int(-3968710530712) - ---float -10.5-- -int(1218118088) -int(1218181808) -int(1218182870) -int(1170922088) -int(-62465356312) diff --git a/ext/imap/tests/imap_fetch_overview_error.phpt b/ext/imap/tests/imap_fetch_overview_error.phpt new file mode 100644 index 0000000000000..7639fca439738 --- /dev/null +++ b/ext/imap/tests/imap_fetch_overview_error.phpt @@ -0,0 +1,31 @@ +--TEST-- +Test imap_fetch_overview() function: invalid option +--SKIPIF-- + +--FILE-- +getMessage() . \PHP_EOL; +} + +?> +--CLEAN-- + +--EXPECT-- +imap_fetch_overview(): Argument #3 ($flags) must be FT_UID or 0 diff --git a/ext/imap/tests/imap_fetch_overview_variation3.phpt b/ext/imap/tests/imap_fetch_overview_variation3.phpt deleted file mode 100644 index 1ed528a17327f..0000000000000 --- a/ext/imap/tests/imap_fetch_overview_variation3.phpt +++ /dev/null @@ -1,70 +0,0 @@ ---TEST-- -Test imap_fetch_overview() function : usage variations - FT_UID option ---SKIPIF-- - ---FILE-- -getMessage() . \PHP_EOL; - } -} - -?> ---CLEAN-- - ---EXPECT-- -*** Testing imap_fetch_overview() : usage variations *** -Create a temporary mailbox and add 1 msgs -New mailbox created - -Testing with option value:string(1) "1" -imap_fetch_overview() returns an object - -Testing with option value:bool(true) -imap_fetch_overview() returns an object - -Testing with option value:float(1.000000000000001) -imap_fetch_overview() returns an object - -Testing with option value:float(1) -imap_fetch_overview() returns an object - -Testing with option value:int(245) -imap_fetch_overview(): Argument #3 ($flags) must be FT_UID or 0 diff --git a/ext/imap/tests/imap_fetchbody_variation4.phpt b/ext/imap/tests/imap_fetchbody_variation4.phpt deleted file mode 100644 index 5e25dd1126b4f..0000000000000 --- a/ext/imap/tests/imap_fetchbody_variation4.phpt +++ /dev/null @@ -1,74 +0,0 @@ ---TEST-- -Test imap_fetchbody() function : usage variations - FT_UID option ---SKIPIF-- - ---FILE-- -getMessage() . \PHP_EOL; - } - $iterator++; -} - -?> ---CLEAN-- - ---EXPECT-- -*** Testing imap_fetchbody() : usage variations *** -Create a temporary mailbox and add 1 msgs -New mailbox created - --- Iteration 1 -- -FT_UID valid - --- Iteration 2 -- -FT_UID valid - --- Iteration 3 -- -FT_UID valid - --- Iteration 4 -- -FT_UID valid - --- Iteration 5 -- -imap_fetchbody(): Argument #4 ($flags) must be a bitmask of FT_UID, FT_PEEK, and FT_INTERNAL - --- Iteration 6 -- -imap_fetchbody(): Argument #4 ($flags) must be a bitmask of FT_UID, FT_PEEK, and FT_INTERNAL diff --git a/ext/imap/tests/imap_fetchheader_variation3.phpt b/ext/imap/tests/imap_fetchheader_variation3.phpt deleted file mode 100644 index 1289087b7d4a6..0000000000000 --- a/ext/imap/tests/imap_fetchheader_variation3.phpt +++ /dev/null @@ -1,71 +0,0 @@ ---TEST-- -Test imap_fetchheader() function : usage variations - FT_UID option ---SKIPIF-- - ---FILE-- -getMessage() . \PHP_EOL; - } - $iterator++; -} -?> ---CLEAN-- - ---EXPECT-- -*** Testing imap_fetchheader() : usage variations *** -Create a temporary mailbox and add 1 msgs -New mailbox created - --- Iteration 1 -- -FT_UID valid - --- Iteration 2 -- -FT_UID valid - --- Iteration 3 -- -FT_UID valid - --- Iteration 4 -- -FT_UID valid - --- Iteration 5 -- -imap_fetchheader(): Argument #3 ($flags) must be a bitmask of FT_UID, FT_PREFETCHTEXT, and FT_INTERNAL - --- Iteration 6 -- -imap_fetchheader(): Argument #3 ($flags) must be a bitmask of FT_UID, FT_PREFETCHTEXT, and FT_INTERNAL diff --git a/ext/intl/tests/collator_get_locale2.phpt b/ext/intl/tests/collator_get_locale2.phpt index e579c015e5f34..cf96130286658 100644 --- a/ext/intl/tests/collator_get_locale2.phpt +++ b/ext/intl/tests/collator_get_locale2.phpt @@ -19,7 +19,6 @@ function ut_main() -100, -9999999999999, 9999999999999, - 1.2, ); $coll = ut_coll_create( 'en_US' ); @@ -48,4 +47,3 @@ Locale of type 100 is false Locale of type -100 is false Locale of type -9999999999999 is false Locale of type 9999999999999 is false -Locale of type 1.2 is 'en_US' diff --git a/ext/posix/tests/posix_ttyname_variation4.phpt b/ext/posix/tests/posix_ttyname_variation4.phpt deleted file mode 100644 index 8664b0dd10e51..0000000000000 --- a/ext/posix/tests/posix_ttyname_variation4.phpt +++ /dev/null @@ -1,40 +0,0 @@ ---TEST-- -Test function posix_ttyname() by substituting argument 1 with float values. ---CREDITS-- -Marco Fabbri mrfabbri@gmail.com -Francesco Fullone ff@ideato.it -#PHPTestFest Cesena Italia on 2009-06-20 ---SKIPIF-- - ---FILE-- - 10.5, - 'float -10.5' => -10.5, - 'float 12.3456789000e10' => 12.3456789000e10, - 'float -12.3456789000e10' => -12.3456789000e10, - 'float .5' => .5, - ); - - -foreach ( $variation_array as $var ) { - var_dump(posix_ttyname( $var ) ); -} -?> ---EXPECT-- -*** Test substituting argument 1 with float values *** -bool(false) -bool(false) -bool(false) -bool(false) -bool(false) diff --git a/ext/spl/tests/SplFixedArray__construct_param_float.phpt b/ext/spl/tests/SplFixedArray__construct_param_float.phpt deleted file mode 100644 index f570289e6c163..0000000000000 --- a/ext/spl/tests/SplFixedArray__construct_param_float.phpt +++ /dev/null @@ -1,14 +0,0 @@ ---TEST-- -SplFixedArray::__construct() with float passed as parameter. ---CREDITS-- -PHPNW Test Fest 2009 - Jordan Hatch ---FILE-- -getSize(); - -?> ---EXPECT-- -3 diff --git a/ext/spl/tests/SplFixedArray_offsetExists_integer.phpt b/ext/spl/tests/SplFixedArray_offsetExists_integer.phpt deleted file mode 100644 index 5ea9d61134b23..0000000000000 --- a/ext/spl/tests/SplFixedArray_offsetExists_integer.phpt +++ /dev/null @@ -1,8 +0,0 @@ ---TEST-- -SplFixedArray::offsetExists with various types ---CREDITS-- -Gabriel Caruso (carusogabriel34@gmail.com) ---FILE-- -offsetExists(0.1)); ?> ---EXPECT-- -bool(false) diff --git a/ext/spl/tests/SplFixedArray_offsetGet_integer.phpt b/ext/spl/tests/SplFixedArray_offsetGet_integer.phpt deleted file mode 100644 index 1408be048535f..0000000000000 --- a/ext/spl/tests/SplFixedArray_offsetGet_integer.phpt +++ /dev/null @@ -1,19 +0,0 @@ ---TEST-- -Using SplFixedArray::offsetGet() with various types ---CREDITS-- -Gabriel Caruso (carusogabriel34@gmail.com) ---FILE-- -offsetGet(0.2)); -var_dump($arr->offsetGet(false)); -var_dump($arr->offsetGet(true)); -?> ---EXPECT-- -string(3) "foo" -string(3) "foo" -string(3) "bar" diff --git a/ext/spl/tests/SplFixedArray_setSize_param_float.phpt b/ext/spl/tests/SplFixedArray_setSize_param_float.phpt deleted file mode 100644 index 7e76485885409..0000000000000 --- a/ext/spl/tests/SplFixedArray_setSize_param_float.phpt +++ /dev/null @@ -1,19 +0,0 @@ ---TEST-- -SplFixedArray::setSize() with a float param ---CREDITS-- -PHPNW Testfest 2009 - Adrian Hardy ---FILE-- -setSize(3.14159); -var_dump($fixed_array); -?> ---EXPECT-- -object(SplFixedArray)#1 (3) { - [0]=> - NULL - [1]=> - NULL - [2]=> - NULL -} diff --git a/ext/standard/tests/math/mt_rand_basic.phpt b/ext/standard/tests/math/mt_rand_basic.phpt index 113ca32ee6968..87a7d2bd4b537 100644 --- a/ext/standard/tests/math/mt_rand_basic.phpt +++ b/ext/standard/tests/math/mt_rand_basic.phpt @@ -9,7 +9,7 @@ for ($i = 0; $i < 100; $i++) { $res = mt_rand(); // By default RAND_MAX is 32768 although no constant is defined for it for user space apps - if (!is_int($res) || $res < 0 || $res > $default_max) { + if ($res < 0 || $res > $default_max) { break; } } @@ -24,14 +24,12 @@ echo "\nmt_rand() tests with defined min and max value\n"; $min = array(10, 100, - 10.5, 10.5e3, 0x10, 0400); $max = array(100, 1000, - 19.5, 10.5e5, 0x10000, 0700); @@ -51,32 +49,6 @@ for ($x = 0; $x < count($min); $x++) { } } -echo "\nNon-numeric cases\n"; -$min = array(true, - false, - "10", - "10.5"); - -// Expected numerical equivalent of above non-numerics -$minval = array(1, - 0, - 0, - 10, - 10); -for ($x = 0; $x < count($min); $x++) { - for ($i = 0; $i < 100; $i++) { - $res = mt_rand($min[$x], 100); - - if (!is_int($res) || $res < intval($minval[$x]) || $res > 100) { - echo "FAILED: res = ", $res, " min = ", intval($min[$x]), " max = ", intval($max[$x]), "\n"; - break; - } - } - - if ($i == 100) { - echo "PASSED range min = ", intval($min[$x]), " max = 100\n"; - } -} ?> --EXPECT-- mt_rand() tests with default min and max value (i.e 0 thru 2147483647) @@ -85,13 +57,7 @@ PASSED: range min = 0 max = 2147483647 mt_rand() tests with defined min and max value PASSED: range min = 10 max = 100 PASSED: range min = 100 max = 1000 -PASSED: range min = 10 max = 19 PASSED: range min = 10500 max = 1050000 PASSED: range min = 16 max = 65536 PASSED: range min = 256 max = 448 -Non-numeric cases -PASSED range min = 1 max = 100 -PASSED range min = 0 max = 100 -PASSED range min = 10 max = 100 -PASSED range min = 10 max = 100 diff --git a/ext/standard/tests/math/rand_basic.phpt b/ext/standard/tests/math/rand_basic.phpt index 06b46b227719f..c3d208ac24f5f 100644 --- a/ext/standard/tests/math/rand_basic.phpt +++ b/ext/standard/tests/math/rand_basic.phpt @@ -9,7 +9,7 @@ for ($i = 0; $i < 100; $i++) { $res = rand(); // By default RAND_MAX is 32768 although no constant is defined for it for user space apps - if (!is_int($res) || $res < 0 || $res > $default_max) { + if ($res < 0 || $res > $default_max) { break; } } @@ -24,14 +24,12 @@ echo "\nrand() tests with defined min and max value\n"; $min = array(10, 100, - 10.5, 10.5e3, 0x10, 0400); $max = array(100, 1000, - 19.5, 10.5e5, 0x10000, 0700); @@ -51,32 +49,6 @@ for ($x = 0; $x < count($min); $x++) { } } -echo "\nNon-numeric cases\n"; -$min = array(true, - false, - "10", - "10.5"); - -// Eexepcted numerical equivalent of above non-numerics -$minval = array(1, - 0, - 0, - 10, - 10); -for ($x = 0; $x < count($min); $x++) { - for ($i = 0; $i < 100; $i++) { - $res = rand($min[$x], 100); - - if (!is_int($res) || $res < intval($minval[$x]) || $res > 100) { - echo "FAILED: res = ", $res, " min = ", intval($min[$x]), " max = ", intval($max[$x]), "\n"; - break; - } - } - - if ($i == 100) { - echo "PASSED range min = ", intval($min[$x]), " max = 100\n"; - } -} ?> --EXPECTF-- rand() tests with default min and max value (i.e 0 thru %i) @@ -85,13 +57,6 @@ PASSED: range min = 0 max = %i rand() tests with defined min and max value PASSED: range min = 10 max = 100 PASSED: range min = 100 max = 1000 -PASSED: range min = 10 max = 19 PASSED: range min = 10500 max = 1050000 PASSED: range min = 16 max = 65536 PASSED: range min = 256 max = 448 - -Non-numeric cases -PASSED range min = 1 max = 100 -PASSED range min = 0 max = 100 -PASSED range min = 10 max = 100 -PASSED range min = 10 max = 100 diff --git a/ext/xml/tests/xml_parser_set_option_variation3.phpt b/ext/xml/tests/xml_parser_set_option_variation3.phpt deleted file mode 100644 index a6b3a9b6ecab4..0000000000000 --- a/ext/xml/tests/xml_parser_set_option_variation3.phpt +++ /dev/null @@ -1,170 +0,0 @@ ---TEST-- -Test xml_parser_set_option() function : usage variations ---SKIPIF-- - ---FILE-- - 'red', 'item' => 'pen'), - - // null data - NULL, - null, - - // boolean data - true, - false, - TRUE, - FALSE, - - // empty data - "", - '', - - // string data - "string", - 'string', - - // object data - new aClass(), - - // resource data - $fp, -); - -// loop through each element of the array for value - -foreach($values as $value) { - echo @"\nArg value $value \n"; - var_dump(xml_parser_set_option($parser, $option, $value)); -} - -fclose($fp); -xml_parser_free($parser); -echo "Done"; -?> ---EXPECTF-- -*** Testing xml_parser_set_option() : usage variations *** - -Arg value 0 -bool(true) - -Arg value 1 -bool(true) - -Arg value 12345 -bool(true) - -Arg value -2345 -bool(true) - -Arg value 10.5 -bool(true) - -Arg value -10.5 -bool(true) - -Arg value 101234567000 -bool(true) - -Arg value 1.07654321E-9 -bool(true) - -Arg value 0.5 -bool(true) - -Arg value Array -bool(true) - -Arg value Array -bool(true) - -Arg value Array -bool(true) - -Arg value Array -bool(true) - -Arg value Array -bool(true) - -Arg value -bool(true) - -Arg value -bool(true) - -Arg value 1 -bool(true) - -Arg value -bool(true) - -Arg value 1 -bool(true) - -Arg value -bool(true) - -Arg value -bool(true) - -Arg value -bool(true) - -Arg value string -bool(true) - -Arg value string -bool(true) - -Arg value Some Ascii Data - -Warning: Object of class aClass could not be converted to int in %s on line %d -bool(true) - -Arg value Resource id %s -bool(true) -Done diff --git a/ext/zlib/tests/gzfile_variation11.phpt b/ext/zlib/tests/gzfile_variation11.phpt deleted file mode 100644 index 2d0c73e647d6f..0000000000000 --- a/ext/zlib/tests/gzfile_variation11.phpt +++ /dev/null @@ -1,128 +0,0 @@ ---TEST-- -Test function gzfile() by substituting argument 2 with float values. ---SKIPIF-- - ---FILE-- - 10.5, - 'float -10.5' => -10.5, - 'float 12.3456789000e10' => 12.3456789000e10, - 'float -12.3456789000e10' => -12.3456789000e10, - 'float .5' => .5, - ); - - -foreach ( $variation as $var ) { - var_dump(gzfile( $filename, $var ) ); -} -?> ---EXPECT-- -array(6) { - [0]=> - string(36) "When you're taught through feelings -" - [1]=> - string(26) "Destiny flying high above -" - [2]=> - string(38) "all I know is that you can realize it -" - [3]=> - string(18) "Destiny who cares -" - [4]=> - string(19) "as it turns around -" - [5]=> - string(39) "and I know that it descends down on me -" -} -array(6) { - [0]=> - string(36) "When you're taught through feelings -" - [1]=> - string(26) "Destiny flying high above -" - [2]=> - string(38) "all I know is that you can realize it -" - [3]=> - string(18) "Destiny who cares -" - [4]=> - string(19) "as it turns around -" - [5]=> - string(39) "and I know that it descends down on me -" -} -array(6) { - [0]=> - string(36) "When you're taught through feelings -" - [1]=> - string(26) "Destiny flying high above -" - [2]=> - string(38) "all I know is that you can realize it -" - [3]=> - string(18) "Destiny who cares -" - [4]=> - string(19) "as it turns around -" - [5]=> - string(39) "and I know that it descends down on me -" -} -array(6) { - [0]=> - string(36) "When you're taught through feelings -" - [1]=> - string(26) "Destiny flying high above -" - [2]=> - string(38) "all I know is that you can realize it -" - [3]=> - string(18) "Destiny who cares -" - [4]=> - string(19) "as it turns around -" - [5]=> - string(39) "and I know that it descends down on me -" -} -array(6) { - [0]=> - string(36) "When you're taught through feelings -" - [1]=> - string(26) "Destiny flying high above -" - [2]=> - string(38) "all I know is that you can realize it -" - [3]=> - string(18) "Destiny who cares -" - [4]=> - string(19) "as it turns around -" - [5]=> - string(39) "and I know that it descends down on me -" -} diff --git a/ext/zlib/tests/readgzfile_variation11.phpt b/ext/zlib/tests/readgzfile_variation11.phpt deleted file mode 100644 index 15807926a97c3..0000000000000 --- a/ext/zlib/tests/readgzfile_variation11.phpt +++ /dev/null @@ -1,63 +0,0 @@ ---TEST-- -Test function readgzfile() by substituting argument 2 with float values. ---SKIPIF-- - ---FILE-- - 10.5, - 'float -10.5' => -10.5, - 'float 12.3456789000e10' => 12.3456789000e10, - 'float -12.3456789000e10' => -12.3456789000e10, - 'float .5' => .5, - ); - - -foreach ( $variation as $var ) { - var_dump(readgzfile( $filename, $var ) ); -} -?> ---EXPECT-- -When you're taught through feelings -Destiny flying high above -all I know is that you can realize it -Destiny who cares -as it turns around -and I know that it descends down on me -int(176) -When you're taught through feelings -Destiny flying high above -all I know is that you can realize it -Destiny who cares -as it turns around -and I know that it descends down on me -int(176) -When you're taught through feelings -Destiny flying high above -all I know is that you can realize it -Destiny who cares -as it turns around -and I know that it descends down on me -int(176) -When you're taught through feelings -Destiny flying high above -all I know is that you can realize it -Destiny who cares -as it turns around -and I know that it descends down on me -int(176) -When you're taught through feelings -Destiny flying high above -all I know is that you can realize it -Destiny who cares -as it turns around -and I know that it descends down on me -int(176) From 4963bf3964c0648db0c17b37b3825b783fcc48f8 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sat, 20 Mar 2021 04:42:44 +0000 Subject: [PATCH 06/61] Add incompatible float to deprecation message --- Zend/tests/array_offset.phpt | 4 +- Zend/tests/bug72347.phpt | 2 +- Zend/tests/constant_expressions_dynamic.phpt | 2 +- Zend/tests/empty_str_offset.phpt | 18 +-- .../union_int_string_type_arg.phpt | 2 +- ...g_float_does_not_fit_zend_long_arrays.phpt | 8 +- .../float_to_int/warnings_float_literals.phpt | 32 ++--- ...arnings_float_literals_assignment_ops.phpt | 12 +- .../float_to_int/warnings_float_vars.phpt | 36 ++--- .../warnings_string_float_literals.phpt | 26 ++-- ..._string_float_literals_assignment_ops.phpt | 12 +- .../warnings_string_float_vars.phpt | 30 ++-- Zend/tests/isset_array.phpt | 2 +- Zend/tests/isset_str_offset.phpt | 16 +-- Zend/tests/list_keyed_conversions.phpt | 2 +- Zend/tests/not_001.phpt | 2 +- Zend/tests/offset_array.phpt | 2 +- Zend/tests/operator_unsupported_types.phpt | 84 +++++------ .../tests/type_declarations/scalar_basic.phpt | 2 +- .../scalar_return_basic_64bit.phpt | 2 +- Zend/zend_API.c | 5 +- Zend/zend_operators.c | 10 +- Zend/zend_operators.h | 2 +- ext/imap/tests/imap_fetch_overview_error.phpt | 31 ---- ...titute_character_variation_weak_types.phpt | 8 +- ext/session/tests/session_encode_error2.phpt | 8 ++ .../iterator_to_array_nonscalar_keys.phpt | 2 +- .../tests/array/array_column_basic.phpt | 4 + .../tests/array/array_combine_variation4.phpt | 2 + ext/standard/tests/array/array_fill.phpt | 134 ++++++++++++++---- .../array_intersect_assoc_variation5.phpt | 4 +- .../array_intersect_assoc_variation6.phpt | 4 +- .../array/array_intersect_variation5.phpt | 4 +- .../array/array_intersect_variation6.phpt | 4 +- .../array/array_key_exists_variation3.phpt | 8 +- .../tests/array/array_map_variation4.phpt | 2 + .../tests/array/array_reverse_variation4.phpt | 2 + .../tests/array/array_unshift_variation4.phpt | 2 + ext/standard/tests/array/bug68553.phpt | 2 + .../tests/array/usort_variation3.phpt | 4 +- .../tests/file/disk_free_space_basic.phpt | 2 +- .../general_functions/intval_variation1.phpt | 10 ++ ext/standard/tests/math/bug75170.phpt | 2 +- ext/standard/tests/math/decbin_basic.phpt | 10 +- .../tests/math/decbin_variation1_64bit.phpt | 10 +- ext/standard/tests/math/dechex_basic.phpt | 10 +- .../tests/math/dechex_variation1_64bit.phpt | 10 +- ext/standard/tests/math/decoct_basic.phpt | 10 +- .../tests/math/decoct_variation1_64bit.phpt | 10 +- ext/standard/tests/math/mt_srand_basic.phpt | 4 +- ext/standard/tests/math/round_basic.phpt | 38 ++++- ext/standard/tests/math/srand_basic.phpt | 4 +- ext/standard/tests/streams/bug72075.phpt | 3 +- ext/standard/tests/strings/bug47842.phpt | 4 +- .../tests/strings/chr_variation1.phpt | 6 +- .../strings/chunk_split_variation10.phpt | 32 ++++- .../tests/strings/fprintf_variation_002.phpt | 34 ++++- .../strings/fprintf_variation_003_64bit.phpt | 6 +- .../strings/fprintf_variation_006_64bit.phpt | 6 +- .../strings/fprintf_variation_007_64bit.phpt | 6 +- .../strings/fprintf_variation_008_64bit.phpt | 6 +- ext/standard/tests/strings/printf_64bit.phpt | 48 +++++++ .../strings/vprintf_variation12_64bit.phpt | 30 +++- .../strings/vprintf_variation14_64bit.phpt | 30 +++- .../strings/vprintf_variation15_64bit.phpt | 4 +- .../strings/vprintf_variation16_64bit.phpt | 30 +++- .../strings/vprintf_variation4_64bit.phpt | 30 +++- .../operators/bitwiseNot_basiclong_64bit.phpt | 4 +- 68 files changed, 685 insertions(+), 252 deletions(-) delete mode 100644 ext/imap/tests/imap_fetch_overview_error.phpt diff --git a/Zend/tests/array_offset.phpt b/Zend/tests/array_offset.phpt index 657f3b41d4087..f3e9955ca0852 100644 --- a/Zend/tests/array_offset.phpt +++ b/Zend/tests/array_offset.phpt @@ -13,13 +13,13 @@ echo "Done\n"; --EXPECTF-- Warning: Undefined array key -1 in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float -1.100000 in %s on line %d Warning: Undefined array key -1 in %s on line %d Warning: Undefined array key -1 in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float -1.100000 in %s on line %d Warning: Undefined array key -1 in %s on line %d Done diff --git a/Zend/tests/bug72347.phpt b/Zend/tests/bug72347.phpt index 100ff51fb70e5..7ad5bd526fa0d 100644 --- a/Zend/tests/bug72347.phpt +++ b/Zend/tests/bug72347.phpt @@ -13,6 +13,6 @@ function test() : int { var_dump(test()); ?> --EXPECTF-- -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d float(1.5) int(1) diff --git a/Zend/tests/constant_expressions_dynamic.phpt b/Zend/tests/constant_expressions_dynamic.phpt index 2dfb75f7bab8a..c80a5e4e5f8e1 100644 --- a/Zend/tests/constant_expressions_dynamic.phpt +++ b/Zend/tests/constant_expressions_dynamic.phpt @@ -47,7 +47,7 @@ var_dump( --EXPECTF-- Warning: A non-numeric value encountered in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 3.140000 in %s on line %d int(3) string(4) "1foo" bool(false) diff --git a/Zend/tests/empty_str_offset.phpt b/Zend/tests/empty_str_offset.phpt index 77723dfa614e4..3fc6e290ab5c8 100644 --- a/Zend/tests/empty_str_offset.phpt +++ b/Zend/tests/empty_str_offset.phpt @@ -99,31 +99,31 @@ bool(true) bool(false) - double --- -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float -1.100000 in %s on line %d bool(false) -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float -10.500000 in %s on line %d bool(true) -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float -4.100000 in %s on line %d bool(true) -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float -0.800000 in %s on line %d bool(false) -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float -0.100000 in %s on line %d bool(false) -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 0.200000 in %s on line %d bool(false) -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 0.900000 in %s on line %d bool(false) -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 3.141593 in %s on line %d bool(false) -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 100.500100 in %s on line %d bool(true) - array --- bool(true) diff --git a/Zend/tests/float_to_int/union_int_string_type_arg.phpt b/Zend/tests/float_to_int/union_int_string_type_arg.phpt index 799328d60213e..112a2cd9fc3c1 100644 --- a/Zend/tests/float_to_int/union_int_string_type_arg.phpt +++ b/Zend/tests/float_to_int/union_int_string_type_arg.phpt @@ -21,7 +21,7 @@ foo(10e500); // Infinity --EXPECTF-- int(1) -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d int(1) string(3) "NAN" string(8) "1.0E+121" diff --git a/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_arrays.phpt b/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_arrays.phpt index 0ec518b646883..01f329806d5cb 100644 --- a/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_arrays.phpt +++ b/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_arrays.phpt @@ -26,9 +26,9 @@ var_dump($array[$string_float]); int(0) int(9223372036854775807) -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 10000000000000000373409337471459889719393275754491820381027730410378005080671497101378613371421126415052399029342192009216.000000 in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 10000000000000000373409337471459889719393275754491820381027730410378005080671497101378613371421126415052399029342192009216.000000 in %s on line %d array(2) { [0]=> string(11) "Large float" @@ -42,13 +42,13 @@ array(2) { string(18) "String large float" } -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 10000000000000000373409337471459889719393275754491820381027730410378005080671497101378613371421126415052399029342192009216.000000 in %s on line %d string(1) "0" Warning: Undefined array key "1.0E+121" in %s on line %d NULL -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 10000000000000000373409337471459889719393275754491820381027730410378005080671497101378613371421126415052399029342192009216.000000 in %s on line %d string(1) "0" Warning: Undefined array key "1.0E+121" in %s on line %d diff --git a/Zend/tests/float_to_int/warnings_float_literals.phpt b/Zend/tests/float_to_int/warnings_float_literals.phpt index ea73ef82c969b..b0cc8a684d81b 100644 --- a/Zend/tests/float_to_int/warnings_float_literals.phpt +++ b/Zend/tests/float_to_int/warnings_float_literals.phpt @@ -69,25 +69,25 @@ var_dump($instance->a); ?> --EXPECTF-- -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 6.500000 in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d Bitwise ops: int(-2) int(3) @@ -103,10 +103,10 @@ int(1) Offset access: Arrays: -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d string(1) "b" -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d array(3) { [0]=> string(1) "a" @@ -124,16 +124,16 @@ Warning: String offset cast occurred in %s on line %d string(3) "phz" Function calls: -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d int(1) -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 60.500000 in %s on line %d string(1) "<" Function returns: -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 3.500000 in %s on line %d int(3) Typed property assignment: -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d int(1) diff --git a/Zend/tests/float_to_int/warnings_float_literals_assignment_ops.phpt b/Zend/tests/float_to_int/warnings_float_literals_assignment_ops.phpt index f309961e68495..25663038ce674 100644 --- a/Zend/tests/float_to_int/warnings_float_literals_assignment_ops.phpt +++ b/Zend/tests/float_to_int/warnings_float_literals_assignment_ops.phpt @@ -34,21 +34,21 @@ var_dump($var); --EXPECTF-- Bitwise ops: -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d int(3) -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d int(1) -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d int(2) -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d int(6) -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d int(1) Modulo: -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d int(1) diff --git a/Zend/tests/float_to_int/warnings_float_vars.phpt b/Zend/tests/float_to_int/warnings_float_vars.phpt index 2c4692c8d85cb..fe63c75b66104 100644 --- a/Zend/tests/float_to_int/warnings_float_vars.phpt +++ b/Zend/tests/float_to_int/warnings_float_vars.phpt @@ -93,49 +93,49 @@ var_dump($instance->a); --EXPECTF-- Bitwise ops: -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d int(-2) -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d int(3) -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d int(1) -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d int(2) -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d int(8) -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d int(0) -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d int(8) -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d int(0) -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d int(6) -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d int(1) Modulo: -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 6.500000 in %s on line %d int(0) -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d int(1) Offset access: Arrays: -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d string(1) "b" -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d array(3) { [0]=> string(1) "a" @@ -153,16 +153,16 @@ Warning: String offset cast occurred in %s on line %d string(3) "phz" Function calls: -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d int(1) -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 60.500000 in %s on line %d string(1) "<" Function returns: -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 3.500000 in %s on line %d int(3) Typed property assignment: -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d int(1) diff --git a/Zend/tests/float_to_int/warnings_string_float_literals.phpt b/Zend/tests/float_to_int/warnings_string_float_literals.phpt index 8bf5f7ac984ef..73a113b5d342c 100644 --- a/Zend/tests/float_to_int/warnings_string_float_literals.phpt +++ b/Zend/tests/float_to_int/warnings_string_float_literals.phpt @@ -52,23 +52,23 @@ var_dump($instance->a); ?> --EXPECTF-- -Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float-string 6.5 in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float-string 2.5 in %s on line %d Bitwise ops: int(3) int(1) @@ -82,16 +82,16 @@ int(0) int(1) Function calls: -Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d int(1) -Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float-string 60.5 in %s on line %d string(1) "<" Function returns: -Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float-string 3.5 in %s on line %d int(3) Typed property assignment: -Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d int(1) diff --git a/Zend/tests/float_to_int/warnings_string_float_literals_assignment_ops.phpt b/Zend/tests/float_to_int/warnings_string_float_literals_assignment_ops.phpt index f203dde2e8d4d..dbb9d019154a3 100644 --- a/Zend/tests/float_to_int/warnings_string_float_literals_assignment_ops.phpt +++ b/Zend/tests/float_to_int/warnings_string_float_literals_assignment_ops.phpt @@ -34,21 +34,21 @@ var_dump($var); --EXPECTF-- Bitwise ops: -Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d int(3) -Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d int(1) -Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d int(2) -Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d int(6) -Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d int(1) Modulo: -Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float-string 2.5 in %s on line %d int(1) diff --git a/Zend/tests/float_to_int/warnings_string_float_vars.phpt b/Zend/tests/float_to_int/warnings_string_float_vars.phpt index f2489cc800f8b..557468998e237 100644 --- a/Zend/tests/float_to_int/warnings_string_float_vars.phpt +++ b/Zend/tests/float_to_int/warnings_string_float_vars.phpt @@ -74,51 +74,51 @@ var_dump($instance->a); --EXPECTF-- Bitwise ops: -Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d int(3) -Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d int(1) -Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d int(2) -Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d int(8) -Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d int(0) -Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d int(8) -Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d int(0) -Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d int(6) -Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d int(1) Modulo: -Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float-string 6.5 in %s on line %d int(0) -Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float-string 2.5 in %s on line %d int(1) Function calls: -Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d int(1) -Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float-string 60.5 in %s on line %d string(1) "<" Function returns: -Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float-string 3.5 in %s on line %d int(3) Typed property assignment: -Deprecated: Implicit conversion to int from non-compatible float-string in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d int(1) diff --git a/Zend/tests/isset_array.phpt b/Zend/tests/isset_array.phpt index 83db3d640d07c..91fd76bff0c04 100644 --- a/Zend/tests/isset_array.phpt +++ b/Zend/tests/isset_array.phpt @@ -39,7 +39,7 @@ bool(true) bool(true) bool(true) -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 0.600000 in %s on line %d bool(true) bool(false) bool(false) diff --git a/Zend/tests/isset_str_offset.phpt b/Zend/tests/isset_str_offset.phpt index 98867f8b23d2c..5e31f3bb02c2d 100644 --- a/Zend/tests/isset_str_offset.phpt +++ b/Zend/tests/isset_str_offset.phpt @@ -96,28 +96,28 @@ bool(false) bool(true) - double --- -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float -1.100000 in %s on line %d bool(true) -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float -10.500000 in %s on line %d bool(false) -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float -0.800000 in %s on line %d bool(true) -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float -0.100000 in %s on line %d bool(true) -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 0.200000 in %s on line %d bool(true) -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 0.900000 in %s on line %d bool(true) -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 3.141593 in %s on line %d bool(true) -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 100.500100 in %s on line %d bool(false) - array --- bool(false) diff --git a/Zend/tests/list_keyed_conversions.phpt b/Zend/tests/list_keyed_conversions.phpt index 6e13d5c7078e4..129e7cd0cf0f0 100644 --- a/Zend/tests/list_keyed_conversions.phpt +++ b/Zend/tests/list_keyed_conversions.phpt @@ -21,7 +21,7 @@ list(STDIN => $resource) = []; ?> --EXPECTF-- -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d string(0) "" int(1) int(0) diff --git a/Zend/tests/not_001.phpt b/Zend/tests/not_001.phpt index 8307c0d2aead5..e5b6368168525 100644 --- a/Zend/tests/not_001.phpt +++ b/Zend/tests/not_001.phpt @@ -17,7 +17,7 @@ var_dump(bin2hex($s1)); echo "Done\n"; ?> --EXPECTF-- -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 23.670000 in %s on line %d int(-24) string(8) "8c90929a" Done diff --git a/Zend/tests/offset_array.phpt b/Zend/tests/offset_array.phpt index 343107b1182ce..08a2b47cd326b 100644 --- a/Zend/tests/offset_array.phpt +++ b/Zend/tests/offset_array.phpt @@ -35,7 +35,7 @@ echo "Done\n"; --EXPECTF-- int(2) -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 0.083600 in %s on line %d int(1) Warning: Undefined array key "" in %s on line %d diff --git a/Zend/tests/operator_unsupported_types.phpt b/Zend/tests/operator_unsupported_types.phpt index 10c521024dff6..030750022aa3c 100644 --- a/Zend/tests/operator_unsupported_types.phpt +++ b/Zend/tests/operator_unsupported_types.phpt @@ -453,7 +453,7 @@ Unsupported operand types: bool % array Unsupported operand types: array % int Unsupported operand types: int % array Unsupported operand types: array % float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float % array Unsupported operand types: array % string Unsupported operand types: string % array @@ -469,7 +469,7 @@ Unsupported operand types: bool % stdClass Unsupported operand types: stdClass % int Unsupported operand types: int % stdClass Unsupported operand types: stdClass % float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float % stdClass Unsupported operand types: stdClass % string Unsupported operand types: string % stdClass @@ -485,7 +485,7 @@ Unsupported operand types: bool % resource Unsupported operand types: resource % int Unsupported operand types: int % resource Unsupported operand types: resource % float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float % resource Unsupported operand types: resource % string Unsupported operand types: string % resource @@ -501,7 +501,7 @@ Unsupported operand types: bool % string Unsupported operand types: string % int Unsupported operand types: int % string Unsupported operand types: string % float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float % string Unsupported operand types: string % string Unsupported operand types: string % string @@ -609,7 +609,7 @@ Unsupported operand types: bool << array Unsupported operand types: array << int Unsupported operand types: int << array Unsupported operand types: array << float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float << array Unsupported operand types: array << string Unsupported operand types: string << array @@ -625,7 +625,7 @@ Unsupported operand types: bool << stdClass Unsupported operand types: stdClass << int Unsupported operand types: int << stdClass Unsupported operand types: stdClass << float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float << stdClass Unsupported operand types: stdClass << string Unsupported operand types: string << stdClass @@ -641,7 +641,7 @@ Unsupported operand types: bool << resource Unsupported operand types: resource << int Unsupported operand types: int << resource Unsupported operand types: resource << float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float << resource Unsupported operand types: resource << string Unsupported operand types: string << resource @@ -657,7 +657,7 @@ Unsupported operand types: bool << string Unsupported operand types: string << int Unsupported operand types: int << string Unsupported operand types: string << float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float << string Unsupported operand types: string << string Unsupported operand types: string << string @@ -689,7 +689,7 @@ Unsupported operand types: bool >> array Unsupported operand types: array >> int Unsupported operand types: int >> array Unsupported operand types: array >> float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float >> array Unsupported operand types: array >> string Unsupported operand types: string >> array @@ -705,7 +705,7 @@ Unsupported operand types: bool >> stdClass Unsupported operand types: stdClass >> int Unsupported operand types: int >> stdClass Unsupported operand types: stdClass >> float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float >> stdClass Unsupported operand types: stdClass >> string Unsupported operand types: string >> stdClass @@ -721,7 +721,7 @@ Unsupported operand types: bool >> resource Unsupported operand types: resource >> int Unsupported operand types: int >> resource Unsupported operand types: resource >> float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float >> resource Unsupported operand types: resource >> string Unsupported operand types: string >> resource @@ -737,7 +737,7 @@ Unsupported operand types: bool >> string Unsupported operand types: string >> int Unsupported operand types: int >> string Unsupported operand types: string >> float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float >> string Unsupported operand types: string >> string Unsupported operand types: string >> string @@ -769,7 +769,7 @@ Unsupported operand types: bool & array Unsupported operand types: array & int Unsupported operand types: int & array Unsupported operand types: array & float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float & array Unsupported operand types: array & string Unsupported operand types: string & array @@ -813,7 +813,7 @@ Unsupported operand types: bool & string Unsupported operand types: string & int Unsupported operand types: int & string Unsupported operand types: string & float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float & string No error for "foo" & "123" No error for "123" & "foo" @@ -844,7 +844,7 @@ Unsupported operand types: bool | array Unsupported operand types: array | int Unsupported operand types: int | array Unsupported operand types: array | float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float | array Unsupported operand types: array | string Unsupported operand types: string | array @@ -888,7 +888,7 @@ Unsupported operand types: bool | string Unsupported operand types: string | int Unsupported operand types: int | string Unsupported operand types: string | float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float | string No error for "foo" | "123" No error for "123" | "foo" @@ -919,7 +919,7 @@ Unsupported operand types: bool ^ array Unsupported operand types: array ^ int Unsupported operand types: int ^ array Unsupported operand types: array ^ float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float ^ array Unsupported operand types: array ^ string Unsupported operand types: string ^ array @@ -963,7 +963,7 @@ Unsupported operand types: bool ^ string Unsupported operand types: string ^ int Unsupported operand types: int ^ string Unsupported operand types: string ^ float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float ^ string No error for "foo" ^ "123" No error for "123" ^ "foo" @@ -1467,7 +1467,7 @@ Unsupported operand types: bool % array Unsupported operand types: array % int Unsupported operand types: int % array Unsupported operand types: array % float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float % array Unsupported operand types: array % string Unsupported operand types: string % array @@ -1483,7 +1483,7 @@ Unsupported operand types: bool % stdClass Unsupported operand types: stdClass % int Unsupported operand types: int % stdClass Unsupported operand types: stdClass % float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float % stdClass Unsupported operand types: stdClass % string Unsupported operand types: string % stdClass @@ -1499,7 +1499,7 @@ Unsupported operand types: bool % resource Unsupported operand types: resource % int Unsupported operand types: int % resource Unsupported operand types: resource % float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float % resource Unsupported operand types: resource % string Unsupported operand types: string % resource @@ -1515,7 +1515,7 @@ Unsupported operand types: bool % string Unsupported operand types: string % int Unsupported operand types: int % string Unsupported operand types: string % float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float % string Unsupported operand types: string % string Unsupported operand types: string % string @@ -1623,7 +1623,7 @@ Unsupported operand types: bool << array Unsupported operand types: array << int Unsupported operand types: int << array Unsupported operand types: array << float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float << array Unsupported operand types: array << string Unsupported operand types: string << array @@ -1639,7 +1639,7 @@ Unsupported operand types: bool << stdClass Unsupported operand types: stdClass << int Unsupported operand types: int << stdClass Unsupported operand types: stdClass << float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float << stdClass Unsupported operand types: stdClass << string Unsupported operand types: string << stdClass @@ -1655,7 +1655,7 @@ Unsupported operand types: bool << resource Unsupported operand types: resource << int Unsupported operand types: int << resource Unsupported operand types: resource << float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float << resource Unsupported operand types: resource << string Unsupported operand types: string << resource @@ -1671,7 +1671,7 @@ Unsupported operand types: bool << string Unsupported operand types: string << int Unsupported operand types: int << string Unsupported operand types: string << float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float << string Unsupported operand types: string << string Unsupported operand types: string << string @@ -1703,7 +1703,7 @@ Unsupported operand types: bool >> array Unsupported operand types: array >> int Unsupported operand types: int >> array Unsupported operand types: array >> float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float >> array Unsupported operand types: array >> string Unsupported operand types: string >> array @@ -1719,7 +1719,7 @@ Unsupported operand types: bool >> stdClass Unsupported operand types: stdClass >> int Unsupported operand types: int >> stdClass Unsupported operand types: stdClass >> float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float >> stdClass Unsupported operand types: stdClass >> string Unsupported operand types: string >> stdClass @@ -1735,7 +1735,7 @@ Unsupported operand types: bool >> resource Unsupported operand types: resource >> int Unsupported operand types: int >> resource Unsupported operand types: resource >> float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float >> resource Unsupported operand types: resource >> string Unsupported operand types: string >> resource @@ -1751,7 +1751,7 @@ Unsupported operand types: bool >> string Unsupported operand types: string >> int Unsupported operand types: int >> string Unsupported operand types: string >> float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float >> string Unsupported operand types: string >> string Unsupported operand types: string >> string @@ -1783,7 +1783,7 @@ Unsupported operand types: bool & array Unsupported operand types: array & int Unsupported operand types: int & array Unsupported operand types: array & float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float & array Unsupported operand types: array & string Unsupported operand types: string & array @@ -1799,7 +1799,7 @@ Unsupported operand types: bool & stdClass Unsupported operand types: stdClass & int Unsupported operand types: int & stdClass Unsupported operand types: stdClass & float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float & stdClass Unsupported operand types: stdClass & string Unsupported operand types: string & stdClass @@ -1815,7 +1815,7 @@ Unsupported operand types: bool & resource Unsupported operand types: resource & int Unsupported operand types: int & resource Unsupported operand types: resource & float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float & resource Unsupported operand types: resource & string Unsupported operand types: string & resource @@ -1831,7 +1831,7 @@ Unsupported operand types: bool & string Unsupported operand types: string & int Unsupported operand types: int & string Unsupported operand types: string & float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float & string No error for "foo" &= "123" No error for "123" &= "foo" @@ -1862,7 +1862,7 @@ Unsupported operand types: bool | array Unsupported operand types: array | int Unsupported operand types: int | array Unsupported operand types: array | float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float | array Unsupported operand types: array | string Unsupported operand types: string | array @@ -1878,7 +1878,7 @@ Unsupported operand types: bool | stdClass Unsupported operand types: stdClass | int Unsupported operand types: int | stdClass Unsupported operand types: stdClass | float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float | stdClass Unsupported operand types: stdClass | string Unsupported operand types: string | stdClass @@ -1894,7 +1894,7 @@ Unsupported operand types: bool | resource Unsupported operand types: resource | int Unsupported operand types: int | resource Unsupported operand types: resource | float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float | resource Unsupported operand types: resource | string Unsupported operand types: string | resource @@ -1910,7 +1910,7 @@ Unsupported operand types: bool | string Unsupported operand types: string | int Unsupported operand types: int | string Unsupported operand types: string | float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float | string No error for "foo" |= "123" No error for "123" |= "foo" @@ -1941,7 +1941,7 @@ Unsupported operand types: bool ^ array Unsupported operand types: array ^ int Unsupported operand types: int ^ array Unsupported operand types: array ^ float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float ^ array Unsupported operand types: array ^ string Unsupported operand types: string ^ array @@ -1957,7 +1957,7 @@ Unsupported operand types: bool ^ stdClass Unsupported operand types: stdClass ^ int Unsupported operand types: int ^ stdClass Unsupported operand types: stdClass ^ float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float ^ stdClass Unsupported operand types: stdClass ^ string Unsupported operand types: string ^ stdClass @@ -1973,7 +1973,7 @@ Unsupported operand types: bool ^ resource Unsupported operand types: resource ^ int Unsupported operand types: int ^ resource Unsupported operand types: resource ^ float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float ^ resource Unsupported operand types: resource ^ string Unsupported operand types: string ^ resource @@ -1989,7 +1989,7 @@ Unsupported operand types: bool ^ string Unsupported operand types: string ^ int Unsupported operand types: int ^ string Unsupported operand types: string ^ float -Warning: Implicit conversion to int from non-compatible float +Warning: Implicit conversion to int from non-compatible float 3.500000 Unsupported operand types: float ^ string No error for "foo" ^= "123" No error for "123" ^= "foo" diff --git a/Zend/tests/type_declarations/scalar_basic.phpt b/Zend/tests/type_declarations/scalar_basic.phpt index 8b3865efa7dc7..ad23ee67a25a2 100644 --- a/Zend/tests/type_declarations/scalar_basic.phpt +++ b/Zend/tests/type_declarations/scalar_basic.phpt @@ -72,7 +72,7 @@ int(1) int(1) *** Trying float(1.5) -E_DEPRECATED: Implicit conversion to int from non-compatible float on line %d +E_DEPRECATED: Implicit conversion to int from non-compatible float 1.500000 on line 14 int(1) *** Trying string(2) "1a" diff --git a/Zend/tests/type_declarations/scalar_return_basic_64bit.phpt b/Zend/tests/type_declarations/scalar_return_basic_64bit.phpt index f9622dbca68bd..148f28afeacf7 100644 --- a/Zend/tests/type_declarations/scalar_return_basic_64bit.phpt +++ b/Zend/tests/type_declarations/scalar_return_basic_64bit.phpt @@ -71,7 +71,7 @@ int(1) *** Trying float(1) int(1) *** Trying float(1.5) -E_DEPRECATED: Implicit conversion to int from non-compatible float on line %d +E_DEPRECATED: Implicit conversion to int from non-compatible float 1.500000 on line 14 int(1) *** Trying string(2) "1a" *** Caught {closure}(): Return value must be of type int, string returned in %s on line %d diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 2f538c6f0d5fe..8e811dc849d2d 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -506,7 +506,7 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest, /* Manually check arg_num is not (uint32_t)-1, as otherwise its called by * zend_verify_weak_scalar_type_hint_no_sideeffect() */ if (UNEXPECTED(!is_long_compatible(Z_DVAL_P(arg)) && arg_num != (uint32_t)-1)) { - zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float"); + zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float %f", Z_DVAL_P(arg)); if (UNEXPECTED(EG(exception))) { return 0; } @@ -531,7 +531,8 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest, * Check arg_num is not (uint32_t)-1, as otherwise its called by * zend_verify_weak_scalar_type_hint_no_sideeffect() */ if (UNEXPECTED(!is_long_compatible(d) && arg_num != (uint32_t)-1)) { - zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float-string"); + zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float-string %s", + Z_STRVAL_P(arg)); if (UNEXPECTED(EG(exception))) { return 0; } diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index ceda8892e1b35..2bf7131a741b5 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -305,7 +305,7 @@ static zend_never_inline zend_long ZEND_FASTCALL zendi_try_get_long(zval *op, bo return 1; case IS_DOUBLE: if (!is_long_compatible(Z_DVAL_P(op))) { - zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float"); + zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float %f", Z_DVAL_P(op)); if (UNEXPECTED(EG(exception))) { *failed = 1; } @@ -340,7 +340,8 @@ static zend_never_inline zend_long ZEND_FASTCALL zendi_try_get_long(zval *op, bo * behaviour. */ if (!is_long_compatible(dval)) { - zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float-string"); + zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float-string %s", + Z_STRVAL_P(op)); if (UNEXPECTED(EG(exception))) { *failed = 1; } @@ -822,7 +823,7 @@ ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op, bool is_lax) /* {{ case IS_DOUBLE: if (EXPECTED(!is_lax)) { if (!is_long_compatible(Z_DVAL_P(op))) { - zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float"); + zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float %f", Z_DVAL_P(op)); // TODO Need to handle this here? //if (UNEXPECTED(EG(exception))) {} } @@ -846,7 +847,8 @@ ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op, bool is_lax) /* {{ /* Most usages are expected to not be (int) casts */ if (EXPECTED(!is_lax)) { if (!is_long_compatible(dval)) { - zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float-string"); + zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float-string %s", + Z_STRVAL_P(op)); // TODO Need to handle this here? //if (UNEXPECTED(EG(exception))) {} } diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index c7e7ff9bbda85..f2bc52f57c118 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -141,7 +141,7 @@ static zend_always_inline bool is_long_compatible(double d) { static zend_always_inline zend_long zend_dval_to_lval_safe(double d) { if (!is_long_compatible(d)) { - zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float"); + zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float %f", d); } return zend_dval_to_lval(d); } diff --git a/ext/imap/tests/imap_fetch_overview_error.phpt b/ext/imap/tests/imap_fetch_overview_error.phpt deleted file mode 100644 index 7639fca439738..0000000000000 --- a/ext/imap/tests/imap_fetch_overview_error.phpt +++ /dev/null @@ -1,31 +0,0 @@ ---TEST-- -Test imap_fetch_overview() function: invalid option ---SKIPIF-- - ---FILE-- -getMessage() . \PHP_EOL; -} - -?> ---CLEAN-- - ---EXPECT-- -imap_fetch_overview(): Argument #3 ($flags) must be FT_UID or 0 diff --git a/ext/mbstring/tests/mb_substitute_character_variation_weak_types.phpt b/ext/mbstring/tests/mb_substitute_character_variation_weak_types.phpt index 64298b0d66288..3b4f75ad756b4 100644 --- a/ext/mbstring/tests/mb_substitute_character_variation_weak_types.phpt +++ b/ext/mbstring/tests/mb_substitute_character_variation_weak_types.phpt @@ -106,7 +106,7 @@ foreach($inputs as $key =>$value) { fclose($fp); ?> ---EXPECT-- +--EXPECTF-- *** Testing mb_substitute_character(): various types in weak typing mode *** --int 0-- bool(true) @@ -117,14 +117,20 @@ bool(true) --int -12345-- ValueError: mb_substitute_character(): Argument #1 ($substitute_character) is not a valid codepoint --float 10.5-- + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d bool(true) --float -10.5-- + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d ValueError: mb_substitute_character(): Argument #1 ($substitute_character) is not a valid codepoint --float 10.0e19-- ValueError: mb_substitute_character(): Argument #1 ($substitute_character) must be "none", "long", "entity" or a valid codepoint --float -10.0e19-- ValueError: mb_substitute_character(): Argument #1 ($substitute_character) must be "none", "long", "entity" or a valid codepoint --float .5-- + +Deprecated: Implicit conversion to int from non-compatible float in %s on line %d bool(true) --empty array-- TypeError: mb_substitute_character(): Argument #1 ($substitute_character) must be of type string|int|null, array given diff --git a/ext/session/tests/session_encode_error2.phpt b/ext/session/tests/session_encode_error2.phpt index a2d3d0ca309a6..b8f41e93efad1 100644 --- a/ext/session/tests/session_encode_error2.phpt +++ b/ext/session/tests/session_encode_error2.phpt @@ -126,6 +126,8 @@ bool(true) -- Iteration 5 -- bool(true) +Deprecated: Implicit conversion to int from non-compatible float 10.500000 in %s on line %d + Warning: session_encode(): Skipping numeric key 10 in %s on line %d bool(false) bool(true) @@ -133,6 +135,8 @@ bool(true) -- Iteration 6 -- bool(true) +Deprecated: Implicit conversion to int from non-compatible float -10.500000 in %s on line %d + Warning: session_encode(): Skipping numeric key -10 in %s on line %d bool(false) bool(true) @@ -147,6 +151,8 @@ bool(true) -- Iteration 8 -- bool(true) +Deprecated: Implicit conversion to int from non-compatible float 0.000000 in %s on line %d + Warning: session_encode(): Skipping numeric key 0 in %s on line %d bool(false) bool(true) @@ -154,6 +160,8 @@ bool(true) -- Iteration 9 -- bool(true) +Deprecated: Implicit conversion to int from non-compatible float 0.500000 in %s on line %d + Warning: session_encode(): Skipping numeric key 0 in %s on line %d bool(false) bool(true) diff --git a/ext/spl/tests/iterator_to_array_nonscalar_keys.phpt b/ext/spl/tests/iterator_to_array_nonscalar_keys.phpt index 2594e7ddba148..30470e7c467bb 100644 --- a/ext/spl/tests/iterator_to_array_nonscalar_keys.phpt +++ b/ext/spl/tests/iterator_to_array_nonscalar_keys.phpt @@ -20,5 +20,5 @@ try { ?> --EXPECTF-- -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d Illegal offset type diff --git a/ext/standard/tests/array/array_column_basic.phpt b/ext/standard/tests/array/array_column_basic.phpt index 42e457617750b..ceabdc6241533 100644 --- a/ext/standard/tests/array/array_column_basic.phpt +++ b/ext/standard/tests/array/array_column_basic.phpt @@ -226,6 +226,8 @@ array(3) { ["ccc"]=> string(3) "333" } + +Deprecated: Implicit conversion to int from non-compatible float 0.123000 in %s on line %d array(3) { ["aaa"]=> string(3) "111" @@ -256,6 +258,8 @@ array(3) { [2]=> string(3) "ccc" } + +Deprecated: Implicit conversion to int from non-compatible float 3.140000 in %s on line %d array(0) { } diff --git a/ext/standard/tests/array/array_combine_variation4.phpt b/ext/standard/tests/array/array_combine_variation4.phpt index ae4d54a626ac0..b72f43aa97d7d 100644 --- a/ext/standard/tests/array/array_combine_variation4.phpt +++ b/ext/standard/tests/array/array_combine_variation4.phpt @@ -81,6 +81,8 @@ echo "Done"; Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 444.432000 in %s on line %d -- Iteration 1 -- array(0) { } diff --git a/ext/standard/tests/array/array_fill.phpt b/ext/standard/tests/array/array_fill.phpt index 901b03b8b579b..e7a3ebea6ccfc 100644 --- a/ext/standard/tests/array/array_fill.phpt +++ b/ext/standard/tests/array/array_fill.phpt @@ -18,7 +18,7 @@ foreach($array1 as $start) } } ?> ---EXPECT-- +--EXPECTF-- =========================== bool(true) start: 0 num: 0 value: array(0) { @@ -81,7 +81,9 @@ start: 0 num: 1 value: array(1) { } =========================== bool(true) -start: 0 num: 2.5 value: array(2) { +start: 0 num: 2.5 value: +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +array(2) { [0]=> bool(true) [1]=> @@ -89,7 +91,9 @@ start: 0 num: 2.5 value: array(2) { } =========================== bool(false) -start: 0 num: 2.5 value: array(2) { +start: 0 num: 2.5 value: +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +array(2) { [0]=> bool(false) [1]=> @@ -97,7 +101,9 @@ start: 0 num: 2.5 value: array(2) { } =========================== NULL -start: 0 num: 2.5 value: array(2) { +start: 0 num: 2.5 value: +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +array(2) { [0]=> NULL [1]=> @@ -105,7 +111,9 @@ start: 0 num: 2.5 value: array(2) { } =========================== string(1) "d" -start: 0 num: 2.5 value: array(2) { +start: 0 num: 2.5 value: +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +array(2) { [0]=> string(1) "d" [1]=> @@ -113,7 +121,9 @@ start: 0 num: 2.5 value: array(2) { } =========================== string(1) "e" -start: 0 num: 2.5 value: array(2) { +start: 0 num: 2.5 value: +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +array(2) { [0]=> string(1) "e" [1]=> @@ -121,7 +131,9 @@ start: 0 num: 2.5 value: array(2) { } =========================== string(1) "f" -start: 0 num: 2.5 value: array(2) { +start: 0 num: 2.5 value: +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +array(2) { [0]=> string(1) "f" [1]=> @@ -189,7 +201,9 @@ start: 1 num: 1 value: array(1) { } =========================== bool(true) -start: 1 num: 2.5 value: array(2) { +start: 1 num: 2.5 value: +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +array(2) { [1]=> bool(true) [2]=> @@ -197,7 +211,9 @@ start: 1 num: 2.5 value: array(2) { } =========================== bool(false) -start: 1 num: 2.5 value: array(2) { +start: 1 num: 2.5 value: +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +array(2) { [1]=> bool(false) [2]=> @@ -205,7 +221,9 @@ start: 1 num: 2.5 value: array(2) { } =========================== NULL -start: 1 num: 2.5 value: array(2) { +start: 1 num: 2.5 value: +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +array(2) { [1]=> NULL [2]=> @@ -213,7 +231,9 @@ start: 1 num: 2.5 value: array(2) { } =========================== string(1) "d" -start: 1 num: 2.5 value: array(2) { +start: 1 num: 2.5 value: +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +array(2) { [1]=> string(1) "d" [2]=> @@ -221,7 +241,9 @@ start: 1 num: 2.5 value: array(2) { } =========================== string(1) "e" -start: 1 num: 2.5 value: array(2) { +start: 1 num: 2.5 value: +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +array(2) { [1]=> string(1) "e" [2]=> @@ -229,7 +251,9 @@ start: 1 num: 2.5 value: array(2) { } =========================== string(1) "f" -start: 1 num: 2.5 value: array(2) { +start: 1 num: 2.5 value: +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +array(2) { [1]=> string(1) "f" [2]=> @@ -237,67 +261,95 @@ start: 1 num: 2.5 value: array(2) { } =========================== bool(true) -start: 2.5 num: 0 value: array(0) { +start: 2.5 num: 0 value: +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +array(0) { } =========================== bool(false) -start: 2.5 num: 0 value: array(0) { +start: 2.5 num: 0 value: +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +array(0) { } =========================== NULL -start: 2.5 num: 0 value: array(0) { +start: 2.5 num: 0 value: +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +array(0) { } =========================== string(1) "d" -start: 2.5 num: 0 value: array(0) { +start: 2.5 num: 0 value: +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +array(0) { } =========================== string(1) "e" -start: 2.5 num: 0 value: array(0) { +start: 2.5 num: 0 value: +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +array(0) { } =========================== string(1) "f" -start: 2.5 num: 0 value: array(0) { +start: 2.5 num: 0 value: +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +array(0) { } =========================== bool(true) -start: 2.5 num: 1 value: array(1) { +start: 2.5 num: 1 value: +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +array(1) { [2]=> bool(true) } =========================== bool(false) -start: 2.5 num: 1 value: array(1) { +start: 2.5 num: 1 value: +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +array(1) { [2]=> bool(false) } =========================== NULL -start: 2.5 num: 1 value: array(1) { +start: 2.5 num: 1 value: +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +array(1) { [2]=> NULL } =========================== string(1) "d" -start: 2.5 num: 1 value: array(1) { +start: 2.5 num: 1 value: +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +array(1) { [2]=> string(1) "d" } =========================== string(1) "e" -start: 2.5 num: 1 value: array(1) { +start: 2.5 num: 1 value: +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +array(1) { [2]=> string(1) "e" } =========================== string(1) "f" -start: 2.5 num: 1 value: array(1) { +start: 2.5 num: 1 value: +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +array(1) { [2]=> string(1) "f" } =========================== bool(true) -start: 2.5 num: 2.5 value: array(2) { +start: 2.5 num: 2.5 value: +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +array(2) { [2]=> bool(true) [3]=> @@ -305,7 +357,11 @@ start: 2.5 num: 2.5 value: array(2) { } =========================== bool(false) -start: 2.5 num: 2.5 value: array(2) { +start: 2.5 num: 2.5 value: +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +array(2) { [2]=> bool(false) [3]=> @@ -313,7 +369,11 @@ start: 2.5 num: 2.5 value: array(2) { } =========================== NULL -start: 2.5 num: 2.5 value: array(2) { +start: 2.5 num: 2.5 value: +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +array(2) { [2]=> NULL [3]=> @@ -321,7 +381,11 @@ start: 2.5 num: 2.5 value: array(2) { } =========================== string(1) "d" -start: 2.5 num: 2.5 value: array(2) { +start: 2.5 num: 2.5 value: +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +array(2) { [2]=> string(1) "d" [3]=> @@ -329,7 +393,11 @@ start: 2.5 num: 2.5 value: array(2) { } =========================== string(1) "e" -start: 2.5 num: 2.5 value: array(2) { +start: 2.5 num: 2.5 value: +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +array(2) { [2]=> string(1) "e" [3]=> @@ -337,7 +405,11 @@ start: 2.5 num: 2.5 value: array(2) { } =========================== string(1) "f" -start: 2.5 num: 2.5 value: array(2) { +start: 2.5 num: 2.5 value: +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +array(2) { [2]=> string(1) "f" [3]=> diff --git a/ext/standard/tests/array/array_intersect_assoc_variation5.phpt b/ext/standard/tests/array/array_intersect_assoc_variation5.phpt index ad0c29b6b5dae..078adec20e7b8 100644 --- a/ext/standard/tests/array/array_intersect_assoc_variation5.phpt +++ b/ext/standard/tests/array/array_intersect_assoc_variation5.phpt @@ -67,8 +67,10 @@ foreach($arrays as $arr1) { echo "Done"; ?> ---EXPECT-- +--EXPECTF-- *** Testing array_intersect_assoc() : assoc array with diff keys to $arr1 argument *** + +Deprecated: Implicit conversion to int from non-compatible float 444.432000 in %s on line %d -- Iteration 1 -- array(0) { } diff --git a/ext/standard/tests/array/array_intersect_assoc_variation6.phpt b/ext/standard/tests/array/array_intersect_assoc_variation6.phpt index 57c3843d1fb18..f2eb859d73e9b 100644 --- a/ext/standard/tests/array/array_intersect_assoc_variation6.phpt +++ b/ext/standard/tests/array/array_intersect_assoc_variation6.phpt @@ -67,8 +67,10 @@ foreach($arrays as $arr2) { echo "Done"; ?> ---EXPECT-- +--EXPECTF-- *** Testing array_intersect_assoc() : assoc array with diff keys to $arr2 argument *** + +Deprecated: Implicit conversion to int from non-compatible float 444.432000 in %s on line %d -- Iteration 1 -- array(0) { } diff --git a/ext/standard/tests/array/array_intersect_variation5.phpt b/ext/standard/tests/array/array_intersect_variation5.phpt index 04eb9b43c37e4..d6be42e61f663 100644 --- a/ext/standard/tests/array/array_intersect_variation5.phpt +++ b/ext/standard/tests/array/array_intersect_variation5.phpt @@ -65,8 +65,10 @@ foreach($arrays as $arr1) { echo "Done"; ?> ---EXPECT-- +--EXPECTF-- *** Testing array_intersect() : assoc array with diff keys to $arr1 argument *** + +Deprecated: Implicit conversion to int from non-compatible float 444.432000 in %s on line %d -- Iterator 1 -- array(0) { } diff --git a/ext/standard/tests/array/array_intersect_variation6.phpt b/ext/standard/tests/array/array_intersect_variation6.phpt index b35a6ce0766df..0f7b0b329a6c2 100644 --- a/ext/standard/tests/array/array_intersect_variation6.phpt +++ b/ext/standard/tests/array/array_intersect_variation6.phpt @@ -65,8 +65,10 @@ foreach($arrays as $arr2) { echo "Done"; ?> ---EXPECT-- +--EXPECTF-- *** Testing array_intersect() : assoc array with diff keys to $arr2 argument *** + +Deprecated: Implicit conversion to int from non-compatible float 444.432000 in %s on line %d -- Iterator 1 -- array(0) { } diff --git a/ext/standard/tests/array/array_key_exists_variation3.phpt b/ext/standard/tests/array/array_key_exists_variation3.phpt index aba298db47e95..8766cee318255 100644 --- a/ext/standard/tests/array/array_key_exists_variation3.phpt +++ b/ext/standard/tests/array/array_key_exists_variation3.phpt @@ -28,23 +28,29 @@ foreach($keys as $key) { echo "Done"; ?> ---EXPECT-- +--EXPECTF-- *** Testing array_key_exists() : usage variations *** -- Iteration 1 -- Pass float as $key: + +Deprecated: Implicit conversion to int from non-compatible float 0.000000 in %s on line %d bool(true) Cast float to int: bool(true) -- Iteration 1 -- Pass float as $key: + +Deprecated: Implicit conversion to int from non-compatible float 1.000000 in %s on line %d bool(true) Cast float to int: bool(true) -- Iteration 1 -- Pass float as $key: + +Deprecated: Implicit conversion to int from non-compatible float 2.000000 in %s on line %d bool(true) Cast float to int: bool(true) diff --git a/ext/standard/tests/array/array_map_variation4.phpt b/ext/standard/tests/array/array_map_variation4.phpt index ea495cbcd8758..e1e5d6f34f6fe 100644 --- a/ext/standard/tests/array/array_map_variation4.phpt +++ b/ext/standard/tests/array/array_map_variation4.phpt @@ -73,6 +73,8 @@ echo "Done"; Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 444.432000 in %s on line %d -- Iteration 1 -- array(0) { } diff --git a/ext/standard/tests/array/array_reverse_variation4.phpt b/ext/standard/tests/array/array_reverse_variation4.phpt index 9a4fcbffbb41e..caa40eaa51da4 100644 --- a/ext/standard/tests/array/array_reverse_variation4.phpt +++ b/ext/standard/tests/array/array_reverse_variation4.phpt @@ -77,6 +77,8 @@ echo "Done"; Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 444.432000 in %s on line %d -- Iteration 1 -- - default argument - array(0) { diff --git a/ext/standard/tests/array/array_unshift_variation4.phpt b/ext/standard/tests/array/array_unshift_variation4.phpt index 4a5c53c472cb5..c9cd39294405a 100644 --- a/ext/standard/tests/array/array_unshift_variation4.phpt +++ b/ext/standard/tests/array/array_unshift_variation4.phpt @@ -93,6 +93,8 @@ echo "Done"; Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 444.432000 in %s on line %d -- Iteration 1 -- int(1) array(1) { diff --git a/ext/standard/tests/array/bug68553.phpt b/ext/standard/tests/array/bug68553.phpt index 1d8f7f1b0b4e5..0fb471bdd0c8c 100644 --- a/ext/standard/tests/array/bug68553.phpt +++ b/ext/standard/tests/array/bug68553.phpt @@ -35,6 +35,8 @@ try { ?> --EXPECTF-- Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 7.380000 in %s on line %d array(8) { [10]=> array(1) { diff --git a/ext/standard/tests/array/usort_variation3.phpt b/ext/standard/tests/array/usort_variation3.phpt index dc37ac21f2ce7..f89b88757487f 100644 --- a/ext/standard/tests/array/usort_variation3.phpt +++ b/ext/standard/tests/array/usort_variation3.phpt @@ -69,8 +69,10 @@ var_dump( usort($array_arg, 'cmp_function') ); echo "\n-- Sorted array after usort() function call --\n"; var_dump($array_arg); ?> ---EXPECT-- +--EXPECTF-- *** Testing usort() : usage variation *** + +Deprecated: Implicit conversion to int from non-compatible float 8.900000 in %s on line %d bool(true) -- Sorted array after usort() function call -- diff --git a/ext/standard/tests/file/disk_free_space_basic.phpt b/ext/standard/tests/file/disk_free_space_basic.phpt index 1590b71123f93..31b293656b914 100644 --- a/ext/standard/tests/file/disk_free_space_basic.phpt +++ b/ext/standard/tests/file/disk_free_space_basic.phpt @@ -53,7 +53,7 @@ rmdir($file_path."/disk_free_space"); float(%f) float(%f) *** Testing with newly created directory *** - + Free Space before writing to a file float(%f) diff --git a/ext/standard/tests/general_functions/intval_variation1.phpt b/ext/standard/tests/general_functions/intval_variation1.phpt index c18910a1d8023..fab896cd83d6b 100644 --- a/ext/standard/tests/general_functions/intval_variation1.phpt +++ b/ext/standard/tests/general_functions/intval_variation1.phpt @@ -109,18 +109,28 @@ int(12345) int(-2345) --float 10.5-- + +Deprecated: Implicit conversion to int from non-compatible float 10.500000 in %s on line %d int(10) --float -10.5-- + +Deprecated: Implicit conversion to int from non-compatible float -10.500000 in %s on line %d int(-10) --float 12.3456789e5-- + +Deprecated: Implicit conversion to int from non-compatible float 1234567.890000 in %s on line %d int(1234567) --float -12.3456789e5-- + +Deprecated: Implicit conversion to int from non-compatible float -1234567.890000 in %s on line %d int(-1234567) --float .5-- + +Deprecated: Implicit conversion to int from non-compatible float 0.500000 in %s on line %d int(0) --empty array-- diff --git a/ext/standard/tests/math/bug75170.phpt b/ext/standard/tests/math/bug75170.phpt index a9aab06ef414d..cc7d2c56c20f6 100644 --- a/ext/standard/tests/math/bug75170.phpt +++ b/ext/standard/tests/math/bug75170.phpt @@ -22,7 +22,7 @@ $total = 10000; $max = 0x66666666; $halves[0] = $halves[1] = 0; for ($i = 0; $i < $total; $i++) { - $halves[mt_rand(0, $max - 1) / ($max / 2)]++; + $halves[(int) (mt_rand(0, $max - 1) / ($max / 2))]++; } printf("%.1f%% vs. %.1f%%\n", 100. * $halves[0] / $total, 100. * $halves[1] / $total); diff --git a/ext/standard/tests/math/decbin_basic.phpt b/ext/standard/tests/math/decbin_basic.phpt index ff1d5896f6182..b74bd7bf047cf 100644 --- a/ext/standard/tests/math/decbin_basic.phpt +++ b/ext/standard/tests/math/decbin_basic.phpt @@ -25,14 +25,22 @@ foreach ($values as $value) { } ?> ---EXPECT-- +--EXPECTF-- string(4) "1010" + +Deprecated: Implicit conversion to int from non-compatible float 3950.500000 in %s on line %d string(12) "111101101110" + +Deprecated: Implicit conversion to int from non-compatible float 3950.500000 in %s on line %d string(12) "111101101110" string(2) "11" string(7) "1011111" string(4) "1010" + +Deprecated: Implicit conversion to int from non-compatible float-string 3950.5 in %s on line %d string(12) "111101101110" + +Deprecated: Implicit conversion to int from non-compatible float-string 3.9505e3 in %s on line %d string(12) "111101101110" string(6) "100111" decbin(): Argument #1 ($num) must be of type int, string given diff --git a/ext/standard/tests/math/decbin_variation1_64bit.phpt b/ext/standard/tests/math/decbin_variation1_64bit.phpt index 15bb864398224..4a71fce6fec22 100644 --- a/ext/standard/tests/math/decbin_variation1_64bit.phpt +++ b/ext/standard/tests/math/decbin_variation1_64bit.phpt @@ -75,7 +75,7 @@ foreach($inputs as $i => $input) { } fclose($fp); ?> ---EXPECT-- +--EXPECTF-- *** Testing decbin() : usage variations *** -- Iteration 1 -- @@ -97,18 +97,26 @@ decbin(): Argument #1 ($num) must be of type int, float given decbin(): Argument #1 ($num) must be of type int, float given -- Iteration 7 -- + +Deprecated: Implicit conversion to int from non-compatible float 10.500000 in %s on line %d string(4) "1010" -- Iteration 8 -- + +Deprecated: Implicit conversion to int from non-compatible float -10.500000 in %s on line %d string(64) "1111111111111111111111111111111111111111111111111111111111110110" -- Iteration 9 -- string(37) "1110010111110100110010001101000001000" -- Iteration 10 -- + +Deprecated: Implicit conversion to int from non-compatible float 0.000000 in %s on line %d string(1) "0" -- Iteration 11 -- + +Deprecated: Implicit conversion to int from non-compatible float 0.500000 in %s on line %d string(1) "0" -- Iteration 12 -- diff --git a/ext/standard/tests/math/dechex_basic.phpt b/ext/standard/tests/math/dechex_basic.phpt index 4fde95ebe7cdf..057fbfe0b6315 100644 --- a/ext/standard/tests/math/dechex_basic.phpt +++ b/ext/standard/tests/math/dechex_basic.phpt @@ -25,14 +25,22 @@ foreach ($values as $value) { } ?> ---EXPECT-- +--EXPECTF-- string(1) "a" + +Deprecated: Implicit conversion to int from non-compatible float 3950.500000 in %s on line %d string(3) "f6e" + +Deprecated: Implicit conversion to int from non-compatible float 3950.500000 in %s on line %d string(3) "f6e" string(1) "3" string(2) "5f" string(1) "a" + +Deprecated: Implicit conversion to int from non-compatible float-string 3950.5 in %s on line %d string(3) "f6e" + +Deprecated: Implicit conversion to int from non-compatible float-string 3.9505e3 in %s on line %d string(3) "f6e" string(2) "27" dechex(): Argument #1 ($num) must be of type int, string given diff --git a/ext/standard/tests/math/dechex_variation1_64bit.phpt b/ext/standard/tests/math/dechex_variation1_64bit.phpt index 8435d2bc30bad..1eff9249e6901 100644 --- a/ext/standard/tests/math/dechex_variation1_64bit.phpt +++ b/ext/standard/tests/math/dechex_variation1_64bit.phpt @@ -76,7 +76,7 @@ foreach($inputs as $i => $input) { fclose($fp); ?> ---EXPECT-- +--EXPECTF-- *** Testing dechex() : usage variations *** -- Iteration 1 -- @@ -98,18 +98,26 @@ dechex(): Argument #1 ($num) must be of type int, float given dechex(): Argument #1 ($num) must be of type int, float given -- Iteration 7 -- + +Deprecated: Implicit conversion to int from non-compatible float 10.500000 in %s on line %d string(1) "a" -- Iteration 8 -- + +Deprecated: Implicit conversion to int from non-compatible float -10.500000 in %s on line %d string(16) "fffffffffffffff6" -- Iteration 9 -- string(10) "1cbe991a08" -- Iteration 10 -- + +Deprecated: Implicit conversion to int from non-compatible float 0.000000 in %s on line %d string(1) "0" -- Iteration 11 -- + +Deprecated: Implicit conversion to int from non-compatible float 0.500000 in %s on line %d string(1) "0" -- Iteration 12 -- diff --git a/ext/standard/tests/math/decoct_basic.phpt b/ext/standard/tests/math/decoct_basic.phpt index 2bf63662f410b..f0b12cd0d9287 100644 --- a/ext/standard/tests/math/decoct_basic.phpt +++ b/ext/standard/tests/math/decoct_basic.phpt @@ -25,14 +25,22 @@ foreach ($values as $value) { } ?> ---EXPECT-- +--EXPECTF-- string(2) "12" + +Deprecated: Implicit conversion to int from non-compatible float 3950.500000 in %s on line %d string(4) "7556" + +Deprecated: Implicit conversion to int from non-compatible float 3950.500000 in %s on line %d string(4) "7556" string(1) "3" string(3) "137" string(2) "12" + +Deprecated: Implicit conversion to int from non-compatible float-string 3950.5 in %s on line %d string(4) "7556" + +Deprecated: Implicit conversion to int from non-compatible float-string 3.9505e3 in %s on line %d string(4) "7556" string(2) "47" decoct(): Argument #1 ($num) must be of type int, string given diff --git a/ext/standard/tests/math/decoct_variation1_64bit.phpt b/ext/standard/tests/math/decoct_variation1_64bit.phpt index 73650f5983557..6760c72ceafeb 100644 --- a/ext/standard/tests/math/decoct_variation1_64bit.phpt +++ b/ext/standard/tests/math/decoct_variation1_64bit.phpt @@ -76,7 +76,7 @@ foreach($inputs as $i => $input) { fclose($fp); ?> ---EXPECT-- +--EXPECTF-- *** Testing decoct() : usage variations *** -- Iteration 1 -- @@ -98,18 +98,26 @@ decoct(): Argument #1 ($num) must be of type int, float given decoct(): Argument #1 ($num) must be of type int, float given -- Iteration 7 -- + +Deprecated: Implicit conversion to int from non-compatible float 10.500000 in %s on line %d string(2) "12" -- Iteration 8 -- + +Deprecated: Implicit conversion to int from non-compatible float -10.500000 in %s on line %d string(22) "1777777777777777777766" -- Iteration 9 -- string(13) "1627646215010" -- Iteration 10 -- + +Deprecated: Implicit conversion to int from non-compatible float 0.000000 in %s on line %d string(1) "0" -- Iteration 11 -- + +Deprecated: Implicit conversion to int from non-compatible float 0.500000 in %s on line %d string(1) "0" -- Iteration 12 -- diff --git a/ext/standard/tests/math/mt_srand_basic.phpt b/ext/standard/tests/math/mt_srand_basic.phpt index 71abbcb0aae0a..da7663a6e2b52 100644 --- a/ext/standard/tests/math/mt_srand_basic.phpt +++ b/ext/standard/tests/math/mt_srand_basic.phpt @@ -12,9 +12,11 @@ var_dump(mt_srand("500E3")); var_dump(mt_srand(true)); var_dump(mt_srand(false)); ?> ---EXPECT-- +--EXPECTF-- NULL NULL + +Deprecated: Implicit conversion to int from non-compatible float 500.100000 in %s on line %d NULL NULL NULL diff --git a/ext/standard/tests/math/round_basic.phpt b/ext/standard/tests/math/round_basic.phpt index 44aacf2eecdc7..34c0d84080d6b 100644 --- a/ext/standard/tests/math/round_basic.phpt +++ b/ext/standard/tests/math/round_basic.phpt @@ -37,16 +37,20 @@ for ($i = 0; $i < count($values); $i++) { } } ?> ---EXPECT-- +--EXPECTF-- *** Testing round() : basic functionality *** round: 123456789 ...with precision 2-> float(123456789) ...with precision 8-> float(123456789) ...with precision 3-> float(123456789) ...with precision 4-> float(123456789) + +Deprecated: Implicit conversion to int from non-compatible float 3.600000 in %s on line %d ...with precision 3.6-> float(123456789) ...with precision 2-> float(123456789) ...with precision 04-> float(123456789) + +Deprecated: Implicit conversion to int from non-compatible float-string 3.6 in %s on line %d ...with precision 3.6-> float(123456789) ...with precision 2.1e1-> float(123456789) ...with precision 1-> float(123456789) @@ -56,9 +60,13 @@ round: 123.456789 ...with precision 8-> float(123.456789) ...with precision 3-> float(123.457) ...with precision 4-> float(123.4568) + +Deprecated: Implicit conversion to int from non-compatible float 3.600000 in %s on line %d ...with precision 3.6-> float(123.457) ...with precision 2-> float(123.46) ...with precision 04-> float(123.4568) + +Deprecated: Implicit conversion to int from non-compatible float-string 3.6 in %s on line %d ...with precision 3.6-> float(123.457) ...with precision 2.1e1-> float(123.456789) ...with precision 1-> float(123.5) @@ -68,9 +76,13 @@ round: -4.5679123 ...with precision 8-> float(-4.5679123) ...with precision 3-> float(-4.568) ...with precision 4-> float(-4.5679) + +Deprecated: Implicit conversion to int from non-compatible float 3.600000 in %s on line %d ...with precision 3.6-> float(-4.568) ...with precision 2-> float(-4.57) ...with precision 04-> float(-4.5679) + +Deprecated: Implicit conversion to int from non-compatible float-string 3.6 in %s on line %d ...with precision 3.6-> float(-4.568) ...with precision 2.1e1-> float(-4.5679123) ...with precision 1-> float(-4.6) @@ -80,9 +92,13 @@ round: 12300 ...with precision 8-> float(12300) ...with precision 3-> float(12300) ...with precision 4-> float(12300) + +Deprecated: Implicit conversion to int from non-compatible float 3.600000 in %s on line %d ...with precision 3.6-> float(12300) ...with precision 2-> float(12300) ...with precision 04-> float(12300) + +Deprecated: Implicit conversion to int from non-compatible float-string 3.6 in %s on line %d ...with precision 3.6-> float(12300) ...with precision 2.1e1-> float(12300) ...with precision 1-> float(12300) @@ -92,9 +108,13 @@ round: -4567 ...with precision 8-> float(-4567) ...with precision 3-> float(-4567) ...with precision 4-> float(-4567) + +Deprecated: Implicit conversion to int from non-compatible float 3.600000 in %s on line %d ...with precision 3.6-> float(-4567) ...with precision 2-> float(-4567) ...with precision 04-> float(-4567) + +Deprecated: Implicit conversion to int from non-compatible float-string 3.6 in %s on line %d ...with precision 3.6-> float(-4567) ...with precision 2.1e1-> float(-4567) ...with precision 1-> float(-4567) @@ -104,9 +124,13 @@ round: 2311527 ...with precision 8-> float(2311527) ...with precision 3-> float(2311527) ...with precision 4-> float(2311527) + +Deprecated: Implicit conversion to int from non-compatible float 3.600000 in %s on line %d ...with precision 3.6-> float(2311527) ...with precision 2-> float(2311527) ...with precision 04-> float(2311527) + +Deprecated: Implicit conversion to int from non-compatible float-string 3.6 in %s on line %d ...with precision 3.6-> float(2311527) ...with precision 2.1e1-> float(2311527) ...with precision 1-> float(2311527) @@ -116,9 +140,13 @@ round: 14680063 ...with precision 8-> float(14680063) ...with precision 3-> float(14680063) ...with precision 4-> float(14680063) + +Deprecated: Implicit conversion to int from non-compatible float 3.600000 in %s on line %d ...with precision 3.6-> float(14680063) ...with precision 2-> float(14680063) ...with precision 04-> float(14680063) + +Deprecated: Implicit conversion to int from non-compatible float-string 3.6 in %s on line %d ...with precision 3.6-> float(14680063) ...with precision 2.1e1-> float(14680063) ...with precision 1-> float(14680063) @@ -128,9 +156,13 @@ round: 1.234567 ...with precision 8-> float(1.234567) ...with precision 3-> float(1.235) ...with precision 4-> float(1.2346) + +Deprecated: Implicit conversion to int from non-compatible float 3.600000 in %s on line %d ...with precision 3.6-> float(1.235) ...with precision 2-> float(1.23) ...with precision 04-> float(1.2346) + +Deprecated: Implicit conversion to int from non-compatible float-string 3.6 in %s on line %d ...with precision 3.6-> float(1.235) ...with precision 2.1e1-> float(1.234567) ...with precision 1-> float(1.2) @@ -140,9 +172,13 @@ round: 2.3456789e8 ...with precision 8-> float(234567890) ...with precision 3-> float(234567890) ...with precision 4-> float(234567890) + +Deprecated: Implicit conversion to int from non-compatible float 3.600000 in %s on line %d ...with precision 3.6-> float(234567890) ...with precision 2-> float(234567890) ...with precision 04-> float(234567890) + +Deprecated: Implicit conversion to int from non-compatible float-string 3.6 in %s on line %d ...with precision 3.6-> float(234567890) ...with precision 2.1e1-> float(234567890) ...with precision 1-> float(234567890) diff --git a/ext/standard/tests/math/srand_basic.phpt b/ext/standard/tests/math/srand_basic.phpt index ce9a4e3f97ad9..5ce3b6e38ae99 100644 --- a/ext/standard/tests/math/srand_basic.phpt +++ b/ext/standard/tests/math/srand_basic.phpt @@ -14,10 +14,12 @@ var_dump(srand("500E3")); var_dump(srand(true)); var_dump(srand(false)); ?> ---EXPECT-- +--EXPECTF-- *** Testing srand() : basic functionality *** NULL NULL + +Deprecated: Implicit conversion to int from non-compatible float 500.100000 in %s on line %d NULL NULL NULL diff --git a/ext/standard/tests/streams/bug72075.phpt b/ext/standard/tests/streams/bug72075.phpt index f0d68cca90432..5af0b06564ee1 100644 --- a/ext/standard/tests/streams/bug72075.phpt +++ b/ext/standard/tests/streams/bug72075.phpt @@ -11,5 +11,6 @@ $dummy =& $r[0]; print stream_select($r, $w, $e, 0.5); ?> ---EXPECT-- +--EXPECTF-- +Deprecated: Implicit conversion to int from non-compatible float 0.500000 in %s on line %d 0 diff --git a/ext/standard/tests/strings/bug47842.phpt b/ext/standard/tests/strings/bug47842.phpt index 2cda861fd2c74..5c6abd0d33eff 100644 --- a/ext/standard/tests/strings/bug47842.phpt +++ b/ext/standard/tests/strings/bug47842.phpt @@ -24,13 +24,13 @@ printf("printf 64-bit signed int '18446744073709551615' (2^64)-1 = %u\n", 184467 echo "Done\n"; ?> --EXPECTF-- -%aTest +-Test sscanf 32-bit signed int '2147483647' (2^31)-1 = 2147483647 sscanf 32-bit unsign int '4294967295' (2^32)-1 = 4294967295 sscanf 64-bit signed int '9223372036854775807' (2^63)-1 = 9223372036854775807 sscanf 64-bit unsign int '18446744073709551615' (2^64)-1 = 18446744073709551615 printf 64-bit signed int '9223372036854775807' (2^63)-1 = 9223372036854775807 -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion to int from non-compatible float 18446744073709551616.000000 in %s on line %d printf 64-bit signed int '18446744073709551615' (2^64)-1 = 0 Done diff --git a/ext/standard/tests/strings/chr_variation1.phpt b/ext/standard/tests/strings/chr_variation1.phpt index 13a0636b8af9f..0b39d05267347 100644 --- a/ext/standard/tests/strings/chr_variation1.phpt +++ b/ext/standard/tests/strings/chr_variation1.phpt @@ -47,7 +47,7 @@ foreach($inputs as $input) { fclose($file_handle); //closing the file handle ?> ---EXPECT-- +--EXPECTF-- *** Testing chr() function: with unexpected inputs for 'ascii' argument *** -- Iteration 1 -- string(2) "00" @@ -58,8 +58,12 @@ string(2) "ff" -- Iteration 4 -- string(2) "00" -- Iteration 5 -- + +Deprecated: Implicit conversion to int from non-compatible float 10.500000 in %s on line %d string(2) "0a" -- Iteration 6 -- + +Deprecated: Implicit conversion to int from non-compatible float -20.500000 in %s on line %d string(2) "ec" -- Iteration 7 -- string(2) "48" diff --git a/ext/standard/tests/strings/chunk_split_variation10.phpt b/ext/standard/tests/strings/chunk_split_variation10.phpt index d40d713f1d5ed..ac1354a2f94ce 100644 --- a/ext/standard/tests/strings/chunk_split_variation10.phpt +++ b/ext/standard/tests/strings/chunk_split_variation10.phpt @@ -45,36 +45,66 @@ for($count = 0; $count < count($values); $count++) { echo "Done" ?> ---EXPECT-- +--EXPECTF-- *** Testing chunk_split() : different single quoted strings as 'ending' *** -- Iteration 0 -- + +Deprecated: Implicit conversion to int from non-compatible float 9.200000 in %s on line %d string(73) "This is to test chunk_split() with various 'single quoted' ending string." -- Iteration 1 -- + +Deprecated: Implicit conversion to int from non-compatible float 9.200000 in %s on line %d string(82) "This is t o test ch unk_split () with v arious 's ingle quo ted' endi ng string . " -- Iteration 2 -- + +Deprecated: Implicit conversion to int from non-compatible float 9.200000 in %s on line %d string(82) "This is tao test chaunk_splita() with vaarious 'saingle quoated' endiang stringa.a" -- Iteration 3 -- + +Deprecated: Implicit conversion to int from non-compatible float 9.200000 in %s on line %d string(127) "This is tENDINGo test chENDINGunk_splitENDING() with vENDINGarious 'sENDINGingle quoENDINGted' endiENDINGng stringENDING.ENDING" -- Iteration 4 -- + +Deprecated: Implicit conversion to int from non-compatible float 9.200000 in %s on line %d string(118) "This is t@#$%^o test ch@#$%^unk_split@#$%^() with v@#$%^arious 's@#$%^ingle quo@#$%^ted' endi@#$%^ng string@#$%^.@#$%^" -- Iteration 5 -- + +Deprecated: Implicit conversion to int from non-compatible float 9.200000 in %s on line %d string(91) "This is t\to test ch\tunk_split\t() with v\tarious 's\tingle quo\tted' endi\tng string\t.\t" -- Iteration 6 -- + +Deprecated: Implicit conversion to int from non-compatible float 9.200000 in %s on line %d string(91) "This is t\no test ch\nunk_split\n() with v\narious 's\ningle quo\nted' endi\nng string\n.\n" -- Iteration 7 -- + +Deprecated: Implicit conversion to int from non-compatible float 9.200000 in %s on line %d string(91) "This is t\ro test ch\runk_split\r() with v\rarious 's\ringle quo\rted' endi\rng string\r.\r" -- Iteration 8 -- + +Deprecated: Implicit conversion to int from non-compatible float 9.200000 in %s on line %d string(109) "This is t\r\no test ch\r\nunk_split\r\n() with v\r\narious 's\r\ningle quo\r\nted' endi\r\nng string\r\n.\r\n" -- Iteration 9 -- + +Deprecated: Implicit conversion to int from non-compatible float 9.200000 in %s on line %d string(91) "This is t\0o test ch\0unk_split\0() with v\0arious 's\0ingle quo\0ted' endi\0ng string\0.\0" -- Iteration 10 -- + +Deprecated: Implicit conversion to int from non-compatible float 9.200000 in %s on line %d string(100) "This is t123o test ch123unk_split123() with v123arious 's123ingle quo123ted' endi123ng string123.123" -- Iteration 11 -- + +Deprecated: Implicit conversion to int from non-compatible float 9.200000 in %s on line %d string(118) "This is t(MSG)o test ch(MSG)unk_split(MSG)() with v(MSG)arious 's(MSG)ingle quo(MSG)ted' endi(MSG)ng string(MSG).(MSG)" -- Iteration 12 -- + +Deprecated: Implicit conversion to int from non-compatible float 9.200000 in %s on line %d string(226) "This is t) ending string (o test ch) ending string (unk_split) ending string (() with v) ending string (arious 's) ending string (ingle quo) ending string (ted' endi) ending string (ng string) ending string (.) ending string (" -- Iteration 13 -- + +Deprecated: Implicit conversion to int from non-compatible float 9.200000 in %s on line %d string(217) "This is t) numbers 1234 (o test ch) numbers 1234 (unk_split) numbers 1234 (() with v) numbers 1234 (arious 's) numbers 1234 (ingle quo) numbers 1234 (ted' endi) numbers 1234 (ng string) numbers 1234 (.) numbers 1234 (" -- Iteration 14 -- + +Deprecated: Implicit conversion to int from non-compatible float 9.200000 in %s on line %d string(226) "This is t) speci@! ch@r$ (o test ch) speci@! ch@r$ (unk_split) speci@! ch@r$ (() with v) speci@! ch@r$ (arious 's) speci@! ch@r$ (ingle quo) speci@! ch@r$ (ted' endi) speci@! ch@r$ (ng string) speci@! ch@r$ (.) speci@! ch@r$ (" Done diff --git a/ext/standard/tests/strings/fprintf_variation_002.phpt b/ext/standard/tests/strings/fprintf_variation_002.phpt index f0f21b46302ea..3296c79bd922b 100644 --- a/ext/standard/tests/strings/fprintf_variation_002.phpt +++ b/ext/standard/tests/strings/fprintf_variation_002.phpt @@ -31,7 +31,39 @@ echo "\nDone"; unlink($data_file); ?> ---EXPECT-- +--EXPECTF-- +Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d + *** Testing fprintf() with integers *** -- Iteration 1 -- diff --git a/ext/standard/tests/strings/fprintf_variation_003_64bit.phpt b/ext/standard/tests/strings/fprintf_variation_003_64bit.phpt index bdb59d5021fba..4e72db90190e3 100644 --- a/ext/standard/tests/strings/fprintf_variation_003_64bit.phpt +++ b/ext/standard/tests/strings/fprintf_variation_003_64bit.phpt @@ -29,7 +29,11 @@ echo "\nDone"; unlink($data_file); ?> ---EXPECT-- +--EXPECTF-- +Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d + *** Testing fprintf() with binary *** 0 diff --git a/ext/standard/tests/strings/fprintf_variation_006_64bit.phpt b/ext/standard/tests/strings/fprintf_variation_006_64bit.phpt index a4c20f16f56e4..eb322a2c03603 100644 --- a/ext/standard/tests/strings/fprintf_variation_006_64bit.phpt +++ b/ext/standard/tests/strings/fprintf_variation_006_64bit.phpt @@ -29,7 +29,11 @@ echo "\nDone"; unlink($data_file); ?> ---EXPECT-- +--EXPECTF-- +Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d + *** Testing fprintf() for unsigned integers *** 0 diff --git a/ext/standard/tests/strings/fprintf_variation_007_64bit.phpt b/ext/standard/tests/strings/fprintf_variation_007_64bit.phpt index b4c80f95c5a94..38341481a9b91 100644 --- a/ext/standard/tests/strings/fprintf_variation_007_64bit.phpt +++ b/ext/standard/tests/strings/fprintf_variation_007_64bit.phpt @@ -29,7 +29,11 @@ echo "\nDone"; unlink($data_file); ?> ---EXPECT-- +--EXPECTF-- +Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d + *** Testing fprintf() for octals *** 0 diff --git a/ext/standard/tests/strings/fprintf_variation_008_64bit.phpt b/ext/standard/tests/strings/fprintf_variation_008_64bit.phpt index fae1ce3c2a6fb..fd1946238f963 100644 --- a/ext/standard/tests/strings/fprintf_variation_008_64bit.phpt +++ b/ext/standard/tests/strings/fprintf_variation_008_64bit.phpt @@ -30,7 +30,11 @@ echo "\nDone"; unlink($data_file); ?> ---EXPECT-- +--EXPECTF-- +Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d + *** Testing fprintf() for hexadecimals *** 0 diff --git a/ext/standard/tests/strings/printf_64bit.phpt b/ext/standard/tests/strings/printf_64bit.phpt index 083b7b2979db2..d9e494c968810 100644 --- a/ext/standard/tests/strings/printf_64bit.phpt +++ b/ext/standard/tests/strings/printf_64bit.phpt @@ -374,7 +374,11 @@ Integer Iteration 1 0 1 -1 + +Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d 2 + +Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d -2 23333333 -23333333 @@ -384,7 +388,11 @@ Integer Iteration 2 0 1 -1 + +Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d 2 + +Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d -2 23333333 -23333333 @@ -394,7 +402,11 @@ Integer Iteration 3 +0 +1 -1 + +Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d +2 + +Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d -2 +23333333 -23333333 @@ -404,7 +416,11 @@ Integer Iteration 4 0 1 -1 + +Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d 2 + +Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d -2 23333333 -23333333 @@ -414,7 +430,11 @@ Integer Iteration 5 0 1 -1 + +Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d 2 + +Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d -2 23333333 -23333333 @@ -424,7 +444,11 @@ Integer Iteration 6 0000000 0000001 -000001 + +Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d 0000002 + +Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d -000002 23333333 -23333333 @@ -434,7 +458,11 @@ Integer Iteration 7 0 1 -1 + +Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d 2 + +Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d -2 23333333 -23333333 @@ -444,7 +472,11 @@ Integer Iteration 8 ######0 ######1 #####-1 + +Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d ######2 + +Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d #####-2 23333333 -23333333 @@ -468,7 +500,11 @@ Array 0 1 1111111111111111111111111111111111111111111111111111111111111111 + +Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d 10 + +Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d 1111111111111111111111111111111111111111111111111111111111111110 1011001000000100111010101 1111111111111111111111111111111111111110100110111111011000101011 @@ -534,7 +570,11 @@ Array 0 1 18446744073709551615 + +Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d 2 + +Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d 18446744073709551614 23333333 18446744073686218283 @@ -558,7 +598,11 @@ Array 0 1 1777777777777777777777 + +Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d 2 + +Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d 1777777777777777777776 131004725 1777777777777646773053 @@ -582,7 +626,11 @@ Array 0 1 ffffffffffffffff + +Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d 2 + +Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d fffffffffffffffe 16409d5 fffffffffe9bf62b diff --git a/ext/standard/tests/strings/vprintf_variation12_64bit.phpt b/ext/standard/tests/strings/vprintf_variation12_64bit.phpt index e3eee1268124e..9d943db6b7a01 100644 --- a/ext/standard/tests/strings/vprintf_variation12_64bit.phpt +++ b/ext/standard/tests/strings/vprintf_variation12_64bit.phpt @@ -74,10 +74,38 @@ foreach($args_array as $args) { } ?> ---EXPECT-- +--EXPECTF-- *** Testing vprintf() : octal formats and non-octal values *** -- Iteration 1 -- + +Deprecated: Implicit conversion to int from non-compatible float 2.200000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 0.200000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 10.200000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 123456.234000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float -1234.678900 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 1234.678900 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 12345.780000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 12.000000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float -12.000001 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float -123456.234000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 10.200000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 123456.234000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 2.200000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 0.200000 in %s on line %d 2 0 12 361100 1777777777777777775456 2322 diff --git a/ext/standard/tests/strings/vprintf_variation14_64bit.phpt b/ext/standard/tests/strings/vprintf_variation14_64bit.phpt index 91ef18a9fb3b6..67ac554b09e1d 100644 --- a/ext/standard/tests/strings/vprintf_variation14_64bit.phpt +++ b/ext/standard/tests/strings/vprintf_variation14_64bit.phpt @@ -75,10 +75,38 @@ foreach($args_array as $args) { } ?> ---EXPECT-- +--EXPECTF-- *** Testing vprintf() : hexa formats and non-hexa values *** -- Iteration 1 -- + +Deprecated: Implicit conversion to int from non-compatible float 2.200000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 0.200000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 10.200000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 123456.234000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float -1234.678900 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 1234.678900 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 12345.780000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 12.000000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float -12.000001 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float -123456.234000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 10.200000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 123456.234000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 2.200000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 0.200000 in %s on line %d 2 0 a 1e240 fffffffffffffb2e 4d2 diff --git a/ext/standard/tests/strings/vprintf_variation15_64bit.phpt b/ext/standard/tests/strings/vprintf_variation15_64bit.phpt index 2729e8f54af74..7a7511d11b7df 100644 --- a/ext/standard/tests/strings/vprintf_variation15_64bit.phpt +++ b/ext/standard/tests/strings/vprintf_variation15_64bit.phpt @@ -44,7 +44,7 @@ foreach($formats as $format) { } ?> ---EXPECT-- +--EXPECTF-- *** Testing vprintf() : unsigned formats and unsigned values *** -- Iteration 1 -- @@ -56,6 +56,8 @@ int(16) int(22) -- Iteration 3 -- + +Deprecated: Implicit conversion to int from non-compatible float 1000000000000000000000.000000 in %s on line %d 1234000 3875820019684212736 120 int(34) diff --git a/ext/standard/tests/strings/vprintf_variation16_64bit.phpt b/ext/standard/tests/strings/vprintf_variation16_64bit.phpt index 9ea63998bfe03..a26fcd592b72f 100644 --- a/ext/standard/tests/strings/vprintf_variation16_64bit.phpt +++ b/ext/standard/tests/strings/vprintf_variation16_64bit.phpt @@ -67,10 +67,38 @@ foreach($args_array as $args) { } ?> ---EXPECT-- +--EXPECTF-- *** Testing vprintf() : unsigned formats and signed & other types of values *** -- Iteration 1 -- + +Deprecated: Implicit conversion to int from non-compatible float 2.200000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 0.200000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 10.200000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 123456.234000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 123456.234000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 1234.678900 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 12345.780000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 12.000000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float -12.000001 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float -123456.234000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 10.200000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 123456.234000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 2.200000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 0.200000 in %s on line %d 2 0 10 123456 123456 1234 20000000000 2000000000000 22000000000000 diff --git a/ext/standard/tests/strings/vprintf_variation4_64bit.phpt b/ext/standard/tests/strings/vprintf_variation4_64bit.phpt index 5631a9adb72f1..910f2ab1b2520 100644 --- a/ext/standard/tests/strings/vprintf_variation4_64bit.phpt +++ b/ext/standard/tests/strings/vprintf_variation4_64bit.phpt @@ -67,10 +67,38 @@ foreach($args_array as $args) { } ?> ---EXPECT-- +--EXPECTF-- *** Testing vprintf() : int formats and non-integer values *** -- Iteration 1 -- + +Deprecated: Implicit conversion to int from non-compatible float 2.200000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 0.200000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 10.200000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 123456.234000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float -1234.678900 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 1234.678900 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 12345.780000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 12.000000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float -12.000001 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float -123456.234000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 10.200000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 123456.234000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 2.200000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 0.200000 in %s on line %d 2 +0 10 123456 -1234 1234 20000000000 200000 4000 22000000 diff --git a/tests/lang/operators/bitwiseNot_basiclong_64bit.phpt b/tests/lang/operators/bitwiseNot_basiclong_64bit.phpt index 72db6d5728862..e5c9b34f02a0f 100644 --- a/tests/lang/operators/bitwiseNot_basiclong_64bit.phpt +++ b/tests/lang/operators/bitwiseNot_basiclong_64bit.phpt @@ -25,7 +25,7 @@ foreach ($longVals as $longVal) { } ?> ---EXPECT-- +--EXPECTF-- --- testing: 9223372036854775807 --- int(-9223372036854775808) --- testing: -9223372036854775808 --- @@ -51,6 +51,8 @@ int(-4294967294) --- testing: 9223372036854775806 --- int(-9223372036854775807) --- testing: 9.2233720368548E+18 --- + +Deprecated: Implicit conversion to int from non-compatible float 9223372036854775808.000000 in %s on line %d int(9223372036854775807) --- testing: -9223372036854775807 --- int(9223372036854775806) From d9f57309d88e2728aa16a044ee6b3c85e0488f0a Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Mon, 5 Apr 2021 05:50:35 +0100 Subject: [PATCH 07/61] Micro optimization --- Zend/zend_operators.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 2bf7131a741b5..babd46bce6482 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -303,14 +303,16 @@ static zend_never_inline zend_long ZEND_FASTCALL zendi_try_get_long(zval *op, bo return 0; case IS_TRUE: return 1; - case IS_DOUBLE: - if (!is_long_compatible(Z_DVAL_P(op))) { - zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float %f", Z_DVAL_P(op)); + case IS_DOUBLE: { + double dval = Z_DVAL_P(op); + if (!is_long_compatible(dval)) { + zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float %f", dval); if (UNEXPECTED(EG(exception))) { *failed = 1; } } - return zend_dval_to_lval(Z_DVAL_P(op)); + return zend_dval_to_lval(dval); + } case IS_STRING: { zend_uchar type; @@ -820,15 +822,17 @@ ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op, bool is_lax) /* {{ return Z_RES_HANDLE_P(op); case IS_LONG: return Z_LVAL_P(op); - case IS_DOUBLE: + case IS_DOUBLE: { + double dval = Z_DVAL_P(op); if (EXPECTED(!is_lax)) { - if (!is_long_compatible(Z_DVAL_P(op))) { - zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float %f", Z_DVAL_P(op)); + if (!is_long_compatible(dval)) { + zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float %f", dval); // TODO Need to handle this here? //if (UNEXPECTED(EG(exception))) {} } } - return zend_dval_to_lval(Z_DVAL_P(op)); + return zend_dval_to_lval(dval); + } case IS_STRING: { zend_uchar type; From 342252bb2b73306b0fe3ad4068964ec573b1e43b Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Mon, 5 Apr 2021 05:53:39 +0100 Subject: [PATCH 08/61] Add test for negative 0 --- Zend/tests/float_to_int/negative_zero_check.phpt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Zend/tests/float_to_int/negative_zero_check.phpt diff --git a/Zend/tests/float_to_int/negative_zero_check.phpt b/Zend/tests/float_to_int/negative_zero_check.phpt new file mode 100644 index 0000000000000..ca8e4bf7528ce --- /dev/null +++ b/Zend/tests/float_to_int/negative_zero_check.phpt @@ -0,0 +1,15 @@ +--TEST-- +Negative 0 check +--FILE-- + +--EXPECT-- +float(-0) +bool(true) +bool(true) From e411fa40cb2b70a22de31954f82db45678bb0605 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Mon, 5 Apr 2021 06:31:15 +0100 Subject: [PATCH 09/61] Fix more tests --- ext/calendar/tests/bug80185.phpt | 6 +- ext/gd/tests/imagefilter.phpt | 2 +- ext/gd/tests/libgd00100.phpt | 2 +- ext/gmp/tests/gmp_fact.phpt | 2 - ext/gmp/tests/gmp_intval.phpt | 2 - ext/standard/tests/strings/bug23894.phpt | 15 --- .../tests/strings/bug23894_32bit.phpt | 22 +++++ .../tests/strings/bug23894_64bit.phpt | 22 +++++ ext/standard/tests/strings/sprintf_f_2.phpt | 93 ++++++++----------- .../tests/strings/sprintf_variation4.phpt | 24 +++++ .../strings/sprintf_variation4_64bit.phpt | 24 +++++ .../tests/strings/sprintf_variation5.phpt | 37 ++++++++ 12 files changed, 173 insertions(+), 78 deletions(-) delete mode 100644 ext/standard/tests/strings/bug23894.phpt create mode 100644 ext/standard/tests/strings/bug23894_32bit.phpt create mode 100644 ext/standard/tests/strings/bug23894_64bit.phpt create mode 100644 ext/standard/tests/strings/sprintf_variation4.phpt create mode 100644 ext/standard/tests/strings/sprintf_variation4_64bit.phpt create mode 100644 ext/standard/tests/strings/sprintf_variation5.phpt diff --git a/ext/calendar/tests/bug80185.phpt b/ext/calendar/tests/bug80185.phpt index dfc843270ec82..f297f7060aca7 100644 --- a/ext/calendar/tests/bug80185.phpt +++ b/ext/calendar/tests/bug80185.phpt @@ -16,7 +16,11 @@ try { echo $ex->getMessage(), PHP_EOL; } ?> ---EXPECT-- +--EXPECTF-- int(2170713600) + +Deprecated: Implicit conversion to int from non-compatible float 106751993607888.640625 in %s on line %d int(9223372036854720000) + +Deprecated: Implicit conversion to int from non-compatible float 106751993607889.640625 in %s on line %d jday must be between 2440588 and 106751993607888 diff --git a/ext/gd/tests/imagefilter.phpt b/ext/gd/tests/imagefilter.phpt index 98e8e3e1773db..156f465da6016 100644 --- a/ext/gd/tests/imagefilter.phpt +++ b/ext/gd/tests/imagefilter.phpt @@ -44,7 +44,7 @@ $SOURCE_IMG = $SAVE_DIR . "/test.png"; $im = imagecreatefrompng($SOURCE_IMG); - if (imagefilter($im, IMG_FILTER_COLORIZE, -127.12, -127.98, 127)) { + if (imagefilter($im, IMG_FILTER_COLORIZE, -127, -127, 127)) { imagepng($im, $SAVE_DIR . "/IMG_FILTER_COLORIZE.png"); echo "IMG_FILTER_COLORIZE success\n"; unlink($SAVE_DIR . "/IMG_FILTER_COLORIZE.png"); diff --git a/ext/gd/tests/libgd00100.phpt b/ext/gd/tests/libgd00100.phpt index 6b8299e2585b7..80e24d0ba203e 100644 --- a/ext/gd/tests/libgd00100.phpt +++ b/ext/gd/tests/libgd00100.phpt @@ -31,7 +31,7 @@ $points = array( $x, $top, $x+2*$d, $top, $x+2*$d, $bot, - $x+$d, ($top+$bot)/2, + $x+$d, (int) (($top+$bot)/2), $x, $bot ); imagefilledpolygon($im, $points, $yellow); diff --git a/ext/gmp/tests/gmp_fact.phpt b/ext/gmp/tests/gmp_fact.phpt index ce7331f610461..e039314549405 100644 --- a/ext/gmp/tests/gmp_fact.phpt +++ b/ext/gmp/tests/gmp_fact.phpt @@ -23,7 +23,6 @@ try { echo $e->getMessage() . \PHP_EOL; } -var_dump(gmp_strval(gmp_fact(1.1))); var_dump(gmp_strval(gmp_fact(20))); var_dump(gmp_strval(gmp_fact("50"))); var_dump(gmp_strval(gmp_fact("10"))); @@ -52,7 +51,6 @@ gmp_fact(): Argument #1 ($num) is not an integer string string(1) "1" gmp_fact(): Argument #1 ($num) must be greater than or equal to 0 gmp_fact(): Argument #1 ($num) must be greater than or equal to 0 -string(1) "1" string(19) "2432902008176640000" string(65) "30414093201713378043612608166064768844377641568960512000000000000" string(7) "3628800" diff --git a/ext/gmp/tests/gmp_intval.phpt b/ext/gmp/tests/gmp_intval.phpt index 1d427e0e9c70e..15a1cdcc3d830 100644 --- a/ext/gmp/tests/gmp_intval.phpt +++ b/ext/gmp/tests/gmp_intval.phpt @@ -9,7 +9,6 @@ var_dump(gmp_intval("-1")); var_dump(gmp_intval(-1)); var_dump(gmp_intval(-2349828)); var_dump(gmp_intval(2342344)); -var_dump(gmp_intval(1.0001)); $g = gmp_init("12345678"); var_dump(gmp_intval($g)); @@ -42,7 +41,6 @@ int(-1) int(-1) int(-2349828) int(2342344) -int(1) int(12345678) gmp_intval(): Argument #1 ($num) is not an integer string gmp_intval(): Argument #1 ($num) must be of type GMP|string|int, stdClass given diff --git a/ext/standard/tests/strings/bug23894.phpt b/ext/standard/tests/strings/bug23894.phpt deleted file mode 100644 index 3455081f117df..0000000000000 --- a/ext/standard/tests/strings/bug23894.phpt +++ /dev/null @@ -1,15 +0,0 @@ ---TEST-- -Bug #23894 (sprintf() decimal specifiers problem) ---FILE-- - ---EXPECTREGEX-- -string\(4\) \"-012\" -string\(8\) \"2d303132\" -(string\(13\) \" 4294967284\"|string\(20\) \"18446744073709551604\") -(string\(26\) \"20202034323934393637323834\"|string\(40\) \"3138343436373434303733373039353531363034\") diff --git a/ext/standard/tests/strings/bug23894_32bit.phpt b/ext/standard/tests/strings/bug23894_32bit.phpt new file mode 100644 index 0000000000000..9ab8c472375fe --- /dev/null +++ b/ext/standard/tests/strings/bug23894_32bit.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #23894 (sprintf() decimal specifiers problem) 32bit version +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Deprecated: Implicit conversion to int from non-compatible float -12.345600 in %s on line %d +string(4) "-012" +string(8) "2d303132" + +Deprecated: Implicit conversion to int from non-compatible float -12.345600 in %s on line %d +string(13) " 4294967284" +string(26) "20202034323934393637323834" diff --git a/ext/standard/tests/strings/bug23894_64bit.phpt b/ext/standard/tests/strings/bug23894_64bit.phpt new file mode 100644 index 0000000000000..f34a1054b04db --- /dev/null +++ b/ext/standard/tests/strings/bug23894_64bit.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #23894 (sprintf() decimal specifiers problem) 64bit version +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Deprecated: Implicit conversion to int from non-compatible float -12.345600 in %s on line %d +string(4) "-012" +string(8) "2d303132" + +Deprecated: Implicit conversion to int from non-compatible float -12.345600 in %s on line %d +string(20) "18446744073709551604" +string(40) "3138343436373434303733373039353531363034" diff --git a/ext/standard/tests/strings/sprintf_f_2.phpt b/ext/standard/tests/strings/sprintf_f_2.phpt index 9ee0aae17fb26..4efd1e2024c4b 100644 --- a/ext/standard/tests/strings/sprintf_f_2.phpt +++ b/ext/standard/tests/strings/sprintf_f_2.phpt @@ -33,28 +33,6 @@ $format = 'The %2$s contains %1$d monkeys. That\'s a nice %2$s full of %1$d monkeys.'; var_dump(sprintf($format, $num, $location)); -/* example#5: various examples */ -$n = 43951789; -$u = -43951789; -$c = 65; // ASCII 65 is 'A' - -// notice the double %%, this prints a literal '%' character -var_dump(sprintf("%%b = '%b'", $n)); // binary representation -var_dump(sprintf("%%c = '%c'", $c)); // print the ascii character, same as chr() function -var_dump(sprintf("%%d = '%d'", $n)); // standard integer representation -var_dump(sprintf("%%e = '%e'", $n)); // scientific notation -var_dump(sprintf("%%u = '%u'", $n)); // unsigned integer representation of a positive integer -var_dump(sprintf("%%u = '%u'", $u)); // unsigned integer representation of a negative integer -var_dump(sprintf("%%f = '%f'", $n)); // floating point representation -var_dump(sprintf("%%o = '%o'", $n)); // octal representation -var_dump(sprintf("%%s = '%s'", $n)); // string representation -var_dump(sprintf("%%x = '%x'", $n)); // hexadecimal representation (lower-case) -var_dump(sprintf("%%X = '%X'", $n)); // hexadecimal representation (upper-case) - -var_dump(sprintf("%%+d = '%+d'", $n)); // sign specifier on a positive integer -var_dump(sprintf("%%+d = '%+d'", $u)); // sign specifier on a negative integer - - /* example#6: string specifiers */ $s = 'monkey'; $t = 'many monkeys'; @@ -80,37 +58,40 @@ $number = 362525200; var_dump(sprintf("%.3e", $number)); // outputs 3.63e+8 ?> ---EXPECTREGEX-- -string\(7\) \"100\.426\" -string\(6\) \"100\.43\" -string\(3\) \"100\" -string\(3\) \"100\" -string\(3\) \"144\" -string\(3\) \"144\" -string\(34\) \"There are 100 monkeys in the world\" -string\(28\) \"The 100\.1 contains 0 monkeys\" -string\(30\) \"The world contains 100 monkeys\" -string\(76\) \"The world contains 100 monkeys. - That's a nice world full of 100 monkeys\.\" -string\(33\) \"%b = '10100111101010011010101101'\" -string\(8\) \"%c = 'A'\" -string\(15\) \"%d = '43951789'\" -string\(18\) \"%e = '4\.395179e\+7'\" -string\(15\) \"%u = '43951789'\" -(string\(17\) \"%u = '4251015507'\"|string\(27\) \"%u = '18446744073665599827'\") -string\(22\) \"%f = '43951789\.000000'\" -string\(16\) \"%o = '247523255'\" -string\(15\) \"%s = '43951789'\" -string\(14\) \"%x = '29ea6ad'\" -string\(14\) \"%X = '29EA6AD'\" -string\(17\) \"%\+d = '\+43951789'\" -string\(17\) \"%\+d = '-43951789'\" -string\(8\) \"\[monkey\]\" -string\(12\) \"\[ monkey\]\" -string\(12\) \"\[monkey \]\" -string\(12\) \"\[0000monkey\]\" -string\(12\) \"\[####monkey\]\" -string\(12\) \"\[many monke\]\" -string\(10\) \"2006-12-18\" -string\(6\) \"123\.10\" -string\(8\) \"3\.625e\+8\" +--EXPECTF-- +string(7) "100.426" +string(6) "100.43" + +Deprecated: Implicit conversion to int from non-compatible float 100.426000 in %s on line %d +string(3) "100" + +Deprecated: Implicit conversion to int from non-compatible float 100.900000 in %s on line %d +string(3) "100" + +Deprecated: Implicit conversion to int from non-compatible float 100.426000 in %s on line %d +string(3) "144" + +Deprecated: Implicit conversion to int from non-compatible float 100.900000 in %s on line %d +string(3) "144" + +Deprecated: Implicit conversion to int from non-compatible float 100.100000 in %s on line %d +string(34) "There are 100 monkeys in the world" +string(28) "The 100.1 contains 0 monkeys" + +Deprecated: Implicit conversion to int from non-compatible float 100.100000 in %s on line %d +string(30) "The world contains 100 monkeys" + +Deprecated: Implicit conversion to int from non-compatible float 100.100000 in %s on line %d + +Deprecated: Implicit conversion to int from non-compatible float 100.100000 in %s on line %d +string(76) "The world contains 100 monkeys. + That's a nice world full of 100 monkeys." +string(8) "[monkey]" +string(12) "[ monkey]" +string(12) "[monkey ]" +string(12) "[0000monkey]" +string(12) "[####monkey]" +string(12) "[many monke]" +string(10) "2006-12-18" +string(6) "123.10" +string(8) "3.625e+8" diff --git a/ext/standard/tests/strings/sprintf_variation4.phpt b/ext/standard/tests/strings/sprintf_variation4.phpt new file mode 100644 index 0000000000000..285dd9a2ada21 --- /dev/null +++ b/ext/standard/tests/strings/sprintf_variation4.phpt @@ -0,0 +1,24 @@ +--TEST-- +sprintf %u With signed integer 32bit +--SKIPIF-- + +--FILE-- + +--EXPECT-- +string(15) "%u = '43951789'" +string(17) "%u = '4251015507'" + diff --git a/ext/standard/tests/strings/sprintf_variation4_64bit.phpt b/ext/standard/tests/strings/sprintf_variation4_64bit.phpt new file mode 100644 index 0000000000000..57d9931648a77 --- /dev/null +++ b/ext/standard/tests/strings/sprintf_variation4_64bit.phpt @@ -0,0 +1,24 @@ +--TEST-- +sprintf %u With signed integer 32bit +--SKIPIF-- + +--FILE-- + +--EXPECT-- +string(15) "%u = '43951789'" +string(27) "%u = '18446744073665599827'" + diff --git a/ext/standard/tests/strings/sprintf_variation5.phpt b/ext/standard/tests/strings/sprintf_variation5.phpt new file mode 100644 index 0000000000000..5a862fe373cc2 --- /dev/null +++ b/ext/standard/tests/strings/sprintf_variation5.phpt @@ -0,0 +1,37 @@ +--TEST-- +sprintf With signed integer +--FILE-- + +--EXPECT-- +string(33) "%b = '10100111101010011010101101'" +string(8) "%c = 'A'" +string(15) "%d = '43951789'" +string(18) "%e = '4.395179e+7'" +string(22) "%f = '43951789.000000'" +string(16) "%o = '247523255'" +string(15) "%s = '43951789'" +string(14) "%x = '29ea6ad'" +string(14) "%X = '29EA6AD'" +string(17) "%+d = '+43951789'" +string(17) "%+d = '-43951789'" From d27a94f602ed96cffe414adf552477f59f1d43e7 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Tue, 13 Apr 2021 12:59:34 +0100 Subject: [PATCH 10/61] Keep zval_get_long() similar to an (int) cast --- Zend/zend_execute.c | 4 ++-- Zend/zend_operators.c | 2 +- Zend/zend_operators.h | 2 +- Zend/zend_vm_def.h | 5 +++-- Zend/zend_vm_execute.h | 21 ++++++++++++--------- 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 573a1ecf7a8d1..57bc3ce921647 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -2598,7 +2598,7 @@ static zend_never_inline bool ZEND_FASTCALL zend_isset_dim_slow(zval *container, if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ || (Z_TYPE_P(offset) == IS_STRING /* or numeric string */ && IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) { - lval = zval_get_long(offset); + lval = zval_get_long_ex(offset, /* is_lax */ false); goto str_offset; } return 0; @@ -2637,7 +2637,7 @@ static zend_never_inline bool ZEND_FASTCALL zend_isempty_dim_slow(zval *containe if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ || (Z_TYPE_P(offset) == IS_STRING /* or numeric string */ && IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) { - lval = zval_get_long(offset); + lval = zval_get_long_ex(offset, /* is_lax */ false); goto str_offset; } return 1; diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index babd46bce6482..a84587f3e00e0 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -473,7 +473,7 @@ ZEND_API void ZEND_FASTCALL convert_to_long(zval *op) /* {{{ */ case IS_STRING: { zend_string *str = Z_STR_P(op); - ZVAL_LONG(op, zval_get_long_ex(op, /* is lax */ true)); + ZVAL_LONG(op, zval_get_long(op)); zend_string_release_ex(str, 0); } break; diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index f2bc52f57c118..e7d4a29c03074 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -286,7 +286,7 @@ ZEND_API zend_string* ZEND_FASTCALL zval_get_string_func(zval *op); ZEND_API zend_string* ZEND_FASTCALL zval_try_get_string_func(zval *op); static zend_always_inline zend_long zval_get_long(zval *op) { - return EXPECTED(Z_TYPE_P(op) == IS_LONG) ? Z_LVAL_P(op) : zval_get_long_func(op, 0); + return EXPECTED(Z_TYPE_P(op) == IS_LONG) ? Z_LVAL_P(op) : zval_get_long_func(op, true); } static zend_always_inline zend_long zval_get_long_ex(zval *op, bool is_lax) { return EXPECTED(Z_TYPE_P(op) == IS_LONG) ? Z_LVAL_P(op) : zval_get_long_func(op, is_lax); diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index ec2bbd76fbab2..979fa57794289 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -6117,7 +6117,7 @@ ZEND_VM_COLD_CONST_HANDLER(51, ZEND_CAST, CONST|TMP|VAR|CV, ANY, TYPE) switch (opline->extended_value) { case IS_LONG: - ZVAL_LONG(result, zval_get_long_ex(expr, /* lax */ true)); + ZVAL_LONG(result, zval_get_long(expr)); break; case IS_DOUBLE: ZVAL_DOUBLE(result, zval_get_double(expr)); @@ -9041,6 +9041,7 @@ ZEND_VM_COLD_CONST_HANDLER(190, ZEND_COUNT, CONST|TMPVAR|CV, UNUSED) zval retval; zend_call_method_with_0_params(zobj, NULL, NULL, "count", &retval); + // TODO Should this use zval_get_long_ex(&retval, /* is lax */ false); count = zval_get_long(&retval); zval_ptr_dtor(&retval); break; @@ -9613,7 +9614,7 @@ ZEND_VM_C_LABEL(fetch_dim_r_index_array): if (EXPECTED(Z_TYPE_P(dim) == IS_LONG)) { offset = Z_LVAL_P(dim); } else { - offset = zval_get_long(dim); + offset = zval_get_long_ex(dim, /* is_lax */ false); } ht = Z_ARRVAL_P(container); ZEND_HASH_INDEX_FIND(ht, offset, value, ZEND_VM_C_LABEL(fetch_dim_r_index_undef)); diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index d5cf4dc8bd5ae..87170b650e589 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -4736,7 +4736,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CAST_SPEC_CONST_H switch (opline->extended_value) { case IS_LONG: - ZVAL_LONG(result, zval_get_long_ex(expr, /* lax */ true)); + ZVAL_LONG(result, zval_get_long(expr)); break; case IS_DOUBLE: ZVAL_DOUBLE(result, zval_get_double(expr)); @@ -8307,7 +8307,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_R_INDEX_ if (EXPECTED(Z_TYPE_P(dim) == IS_LONG)) { offset = Z_LVAL_P(dim); } else { - offset = zval_get_long(dim); + offset = zval_get_long_ex(dim, /* is_lax */ false); } ht = Z_ARRVAL_P(container); ZEND_HASH_INDEX_FIND(ht, offset, value, fetch_dim_r_index_undef); @@ -10541,6 +10541,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_CONST_ zval retval; zend_call_method_with_0_params(zobj, NULL, NULL, "count", &retval); + // TODO Should this use zval_get_long_ex(&retval, /* is lax */ false); count = zval_get_long(&retval); zval_ptr_dtor(&retval); break; @@ -16101,7 +16102,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_R_INDEX_ if (EXPECTED(Z_TYPE_P(dim) == IS_LONG)) { offset = Z_LVAL_P(dim); } else { - offset = zval_get_long(dim); + offset = zval_get_long_ex(dim, /* is_lax */ false); } ht = Z_ARRVAL_P(container); ZEND_HASH_INDEX_FIND(ht, offset, value, fetch_dim_r_index_undef); @@ -16153,7 +16154,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_R_INDEX_ if (EXPECTED(Z_TYPE_P(dim) == IS_LONG)) { offset = Z_LVAL_P(dim); } else { - offset = zval_get_long(dim); + offset = zval_get_long_ex(dim, /* is_lax */ false); } ht = Z_ARRVAL_P(container); ZEND_HASH_INDEX_FIND(ht, offset, value, fetch_dim_r_index_undef); @@ -17795,6 +17796,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_TMPVAR_UNUSED_HANDL zval retval; zend_call_method_with_0_params(zobj, NULL, NULL, "count", &retval); + // TODO Should this use zval_get_long_ex(&retval, /* is lax */ false); count = zval_get_long(&retval); zval_ptr_dtor(&retval); break; @@ -18958,7 +18960,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CAST_SPEC_TMP_HANDLER(ZEND_OPC switch (opline->extended_value) { case IS_LONG: - ZVAL_LONG(result, zval_get_long_ex(expr, /* lax */ true)); + ZVAL_LONG(result, zval_get_long(expr)); break; case IS_DOUBLE: ZVAL_DOUBLE(result, zval_get_double(expr)); @@ -21572,7 +21574,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CAST_SPEC_VAR_HANDLER(ZEND_OPC switch (opline->extended_value) { case IS_LONG: - ZVAL_LONG(result, zval_get_long_ex(expr, /* lax */ true)); + ZVAL_LONG(result, zval_get_long(expr)); break; case IS_DOUBLE: ZVAL_DOUBLE(result, zval_get_double(expr)); @@ -38100,7 +38102,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CAST_SPEC_CV_HANDLER(ZEND_OPCO switch (opline->extended_value) { case IS_LONG: - ZVAL_LONG(result, zval_get_long_ex(expr, /* lax */ true)); + ZVAL_LONG(result, zval_get_long(expr)); break; case IS_DOUBLE: ZVAL_DOUBLE(result, zval_get_double(expr)); @@ -42563,7 +42565,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_R_INDEX_ if (EXPECTED(Z_TYPE_P(dim) == IS_LONG)) { offset = Z_LVAL_P(dim); } else { - offset = zval_get_long(dim); + offset = zval_get_long_ex(dim, /* is_lax */ false); } ht = Z_ARRVAL_P(container); ZEND_HASH_INDEX_FIND(ht, offset, value, fetch_dim_r_index_undef); @@ -42615,7 +42617,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_R_INDEX_ if (EXPECTED(Z_TYPE_P(dim) == IS_LONG)) { offset = Z_LVAL_P(dim); } else { - offset = zval_get_long(dim); + offset = zval_get_long_ex(dim, /* is_lax */ false); } ht = Z_ARRVAL_P(container); ZEND_HASH_INDEX_FIND(ht, offset, value, fetch_dim_r_index_undef); @@ -47557,6 +47559,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_CV_UNUSED_HANDLER(Z zval retval; zend_call_method_with_0_params(zobj, NULL, NULL, "count", &retval); + // TODO Should this use zval_get_long_ex(&retval, /* is lax */ false); count = zval_get_long(&retval); zval_ptr_dtor(&retval); break; From 20dafcc8731a0a73952d9594fee9e9165245c6d4 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Tue, 13 Apr 2021 13:37:04 +0100 Subject: [PATCH 11/61] Rework is_long_compatible function --- Zend/Optimizer/sccp.c | 24 +++++++++++++++--------- Zend/zend_API.c | 11 +++++++---- Zend/zend_operators.c | 20 ++++++++++++-------- Zend/zend_operators.h | 9 +++++---- 4 files changed, 39 insertions(+), 25 deletions(-) diff --git a/Zend/Optimizer/sccp.c b/Zend/Optimizer/sccp.c index 7e43004591e69..e687ec7f21bf0 100644 --- a/Zend/Optimizer/sccp.c +++ b/Zend/Optimizer/sccp.c @@ -425,12 +425,14 @@ static inline int fetch_array_elem(zval **result, zval *op1, zval *op2) { case IS_LONG: *result = zend_hash_index_find(Z_ARR_P(op1), Z_LVAL_P(op2)); return SUCCESS; - case IS_DOUBLE: - if (!is_long_compatible(Z_DVAL_P(op2))) { + case IS_DOUBLE: { + zend_long lval = zend_dval_to_lval(Z_DVAL_P(op2)); + if (!zend_is_long_compatible(Z_DVAL_P(op2), lval)) { return FAILURE; } - *result = zend_hash_index_find(Z_ARR_P(op1), zend_dval_to_lval(Z_DVAL_P(op2))); + *result = zend_hash_index_find(Z_ARR_P(op1), lval); return SUCCESS; + } case IS_STRING: *result = zend_symtable_find(Z_ARR_P(op1), Z_STR_P(op2)); return SUCCESS; @@ -511,12 +513,14 @@ static inline int ct_eval_del_array_elem(zval *result, zval *key) { case IS_LONG: zend_hash_index_del(Z_ARR_P(result), Z_LVAL_P(key)); break; - case IS_DOUBLE: - if (!is_long_compatible(Z_DVAL_P(key))) { + case IS_DOUBLE: { + zend_long lval = zend_dval_to_lval(Z_DVAL_P(key)); + if (!zend_is_long_compatible(Z_DVAL_P(key), lval)) { return FAILURE; } - zend_hash_index_del(Z_ARR_P(result), zend_dval_to_lval(Z_DVAL_P(key))); + zend_hash_index_del(Z_ARR_P(result), lval); break; + } case IS_STRING: zend_symtable_del(Z_ARR_P(result), Z_STR_P(key)); break; @@ -554,14 +558,16 @@ static inline int ct_eval_add_array_elem(zval *result, zval *value, zval *key) { SEPARATE_ARRAY(result); value = zend_hash_index_update(Z_ARR_P(result), Z_LVAL_P(key), value); break; - case IS_DOUBLE: + case IS_DOUBLE: { + zend_long lval = zend_dval_to_lval(Z_DVAL_P(key)); SEPARATE_ARRAY(result); - if (!is_long_compatible(Z_DVAL_P(key))) { + if (!zend_is_long_compatible(Z_DVAL_P(key), lval)) { return FAILURE; } value = zend_hash_index_update( - Z_ARR_P(result), zend_dval_to_lval(Z_DVAL_P(key)), value); + Z_ARR_P(result), lval, value); break; + } case IS_STRING: SEPARATE_ARRAY(result); value = zend_symtable_update(Z_ARR_P(result), Z_STR_P(key), value); diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 8e811dc849d2d..3021994517ef8 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -503,15 +503,16 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest, if (UNEXPECTED(!ZEND_DOUBLE_FITS_LONG(Z_DVAL_P(arg)))) { return 0; } else { + zend_long lval = zend_dval_to_lval(Z_DVAL_P(arg)); /* Manually check arg_num is not (uint32_t)-1, as otherwise its called by * zend_verify_weak_scalar_type_hint_no_sideeffect() */ - if (UNEXPECTED(!is_long_compatible(Z_DVAL_P(arg)) && arg_num != (uint32_t)-1)) { + if (UNEXPECTED(!zend_is_long_compatible(Z_DVAL_P(arg), lval) && arg_num != (uint32_t)-1)) { zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float %f", Z_DVAL_P(arg)); if (UNEXPECTED(EG(exception))) { return 0; } } - *dest = zend_dval_to_lval(Z_DVAL_P(arg)); + *dest = lval; } } else if (EXPECTED(Z_TYPE_P(arg) == IS_STRING)) { double d; @@ -519,6 +520,7 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest, if (UNEXPECTED((type = is_numeric_str_function(Z_STR_P(arg), dest, &d)) != IS_LONG)) { if (EXPECTED(type != 0)) { + zend_long lval; if (UNEXPECTED(zend_isnan(d))) { return 0; } @@ -526,18 +528,19 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest, return 0; } + lval = zend_dval_to_lval(d); /* This only checks for a fractional part as if doesn't fit it already throws a TypeError * Manually check to get correct warning text mentioning string origin * Check arg_num is not (uint32_t)-1, as otherwise its called by * zend_verify_weak_scalar_type_hint_no_sideeffect() */ - if (UNEXPECTED(!is_long_compatible(d) && arg_num != (uint32_t)-1)) { + if (UNEXPECTED(!zend_is_long_compatible(d, lval) && arg_num != (uint32_t)-1)) { zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float-string %s", Z_STRVAL_P(arg)); if (UNEXPECTED(EG(exception))) { return 0; } } - *dest = zend_dval_to_lval(d); + *dest = lval; } else { return 0; } diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index a84587f3e00e0..7dfc5c0635523 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -305,13 +305,14 @@ static zend_never_inline zend_long ZEND_FASTCALL zendi_try_get_long(zval *op, bo return 1; case IS_DOUBLE: { double dval = Z_DVAL_P(op); - if (!is_long_compatible(dval)) { + zend_long lval = zend_dval_to_lval(dval); + if (!zend_is_long_compatible(dval, lval)) { zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float %f", dval); if (UNEXPECTED(EG(exception))) { *failed = 1; } } - return zend_dval_to_lval(dval); + return lval; } case IS_STRING: { @@ -341,14 +342,15 @@ static zend_never_inline zend_long ZEND_FASTCALL zendi_try_get_long(zval *op, bo * We use use saturating conversion to emulate strtol()'s * behaviour. */ - if (!is_long_compatible(dval)) { + lval = zend_dval_to_lval_cap(dval); + if (!zend_is_long_compatible(dval, lval)) { zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float-string %s", Z_STRVAL_P(op)); if (UNEXPECTED(EG(exception))) { *failed = 1; } } - return zend_dval_to_lval_cap(dval); + return lval; } } case IS_OBJECT: @@ -824,14 +826,15 @@ ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op, bool is_lax) /* {{ return Z_LVAL_P(op); case IS_DOUBLE: { double dval = Z_DVAL_P(op); + zend_long lval = zend_dval_to_lval(dval); if (EXPECTED(!is_lax)) { - if (!is_long_compatible(dval)) { + if (!zend_is_long_compatible(dval, lval)) { zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float %f", dval); // TODO Need to handle this here? //if (UNEXPECTED(EG(exception))) {} } } - return zend_dval_to_lval(dval); + return lval; } case IS_STRING: { @@ -849,15 +852,16 @@ ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op, bool is_lax) /* {{ * behaviour. */ /* Most usages are expected to not be (int) casts */ + lval = zend_dval_to_lval_cap(dval); if (EXPECTED(!is_lax)) { - if (!is_long_compatible(dval)) { + if (!zend_is_long_compatible(dval, lval)) { zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float-string %s", Z_STRVAL_P(op)); // TODO Need to handle this here? //if (UNEXPECTED(EG(exception))) {} } } - return zend_dval_to_lval_cap(dval); + return lval; } } case IS_ARRAY: diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index e7d4a29c03074..0499856e7dfab 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -134,16 +134,17 @@ static zend_always_inline zend_long zend_dval_to_lval_cap(double d) } /* }}} */ -static zend_always_inline bool is_long_compatible(double d) { - return ((double)(zend_long) d == d); +static zend_always_inline bool zend_is_long_compatible(double d, zend_long l) { + return ((double)l == d); } static zend_always_inline zend_long zend_dval_to_lval_safe(double d) { - if (!is_long_compatible(d)) { + zend_long l = zend_dval_to_lval(d); + if (!zend_is_long_compatible(d, l)) { zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float %f", d); } - return zend_dval_to_lval(d); + return l; } #define ZEND_IS_DIGIT(c) ((c) >= '0' && (c) <= '9') From 139aa8f54c94259ea690622ee01ac98a4510247c Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sat, 17 Apr 2021 16:28:56 +0100 Subject: [PATCH 12/61] Move SEPARATE_ARRAY below the check. --- Zend/Optimizer/sccp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/Optimizer/sccp.c b/Zend/Optimizer/sccp.c index e687ec7f21bf0..f85f7c6ae39ec 100644 --- a/Zend/Optimizer/sccp.c +++ b/Zend/Optimizer/sccp.c @@ -560,10 +560,10 @@ static inline int ct_eval_add_array_elem(zval *result, zval *value, zval *key) { break; case IS_DOUBLE: { zend_long lval = zend_dval_to_lval(Z_DVAL_P(key)); - SEPARATE_ARRAY(result); if (!zend_is_long_compatible(Z_DVAL_P(key), lval)) { return FAILURE; } + SEPARATE_ARRAY(result); value = zend_hash_index_update( Z_ARR_P(result), lval, value); break; From f319fe45902c2954231b02faa6cfaecd03872d10 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sat, 17 Apr 2021 16:49:28 +0100 Subject: [PATCH 13/61] Flip is_lax to is_strict --- Zend/zend_compile.c | 4 ++-- Zend/zend_execute.c | 8 ++++---- Zend/zend_operators.c | 9 ++++----- Zend/zend_operators.h | 8 ++++---- Zend/zend_vm_def.h | 4 ++-- Zend/zend_vm_execute.h | 16 ++++++++-------- ext/opcache/jit/zend_jit_helpers.c | 4 ++-- 7 files changed, 26 insertions(+), 27 deletions(-) diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 9e24dfb3269a8..3c473f443397b 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -8197,12 +8197,12 @@ ZEND_API bool zend_binary_op_produces_error(uint32_t opcode, zval *op1, zval *op return 1; } - if ((opcode == ZEND_MOD && zval_get_long_func(op2, /* lax */ true) == 0) + if ((opcode == ZEND_MOD && zval_get_long(op2) == 0) || (opcode == ZEND_DIV && zval_get_double(op2) == 0.0)) { /* Division by zero throws an error. */ return 1; } - if ((opcode == ZEND_SL || opcode == ZEND_SR) && zval_get_long_func(op2, /* lax */ true) < 0) { + if ((opcode == ZEND_SL || opcode == ZEND_SR) && zval_get_long(op2) < 0) { /* Shift by negative number throws an error. */ return 1; } diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 57bc3ce921647..27f704a87c3fd 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -1471,7 +1471,7 @@ static zend_never_inline zend_long zend_check_string_offset(zval *dim, int type break; } - offset = zval_get_long_func(dim, /* lax */ true); + offset = zval_get_long_func(dim, /* is_strict */ false); } else { offset = Z_LVAL_P(dim); } @@ -2453,7 +2453,7 @@ static zend_always_inline void zend_fetch_dimension_address_read(zval *result, z break; } - offset = zval_get_long_func(dim, /* is_lax */ true); + offset = zval_get_long_func(dim, /* is_strict */ false); } else { offset = Z_LVAL_P(dim); } @@ -2598,7 +2598,7 @@ static zend_never_inline bool ZEND_FASTCALL zend_isset_dim_slow(zval *container, if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ || (Z_TYPE_P(offset) == IS_STRING /* or numeric string */ && IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) { - lval = zval_get_long_ex(offset, /* is_lax */ false); + lval = zval_get_long_ex(offset, /* is_strict */ true); goto str_offset; } return 0; @@ -2637,7 +2637,7 @@ static zend_never_inline bool ZEND_FASTCALL zend_isempty_dim_slow(zval *containe if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ || (Z_TYPE_P(offset) == IS_STRING /* or numeric string */ && IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) { - lval = zval_get_long_ex(offset, /* is_lax */ false); + lval = zval_get_long_ex(offset, /* is_strict */ true); goto str_offset; } return 1; diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 7dfc5c0635523..708d4e99b2171 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -342,7 +342,7 @@ static zend_never_inline zend_long ZEND_FASTCALL zendi_try_get_long(zval *op, bo * We use use saturating conversion to emulate strtol()'s * behaviour. */ - lval = zend_dval_to_lval_cap(dval); + lval = zend_dval_to_lval_cap(dval); if (!zend_is_long_compatible(dval, lval)) { zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float-string %s", Z_STRVAL_P(op)); @@ -448,7 +448,6 @@ static zend_never_inline zend_long ZEND_FASTCALL zendi_try_get_long(zval *op, bo } \ } while (0); -/* TODO Should this warn? */ ZEND_API void ZEND_FASTCALL convert_to_long(zval *op) /* {{{ */ { zend_long tmp; @@ -810,7 +809,7 @@ ZEND_API void ZEND_FASTCALL convert_to_object(zval *op) /* {{{ */ } /* }}} */ -ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op, bool is_lax) /* {{{ */ +ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op, bool is_strict) /* {{{ */ { try_again: switch (Z_TYPE_P(op)) { @@ -827,7 +826,7 @@ ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op, bool is_lax) /* {{ case IS_DOUBLE: { double dval = Z_DVAL_P(op); zend_long lval = zend_dval_to_lval(dval); - if (EXPECTED(!is_lax)) { + if (UNEXPECTED(is_strict)) { if (!zend_is_long_compatible(dval, lval)) { zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float %f", dval); // TODO Need to handle this here? @@ -853,7 +852,7 @@ ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op, bool is_lax) /* {{ */ /* Most usages are expected to not be (int) casts */ lval = zend_dval_to_lval_cap(dval); - if (EXPECTED(!is_lax)) { + if (UNEXPECTED(is_strict)) { if (!zend_is_long_compatible(dval, lval)) { zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float-string %s", Z_STRVAL_P(op)); diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index 0499856e7dfab..03c4041b5f93f 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -281,16 +281,16 @@ ZEND_API void ZEND_FASTCALL convert_to_boolean(zval *op); ZEND_API void ZEND_FASTCALL convert_to_array(zval *op); ZEND_API void ZEND_FASTCALL convert_to_object(zval *op); -ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op, bool is_lax); +ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op, bool is_strict); ZEND_API double ZEND_FASTCALL zval_get_double_func(zval *op); ZEND_API zend_string* ZEND_FASTCALL zval_get_string_func(zval *op); ZEND_API zend_string* ZEND_FASTCALL zval_try_get_string_func(zval *op); static zend_always_inline zend_long zval_get_long(zval *op) { - return EXPECTED(Z_TYPE_P(op) == IS_LONG) ? Z_LVAL_P(op) : zval_get_long_func(op, true); + return EXPECTED(Z_TYPE_P(op) == IS_LONG) ? Z_LVAL_P(op) : zval_get_long_func(op, false); } -static zend_always_inline zend_long zval_get_long_ex(zval *op, bool is_lax) { - return EXPECTED(Z_TYPE_P(op) == IS_LONG) ? Z_LVAL_P(op) : zval_get_long_func(op, is_lax); +static zend_always_inline zend_long zval_get_long_ex(zval *op, bool is_strict) { + return EXPECTED(Z_TYPE_P(op) == IS_LONG) ? Z_LVAL_P(op) : zval_get_long_func(op, is_strict); } static zend_always_inline double zval_get_double(zval *op) { return EXPECTED(Z_TYPE_P(op) == IS_DOUBLE) ? Z_DVAL_P(op) : zval_get_double_func(op); diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 979fa57794289..f0d53759b3358 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -9041,7 +9041,7 @@ ZEND_VM_COLD_CONST_HANDLER(190, ZEND_COUNT, CONST|TMPVAR|CV, UNUSED) zval retval; zend_call_method_with_0_params(zobj, NULL, NULL, "count", &retval); - // TODO Should this use zval_get_long_ex(&retval, /* is lax */ false); + // TODO Should this use zval_get_long_ex(&retval, /* is_strict */ false); count = zval_get_long(&retval); zval_ptr_dtor(&retval); break; @@ -9614,7 +9614,7 @@ ZEND_VM_C_LABEL(fetch_dim_r_index_array): if (EXPECTED(Z_TYPE_P(dim) == IS_LONG)) { offset = Z_LVAL_P(dim); } else { - offset = zval_get_long_ex(dim, /* is_lax */ false); + offset = zval_get_long_ex(dim, /* is_strict */ true); } ht = Z_ARRVAL_P(container); ZEND_HASH_INDEX_FIND(ht, offset, value, ZEND_VM_C_LABEL(fetch_dim_r_index_undef)); diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 87170b650e589..3e4e3dd35d598 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -8307,7 +8307,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_R_INDEX_ if (EXPECTED(Z_TYPE_P(dim) == IS_LONG)) { offset = Z_LVAL_P(dim); } else { - offset = zval_get_long_ex(dim, /* is_lax */ false); + offset = zval_get_long_ex(dim, /* is_strict */ true); } ht = Z_ARRVAL_P(container); ZEND_HASH_INDEX_FIND(ht, offset, value, fetch_dim_r_index_undef); @@ -10541,7 +10541,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_CONST_ zval retval; zend_call_method_with_0_params(zobj, NULL, NULL, "count", &retval); - // TODO Should this use zval_get_long_ex(&retval, /* is lax */ false); + // TODO Should this use zval_get_long_ex(&retval, /* is_strict */ false); count = zval_get_long(&retval); zval_ptr_dtor(&retval); break; @@ -16102,7 +16102,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_R_INDEX_ if (EXPECTED(Z_TYPE_P(dim) == IS_LONG)) { offset = Z_LVAL_P(dim); } else { - offset = zval_get_long_ex(dim, /* is_lax */ false); + offset = zval_get_long_ex(dim, /* is_strict */ true); } ht = Z_ARRVAL_P(container); ZEND_HASH_INDEX_FIND(ht, offset, value, fetch_dim_r_index_undef); @@ -16154,7 +16154,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_R_INDEX_ if (EXPECTED(Z_TYPE_P(dim) == IS_LONG)) { offset = Z_LVAL_P(dim); } else { - offset = zval_get_long_ex(dim, /* is_lax */ false); + offset = zval_get_long_ex(dim, /* is_strict */ true); } ht = Z_ARRVAL_P(container); ZEND_HASH_INDEX_FIND(ht, offset, value, fetch_dim_r_index_undef); @@ -17796,7 +17796,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_TMPVAR_UNUSED_HANDL zval retval; zend_call_method_with_0_params(zobj, NULL, NULL, "count", &retval); - // TODO Should this use zval_get_long_ex(&retval, /* is lax */ false); + // TODO Should this use zval_get_long_ex(&retval, /* is_strict */ false); count = zval_get_long(&retval); zval_ptr_dtor(&retval); break; @@ -42565,7 +42565,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_R_INDEX_ if (EXPECTED(Z_TYPE_P(dim) == IS_LONG)) { offset = Z_LVAL_P(dim); } else { - offset = zval_get_long_ex(dim, /* is_lax */ false); + offset = zval_get_long_ex(dim, /* is_strict */ true); } ht = Z_ARRVAL_P(container); ZEND_HASH_INDEX_FIND(ht, offset, value, fetch_dim_r_index_undef); @@ -42617,7 +42617,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_DIM_R_INDEX_ if (EXPECTED(Z_TYPE_P(dim) == IS_LONG)) { offset = Z_LVAL_P(dim); } else { - offset = zval_get_long_ex(dim, /* is_lax */ false); + offset = zval_get_long_ex(dim, /* is_strict */ true); } ht = Z_ARRVAL_P(container); ZEND_HASH_INDEX_FIND(ht, offset, value, fetch_dim_r_index_undef); @@ -47559,7 +47559,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_CV_UNUSED_HANDLER(Z zval retval; zend_call_method_with_0_params(zobj, NULL, NULL, "count", &retval); - // TODO Should this use zval_get_long_ex(&retval, /* is lax */ false); + // TODO Should this use zval_get_long_ex(&retval, /* is_strict */ false); count = zval_get_long(&retval); zval_ptr_dtor(&retval); break; diff --git a/ext/opcache/jit/zend_jit_helpers.c b/ext/opcache/jit/zend_jit_helpers.c index 53b921439fd67..e3a873b56b4bc 100644 --- a/ext/opcache/jit/zend_jit_helpers.c +++ b/ext/opcache/jit/zend_jit_helpers.c @@ -736,7 +736,7 @@ static zend_never_inline zend_long zend_check_string_offset(zval *dim/*, int typ break; } - return zval_get_long_func(dim, /* is_lax */ true); + return zval_get_long_func(dim, /* is_strict */ false); } static zend_always_inline zend_string* zend_jit_fetch_dim_str_offset(zend_string *str, zend_long offset) @@ -803,7 +803,7 @@ static void ZEND_FASTCALL zend_jit_fetch_dim_str_is_helper(zend_string *str, zva break; } - offset = zval_get_long_func(dim, /* is_lax */ true); + offset = zval_get_long_func(dim, /* is_strict */ false); } else { offset = Z_LVAL_P(dim); } From 0d678bf8bea42a3e8dedac8c2f49a6e48d306095 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sat, 17 Apr 2021 16:55:59 +0100 Subject: [PATCH 14/61] Make sprintf family of functions warn on incompatible float to int conversion --- ext/standard/formatted_print.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c index 0990b390d6b29..2854f7f572c05 100644 --- a/ext/standard/formatted_print.c +++ b/ext/standard/formatted_print.c @@ -634,15 +634,14 @@ php_formatted_print(char *format, size_t format_len, zval *args, int argc, int n case 'd': php_sprintf_appendint(&result, &outpos, - zval_get_long(tmp), - width, padding, alignment, - always_sign); + zval_get_long_ex(tmp, /* is_strict */ true), + width, padding, alignment, always_sign); break; case 'u': php_sprintf_appenduint(&result, &outpos, - zval_get_long(tmp), - width, padding, alignment); + zval_get_long_ex(tmp, /* is_strict */ true), + width, padding, alignment); break; case 'e': @@ -663,35 +662,31 @@ php_formatted_print(char *format, size_t format_len, zval *args, int argc, int n case 'c': php_sprintf_appendchar(&result, &outpos, - (char) zval_get_long(tmp)); + (char) zval_get_long_ex(tmp, /* is_strict */ true)); break; case 'o': php_sprintf_append2n(&result, &outpos, - zval_get_long(tmp), - width, padding, alignment, 3, - hexchars, expprec); + zval_get_long_ex(tmp, /* is_strict */ true), + width, padding, alignment, 3, hexchars, expprec); break; case 'x': php_sprintf_append2n(&result, &outpos, - zval_get_long(tmp), - width, padding, alignment, 4, - hexchars, expprec); + zval_get_long_ex(tmp, /* is_strict */ true), + width, padding, alignment, 4, hexchars, expprec); break; case 'X': php_sprintf_append2n(&result, &outpos, - zval_get_long(tmp), - width, padding, alignment, 4, - HEXCHARS, expprec); + zval_get_long_ex(tmp, /* is_strict */ true), + width, padding, alignment, 4, HEXCHARS, expprec); break; case 'b': php_sprintf_append2n(&result, &outpos, - zval_get_long(tmp), - width, padding, alignment, 1, - hexchars, expprec); + zval_get_long_ex(tmp, /* is_strict */ true), + width, padding, alignment, 1, hexchars, expprec); break; case '%': From d2ee140da4ffa6594946ec7e23d07b15c54349f9 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sat, 17 Apr 2021 17:00:47 +0100 Subject: [PATCH 15/61] intval() is like (int) cast --- .../tests/general_functions/intval_variation1.phpt | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/ext/standard/tests/general_functions/intval_variation1.phpt b/ext/standard/tests/general_functions/intval_variation1.phpt index fab896cd83d6b..c18910a1d8023 100644 --- a/ext/standard/tests/general_functions/intval_variation1.phpt +++ b/ext/standard/tests/general_functions/intval_variation1.phpt @@ -109,28 +109,18 @@ int(12345) int(-2345) --float 10.5-- - -Deprecated: Implicit conversion to int from non-compatible float 10.500000 in %s on line %d int(10) --float -10.5-- - -Deprecated: Implicit conversion to int from non-compatible float -10.500000 in %s on line %d int(-10) --float 12.3456789e5-- - -Deprecated: Implicit conversion to int from non-compatible float 1234567.890000 in %s on line %d int(1234567) --float -12.3456789e5-- - -Deprecated: Implicit conversion to int from non-compatible float -1234567.890000 in %s on line %d int(-1234567) --float .5-- - -Deprecated: Implicit conversion to int from non-compatible float 0.500000 in %s on line %d int(0) --empty array-- From 8bacb861c7f9b4264175829954fb17836959d295 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sat, 17 Apr 2021 17:03:26 +0100 Subject: [PATCH 16/61] Fix jit with incompatible float to long for isset --- ext/opcache/jit/zend_jit_helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/opcache/jit/zend_jit_helpers.c b/ext/opcache/jit/zend_jit_helpers.c index e3a873b56b4bc..e7f98665fba7a 100644 --- a/ext/opcache/jit/zend_jit_helpers.c +++ b/ext/opcache/jit/zend_jit_helpers.c @@ -1282,7 +1282,7 @@ static int ZEND_FASTCALL zend_jit_isset_dim_helper(zval *container, zval *offset if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ || (Z_TYPE_P(offset) == IS_STRING /* or numeric string */ && IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, false))) { - lval = zval_get_long(offset); + lval = zval_get_long_ex(offset, /* is_strict */ true); goto isset_str_offset; } } From f2269545ece26de4a18dfe2afd271d355e915fbb Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sat, 17 Apr 2021 17:12:01 +0100 Subject: [PATCH 17/61] Extract float to int deprecation message into own function --- Zend/zend_operators.c | 9 +++++++-- Zend/zend_operators.h | 4 +++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 708d4e99b2171..257f0e23c9d06 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -307,7 +307,7 @@ static zend_never_inline zend_long ZEND_FASTCALL zendi_try_get_long(zval *op, bo double dval = Z_DVAL_P(op); zend_long lval = zend_dval_to_lval(dval); if (!zend_is_long_compatible(dval, lval)) { - zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float %f", dval); + zend_incompatible_double_to_long_error(dval); if (UNEXPECTED(EG(exception))) { *failed = 1; } @@ -809,6 +809,11 @@ ZEND_API void ZEND_FASTCALL convert_to_object(zval *op) /* {{{ */ } /* }}} */ +void zend_incompatible_double_to_long_error(double d) +{ + zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float %f", d); +} + ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op, bool is_strict) /* {{{ */ { try_again: @@ -828,7 +833,7 @@ ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op, bool is_strict) /* zend_long lval = zend_dval_to_lval(dval); if (UNEXPECTED(is_strict)) { if (!zend_is_long_compatible(dval, lval)) { - zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float %f", dval); + zend_incompatible_double_to_long_error(dval); // TODO Need to handle this here? //if (UNEXPECTED(EG(exception))) {} } diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index 03c4041b5f93f..edfd93c13ad24 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -138,11 +138,13 @@ static zend_always_inline bool zend_is_long_compatible(double d, zend_long l) { return ((double)l == d); } +void zend_incompatible_double_to_long_error(double d); + static zend_always_inline zend_long zend_dval_to_lval_safe(double d) { zend_long l = zend_dval_to_lval(d); if (!zend_is_long_compatible(d, l)) { - zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float %f", d); + zend_incompatible_double_to_long_error(d); } return l; } From 4913890a880ac9db87e4a5258a37683ef3bca3f4 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sat, 17 Apr 2021 17:26:23 +0100 Subject: [PATCH 18/61] Rephrase deprecation message --- Zend/tests/array_offset.phpt | 4 +- Zend/tests/constant_expressions_dynamic.phpt | 2 +- Zend/tests/empty_str_offset.phpt | 18 ++-- ...g_float_does_not_fit_zend_long_arrays.phpt | 8 +- .../float_to_int/warnings_float_literals.phpt | 24 +++--- ...arnings_float_literals_assignment_ops.phpt | 12 +-- .../float_to_int/warnings_float_vars.phpt | 28 +++---- Zend/tests/isset_array.phpt | 2 +- Zend/tests/isset_str_offset.phpt | 16 ++-- Zend/tests/list_keyed_conversions.phpt | 2 +- Zend/tests/not_001.phpt | 2 +- Zend/tests/offset_array.phpt | 2 +- Zend/tests/operator_unsupported_types.phpt | 84 +++++++++---------- Zend/zend_operators.c | 2 +- ext/session/tests/session_encode_error2.phpt | 8 +- .../iterator_to_array_nonscalar_keys.phpt | 2 +- .../tests/array/array_combine_variation4.phpt | 2 +- .../array_intersect_assoc_variation5.phpt | 2 +- .../array_intersect_assoc_variation6.phpt | 2 +- .../array/array_intersect_variation5.phpt | 2 +- .../array/array_intersect_variation6.phpt | 2 +- .../array/array_key_exists_variation3.phpt | 6 +- .../tests/array/array_map_variation4.phpt | 2 +- .../tests/array/array_reverse_variation4.phpt | 2 +- .../tests/array/array_unshift_variation4.phpt | 2 +- ext/standard/tests/array/bug68553.phpt | 2 +- .../tests/array/usort_variation3.phpt | 2 +- .../tests/file/disk_free_space_basic.phpt | 6 +- .../tests/strings/bug23894_64bit.phpt | 4 +- ext/standard/tests/strings/bug47842.phpt | 2 +- .../tests/strings/fprintf_variation_002.phpt | 32 +++---- .../strings/fprintf_variation_003_64bit.phpt | 4 +- .../strings/fprintf_variation_006_64bit.phpt | 4 +- .../strings/fprintf_variation_007_64bit.phpt | 4 +- .../strings/fprintf_variation_008_64bit.phpt | 4 +- ext/standard/tests/strings/printf_64bit.phpt | 48 +++++------ ext/standard/tests/strings/sprintf_f_2.phpt | 16 ++-- .../strings/vprintf_variation12_64bit.phpt | 28 +++---- .../strings/vprintf_variation14_64bit.phpt | 28 +++---- .../strings/vprintf_variation15_64bit.phpt | 2 +- .../strings/vprintf_variation16_64bit.phpt | 28 +++---- .../strings/vprintf_variation4_64bit.phpt | 28 +++---- .../operators/bitwiseNot_basiclong_64bit.phpt | 2 +- 43 files changed, 242 insertions(+), 240 deletions(-) diff --git a/Zend/tests/array_offset.phpt b/Zend/tests/array_offset.phpt index f3e9955ca0852..09a10c7429e42 100644 --- a/Zend/tests/array_offset.phpt +++ b/Zend/tests/array_offset.phpt @@ -13,13 +13,13 @@ echo "Done\n"; --EXPECTF-- Warning: Undefined array key -1 in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float -1.100000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -1.1 to int in %s on line %d Warning: Undefined array key -1 in %s on line %d Warning: Undefined array key -1 in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float -1.100000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -1.1 to int in %s on line %d Warning: Undefined array key -1 in %s on line %d Done diff --git a/Zend/tests/constant_expressions_dynamic.phpt b/Zend/tests/constant_expressions_dynamic.phpt index c80a5e4e5f8e1..ea148c9ecf4ae 100644 --- a/Zend/tests/constant_expressions_dynamic.phpt +++ b/Zend/tests/constant_expressions_dynamic.phpt @@ -47,7 +47,7 @@ var_dump( --EXPECTF-- Warning: A non-numeric value encountered in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 3.140000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 3.14 to int in %s on line %d int(3) string(4) "1foo" bool(false) diff --git a/Zend/tests/empty_str_offset.phpt b/Zend/tests/empty_str_offset.phpt index 3fc6e290ab5c8..3ca72e8daf39d 100644 --- a/Zend/tests/empty_str_offset.phpt +++ b/Zend/tests/empty_str_offset.phpt @@ -99,31 +99,31 @@ bool(true) bool(false) - double --- -Deprecated: Implicit conversion to int from non-compatible float -1.100000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -1.1 to int in %s on line %d bool(false) -Deprecated: Implicit conversion to int from non-compatible float -10.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -10.5 to int in %s on line %d bool(true) -Deprecated: Implicit conversion to int from non-compatible float -4.100000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -4.1 to int in %s on line %d bool(true) -Deprecated: Implicit conversion to int from non-compatible float -0.800000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -0.8 to int in %s on line %d bool(false) -Deprecated: Implicit conversion to int from non-compatible float -0.100000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -0.1 to int in %s on line %d bool(false) -Deprecated: Implicit conversion to int from non-compatible float 0.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 0.2 to int in %s on line %d bool(false) -Deprecated: Implicit conversion to int from non-compatible float 0.900000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 0.9 to int in %s on line %d bool(false) -Deprecated: Implicit conversion to int from non-compatible float 3.141593 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 3.141592653589793 to int in %s on line %d bool(false) -Deprecated: Implicit conversion to int from non-compatible float 100.500100 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 100.5001 to int in %s on line %d bool(true) - array --- bool(true) diff --git a/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_arrays.phpt b/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_arrays.phpt index 01f329806d5cb..4e961a9d45632 100644 --- a/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_arrays.phpt +++ b/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_arrays.phpt @@ -26,9 +26,9 @@ var_dump($array[$string_float]); int(0) int(9223372036854775807) -Deprecated: Implicit conversion to int from non-compatible float 10000000000000000373409337471459889719393275754491820381027730410378005080671497101378613371421126415052399029342192009216.000000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.0E+121 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 10000000000000000373409337471459889719393275754491820381027730410378005080671497101378613371421126415052399029342192009216.000000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.0E+121 to int in %s on line %d array(2) { [0]=> string(11) "Large float" @@ -42,13 +42,13 @@ array(2) { string(18) "String large float" } -Deprecated: Implicit conversion to int from non-compatible float 10000000000000000373409337471459889719393275754491820381027730410378005080671497101378613371421126415052399029342192009216.000000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.0E+121 to int in %s on line %d string(1) "0" Warning: Undefined array key "1.0E+121" in %s on line %d NULL -Deprecated: Implicit conversion to int from non-compatible float 10000000000000000373409337471459889719393275754491820381027730410378005080671497101378613371421126415052399029342192009216.000000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.0E+121 to int in %s on line %d string(1) "0" Warning: Undefined array key "1.0E+121" in %s on line %d diff --git a/Zend/tests/float_to_int/warnings_float_literals.phpt b/Zend/tests/float_to_int/warnings_float_literals.phpt index b0cc8a684d81b..1c325e57519ec 100644 --- a/Zend/tests/float_to_int/warnings_float_literals.phpt +++ b/Zend/tests/float_to_int/warnings_float_literals.phpt @@ -69,25 +69,25 @@ var_dump($instance->a); ?> --EXPECTF-- -Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 6.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 6.5 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d Bitwise ops: int(-2) int(3) @@ -103,10 +103,10 @@ int(1) Offset access: Arrays: -Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d string(1) "b" -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d array(3) { [0]=> string(1) "a" diff --git a/Zend/tests/float_to_int/warnings_float_literals_assignment_ops.phpt b/Zend/tests/float_to_int/warnings_float_literals_assignment_ops.phpt index 25663038ce674..17d7cca8d0e43 100644 --- a/Zend/tests/float_to_int/warnings_float_literals_assignment_ops.phpt +++ b/Zend/tests/float_to_int/warnings_float_literals_assignment_ops.phpt @@ -34,21 +34,21 @@ var_dump($var); --EXPECTF-- Bitwise ops: -Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d int(3) -Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d int(1) -Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d int(2) -Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d int(6) -Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d int(1) Modulo: -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d int(1) diff --git a/Zend/tests/float_to_int/warnings_float_vars.phpt b/Zend/tests/float_to_int/warnings_float_vars.phpt index fe63c75b66104..98049663ded32 100644 --- a/Zend/tests/float_to_int/warnings_float_vars.phpt +++ b/Zend/tests/float_to_int/warnings_float_vars.phpt @@ -93,49 +93,49 @@ var_dump($instance->a); --EXPECTF-- Bitwise ops: -Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d int(-2) -Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d int(3) -Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d int(1) -Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d int(2) -Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d int(8) -Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d int(0) -Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d int(8) -Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d int(0) -Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d int(6) -Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d int(1) Modulo: -Deprecated: Implicit conversion to int from non-compatible float 6.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 6.5 to int in %s on line %d int(0) -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d int(1) Offset access: Arrays: -Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d string(1) "b" -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d array(3) { [0]=> string(1) "a" diff --git a/Zend/tests/isset_array.phpt b/Zend/tests/isset_array.phpt index 91fd76bff0c04..70ad03084a611 100644 --- a/Zend/tests/isset_array.phpt +++ b/Zend/tests/isset_array.phpt @@ -39,7 +39,7 @@ bool(true) bool(true) bool(true) -Deprecated: Implicit conversion to int from non-compatible float 0.600000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 0.6 to int in %s on line %d bool(true) bool(false) bool(false) diff --git a/Zend/tests/isset_str_offset.phpt b/Zend/tests/isset_str_offset.phpt index 5e31f3bb02c2d..252f913586288 100644 --- a/Zend/tests/isset_str_offset.phpt +++ b/Zend/tests/isset_str_offset.phpt @@ -96,28 +96,28 @@ bool(false) bool(true) - double --- -Deprecated: Implicit conversion to int from non-compatible float -1.100000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -1.1 to int in %s on line %d bool(true) -Deprecated: Implicit conversion to int from non-compatible float -10.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -10.5 to int in %s on line %d bool(false) -Deprecated: Implicit conversion to int from non-compatible float -0.800000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -0.8 to int in %s on line %d bool(true) -Deprecated: Implicit conversion to int from non-compatible float -0.100000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -0.1 to int in %s on line %d bool(true) -Deprecated: Implicit conversion to int from non-compatible float 0.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 0.2 to int in %s on line %d bool(true) -Deprecated: Implicit conversion to int from non-compatible float 0.900000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 0.9 to int in %s on line %d bool(true) -Deprecated: Implicit conversion to int from non-compatible float 3.141593 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 3.141592653589793 to int in %s on line %d bool(true) -Deprecated: Implicit conversion to int from non-compatible float 100.500100 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 100.5001 to int in %s on line %d bool(false) - array --- bool(false) diff --git a/Zend/tests/list_keyed_conversions.phpt b/Zend/tests/list_keyed_conversions.phpt index 129e7cd0cf0f0..71f4c0759960b 100644 --- a/Zend/tests/list_keyed_conversions.phpt +++ b/Zend/tests/list_keyed_conversions.phpt @@ -21,7 +21,7 @@ list(STDIN => $resource) = []; ?> --EXPECTF-- -Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d string(0) "" int(1) int(0) diff --git a/Zend/tests/not_001.phpt b/Zend/tests/not_001.phpt index e5b6368168525..d45a3734c99be 100644 --- a/Zend/tests/not_001.phpt +++ b/Zend/tests/not_001.phpt @@ -17,7 +17,7 @@ var_dump(bin2hex($s1)); echo "Done\n"; ?> --EXPECTF-- -Deprecated: Implicit conversion to int from non-compatible float 23.670000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 23.67 to int in %s on line %d int(-24) string(8) "8c90929a" Done diff --git a/Zend/tests/offset_array.phpt b/Zend/tests/offset_array.phpt index 08a2b47cd326b..fc646704f4f50 100644 --- a/Zend/tests/offset_array.phpt +++ b/Zend/tests/offset_array.phpt @@ -35,7 +35,7 @@ echo "Done\n"; --EXPECTF-- int(2) -Deprecated: Implicit conversion to int from non-compatible float 0.083600 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 0.0836 to int in %s on line %d int(1) Warning: Undefined array key "" in %s on line %d diff --git a/Zend/tests/operator_unsupported_types.phpt b/Zend/tests/operator_unsupported_types.phpt index 030750022aa3c..9ba94895b31d3 100644 --- a/Zend/tests/operator_unsupported_types.phpt +++ b/Zend/tests/operator_unsupported_types.phpt @@ -453,7 +453,7 @@ Unsupported operand types: bool % array Unsupported operand types: array % int Unsupported operand types: int % array Unsupported operand types: array % float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float % array Unsupported operand types: array % string Unsupported operand types: string % array @@ -469,7 +469,7 @@ Unsupported operand types: bool % stdClass Unsupported operand types: stdClass % int Unsupported operand types: int % stdClass Unsupported operand types: stdClass % float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float % stdClass Unsupported operand types: stdClass % string Unsupported operand types: string % stdClass @@ -485,7 +485,7 @@ Unsupported operand types: bool % resource Unsupported operand types: resource % int Unsupported operand types: int % resource Unsupported operand types: resource % float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float % resource Unsupported operand types: resource % string Unsupported operand types: string % resource @@ -501,7 +501,7 @@ Unsupported operand types: bool % string Unsupported operand types: string % int Unsupported operand types: int % string Unsupported operand types: string % float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float % string Unsupported operand types: string % string Unsupported operand types: string % string @@ -609,7 +609,7 @@ Unsupported operand types: bool << array Unsupported operand types: array << int Unsupported operand types: int << array Unsupported operand types: array << float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float << array Unsupported operand types: array << string Unsupported operand types: string << array @@ -625,7 +625,7 @@ Unsupported operand types: bool << stdClass Unsupported operand types: stdClass << int Unsupported operand types: int << stdClass Unsupported operand types: stdClass << float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float << stdClass Unsupported operand types: stdClass << string Unsupported operand types: string << stdClass @@ -641,7 +641,7 @@ Unsupported operand types: bool << resource Unsupported operand types: resource << int Unsupported operand types: int << resource Unsupported operand types: resource << float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float << resource Unsupported operand types: resource << string Unsupported operand types: string << resource @@ -657,7 +657,7 @@ Unsupported operand types: bool << string Unsupported operand types: string << int Unsupported operand types: int << string Unsupported operand types: string << float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float << string Unsupported operand types: string << string Unsupported operand types: string << string @@ -689,7 +689,7 @@ Unsupported operand types: bool >> array Unsupported operand types: array >> int Unsupported operand types: int >> array Unsupported operand types: array >> float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float >> array Unsupported operand types: array >> string Unsupported operand types: string >> array @@ -705,7 +705,7 @@ Unsupported operand types: bool >> stdClass Unsupported operand types: stdClass >> int Unsupported operand types: int >> stdClass Unsupported operand types: stdClass >> float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float >> stdClass Unsupported operand types: stdClass >> string Unsupported operand types: string >> stdClass @@ -721,7 +721,7 @@ Unsupported operand types: bool >> resource Unsupported operand types: resource >> int Unsupported operand types: int >> resource Unsupported operand types: resource >> float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float >> resource Unsupported operand types: resource >> string Unsupported operand types: string >> resource @@ -737,7 +737,7 @@ Unsupported operand types: bool >> string Unsupported operand types: string >> int Unsupported operand types: int >> string Unsupported operand types: string >> float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float >> string Unsupported operand types: string >> string Unsupported operand types: string >> string @@ -769,7 +769,7 @@ Unsupported operand types: bool & array Unsupported operand types: array & int Unsupported operand types: int & array Unsupported operand types: array & float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float & array Unsupported operand types: array & string Unsupported operand types: string & array @@ -813,7 +813,7 @@ Unsupported operand types: bool & string Unsupported operand types: string & int Unsupported operand types: int & string Unsupported operand types: string & float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float & string No error for "foo" & "123" No error for "123" & "foo" @@ -844,7 +844,7 @@ Unsupported operand types: bool | array Unsupported operand types: array | int Unsupported operand types: int | array Unsupported operand types: array | float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float | array Unsupported operand types: array | string Unsupported operand types: string | array @@ -888,7 +888,7 @@ Unsupported operand types: bool | string Unsupported operand types: string | int Unsupported operand types: int | string Unsupported operand types: string | float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float | string No error for "foo" | "123" No error for "123" | "foo" @@ -919,7 +919,7 @@ Unsupported operand types: bool ^ array Unsupported operand types: array ^ int Unsupported operand types: int ^ array Unsupported operand types: array ^ float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float ^ array Unsupported operand types: array ^ string Unsupported operand types: string ^ array @@ -963,7 +963,7 @@ Unsupported operand types: bool ^ string Unsupported operand types: string ^ int Unsupported operand types: int ^ string Unsupported operand types: string ^ float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float ^ string No error for "foo" ^ "123" No error for "123" ^ "foo" @@ -1467,7 +1467,7 @@ Unsupported operand types: bool % array Unsupported operand types: array % int Unsupported operand types: int % array Unsupported operand types: array % float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float % array Unsupported operand types: array % string Unsupported operand types: string % array @@ -1483,7 +1483,7 @@ Unsupported operand types: bool % stdClass Unsupported operand types: stdClass % int Unsupported operand types: int % stdClass Unsupported operand types: stdClass % float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float % stdClass Unsupported operand types: stdClass % string Unsupported operand types: string % stdClass @@ -1499,7 +1499,7 @@ Unsupported operand types: bool % resource Unsupported operand types: resource % int Unsupported operand types: int % resource Unsupported operand types: resource % float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float % resource Unsupported operand types: resource % string Unsupported operand types: string % resource @@ -1515,7 +1515,7 @@ Unsupported operand types: bool % string Unsupported operand types: string % int Unsupported operand types: int % string Unsupported operand types: string % float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float % string Unsupported operand types: string % string Unsupported operand types: string % string @@ -1623,7 +1623,7 @@ Unsupported operand types: bool << array Unsupported operand types: array << int Unsupported operand types: int << array Unsupported operand types: array << float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float << array Unsupported operand types: array << string Unsupported operand types: string << array @@ -1639,7 +1639,7 @@ Unsupported operand types: bool << stdClass Unsupported operand types: stdClass << int Unsupported operand types: int << stdClass Unsupported operand types: stdClass << float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float << stdClass Unsupported operand types: stdClass << string Unsupported operand types: string << stdClass @@ -1655,7 +1655,7 @@ Unsupported operand types: bool << resource Unsupported operand types: resource << int Unsupported operand types: int << resource Unsupported operand types: resource << float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float << resource Unsupported operand types: resource << string Unsupported operand types: string << resource @@ -1671,7 +1671,7 @@ Unsupported operand types: bool << string Unsupported operand types: string << int Unsupported operand types: int << string Unsupported operand types: string << float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float << string Unsupported operand types: string << string Unsupported operand types: string << string @@ -1703,7 +1703,7 @@ Unsupported operand types: bool >> array Unsupported operand types: array >> int Unsupported operand types: int >> array Unsupported operand types: array >> float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float >> array Unsupported operand types: array >> string Unsupported operand types: string >> array @@ -1719,7 +1719,7 @@ Unsupported operand types: bool >> stdClass Unsupported operand types: stdClass >> int Unsupported operand types: int >> stdClass Unsupported operand types: stdClass >> float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float >> stdClass Unsupported operand types: stdClass >> string Unsupported operand types: string >> stdClass @@ -1735,7 +1735,7 @@ Unsupported operand types: bool >> resource Unsupported operand types: resource >> int Unsupported operand types: int >> resource Unsupported operand types: resource >> float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float >> resource Unsupported operand types: resource >> string Unsupported operand types: string >> resource @@ -1751,7 +1751,7 @@ Unsupported operand types: bool >> string Unsupported operand types: string >> int Unsupported operand types: int >> string Unsupported operand types: string >> float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float >> string Unsupported operand types: string >> string Unsupported operand types: string >> string @@ -1783,7 +1783,7 @@ Unsupported operand types: bool & array Unsupported operand types: array & int Unsupported operand types: int & array Unsupported operand types: array & float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float & array Unsupported operand types: array & string Unsupported operand types: string & array @@ -1799,7 +1799,7 @@ Unsupported operand types: bool & stdClass Unsupported operand types: stdClass & int Unsupported operand types: int & stdClass Unsupported operand types: stdClass & float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float & stdClass Unsupported operand types: stdClass & string Unsupported operand types: string & stdClass @@ -1815,7 +1815,7 @@ Unsupported operand types: bool & resource Unsupported operand types: resource & int Unsupported operand types: int & resource Unsupported operand types: resource & float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float & resource Unsupported operand types: resource & string Unsupported operand types: string & resource @@ -1831,7 +1831,7 @@ Unsupported operand types: bool & string Unsupported operand types: string & int Unsupported operand types: int & string Unsupported operand types: string & float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float & string No error for "foo" &= "123" No error for "123" &= "foo" @@ -1862,7 +1862,7 @@ Unsupported operand types: bool | array Unsupported operand types: array | int Unsupported operand types: int | array Unsupported operand types: array | float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float | array Unsupported operand types: array | string Unsupported operand types: string | array @@ -1878,7 +1878,7 @@ Unsupported operand types: bool | stdClass Unsupported operand types: stdClass | int Unsupported operand types: int | stdClass Unsupported operand types: stdClass | float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float | stdClass Unsupported operand types: stdClass | string Unsupported operand types: string | stdClass @@ -1894,7 +1894,7 @@ Unsupported operand types: bool | resource Unsupported operand types: resource | int Unsupported operand types: int | resource Unsupported operand types: resource | float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float | resource Unsupported operand types: resource | string Unsupported operand types: string | resource @@ -1910,7 +1910,7 @@ Unsupported operand types: bool | string Unsupported operand types: string | int Unsupported operand types: int | string Unsupported operand types: string | float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float | string No error for "foo" |= "123" No error for "123" |= "foo" @@ -1941,7 +1941,7 @@ Unsupported operand types: bool ^ array Unsupported operand types: array ^ int Unsupported operand types: int ^ array Unsupported operand types: array ^ float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float ^ array Unsupported operand types: array ^ string Unsupported operand types: string ^ array @@ -1957,7 +1957,7 @@ Unsupported operand types: bool ^ stdClass Unsupported operand types: stdClass ^ int Unsupported operand types: int ^ stdClass Unsupported operand types: stdClass ^ float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float ^ stdClass Unsupported operand types: stdClass ^ string Unsupported operand types: string ^ stdClass @@ -1973,7 +1973,7 @@ Unsupported operand types: bool ^ resource Unsupported operand types: resource ^ int Unsupported operand types: int ^ resource Unsupported operand types: resource ^ float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float ^ resource Unsupported operand types: resource ^ string Unsupported operand types: string ^ resource @@ -1989,7 +1989,7 @@ Unsupported operand types: bool ^ string Unsupported operand types: string ^ int Unsupported operand types: int ^ string Unsupported operand types: string ^ float -Warning: Implicit conversion to int from non-compatible float 3.500000 +Warning: Implicit conversion from non-compatible float 3.5 to int Unsupported operand types: float ^ string No error for "foo" ^= "123" No error for "123" ^= "foo" diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 257f0e23c9d06..c94848687faa9 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -811,7 +811,7 @@ ZEND_API void ZEND_FASTCALL convert_to_object(zval *op) /* {{{ */ void zend_incompatible_double_to_long_error(double d) { - zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float %f", d); + zend_error(E_DEPRECATED, "Implicit conversion from non-compatible float %.*H to int", -1, d); } ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op, bool is_strict) /* {{{ */ diff --git a/ext/session/tests/session_encode_error2.phpt b/ext/session/tests/session_encode_error2.phpt index b8f41e93efad1..426053df8a665 100644 --- a/ext/session/tests/session_encode_error2.phpt +++ b/ext/session/tests/session_encode_error2.phpt @@ -126,7 +126,7 @@ bool(true) -- Iteration 5 -- bool(true) -Deprecated: Implicit conversion to int from non-compatible float 10.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 10.5 to int in %s on line %d Warning: session_encode(): Skipping numeric key 10 in %s on line %d bool(false) @@ -135,7 +135,7 @@ bool(true) -- Iteration 6 -- bool(true) -Deprecated: Implicit conversion to int from non-compatible float -10.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -10.5 to int in %s on line %d Warning: session_encode(): Skipping numeric key -10 in %s on line %d bool(false) @@ -151,7 +151,7 @@ bool(true) -- Iteration 8 -- bool(true) -Deprecated: Implicit conversion to int from non-compatible float 0.000000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.23456789E-9 to int in %s on line %d Warning: session_encode(): Skipping numeric key 0 in %s on line %d bool(false) @@ -160,7 +160,7 @@ bool(true) -- Iteration 9 -- bool(true) -Deprecated: Implicit conversion to int from non-compatible float 0.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 0.5 to int in %s on line %d Warning: session_encode(): Skipping numeric key 0 in %s on line %d bool(false) diff --git a/ext/spl/tests/iterator_to_array_nonscalar_keys.phpt b/ext/spl/tests/iterator_to_array_nonscalar_keys.phpt index 30470e7c467bb..cb9917368e664 100644 --- a/ext/spl/tests/iterator_to_array_nonscalar_keys.phpt +++ b/ext/spl/tests/iterator_to_array_nonscalar_keys.phpt @@ -20,5 +20,5 @@ try { ?> --EXPECTF-- -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d Illegal offset type diff --git a/ext/standard/tests/array/array_combine_variation4.phpt b/ext/standard/tests/array/array_combine_variation4.phpt index b72f43aa97d7d..511c114de2b3e 100644 --- a/ext/standard/tests/array/array_combine_variation4.phpt +++ b/ext/standard/tests/array/array_combine_variation4.phpt @@ -82,7 +82,7 @@ Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 444.432000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 444.432 to int in %s on line %d -- Iteration 1 -- array(0) { } diff --git a/ext/standard/tests/array/array_intersect_assoc_variation5.phpt b/ext/standard/tests/array/array_intersect_assoc_variation5.phpt index 078adec20e7b8..bceffb9f765e5 100644 --- a/ext/standard/tests/array/array_intersect_assoc_variation5.phpt +++ b/ext/standard/tests/array/array_intersect_assoc_variation5.phpt @@ -70,7 +70,7 @@ echo "Done"; --EXPECTF-- *** Testing array_intersect_assoc() : assoc array with diff keys to $arr1 argument *** -Deprecated: Implicit conversion to int from non-compatible float 444.432000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 444.432 to int in %s on line %d -- Iteration 1 -- array(0) { } diff --git a/ext/standard/tests/array/array_intersect_assoc_variation6.phpt b/ext/standard/tests/array/array_intersect_assoc_variation6.phpt index f2eb859d73e9b..e2b048ed741a3 100644 --- a/ext/standard/tests/array/array_intersect_assoc_variation6.phpt +++ b/ext/standard/tests/array/array_intersect_assoc_variation6.phpt @@ -70,7 +70,7 @@ echo "Done"; --EXPECTF-- *** Testing array_intersect_assoc() : assoc array with diff keys to $arr2 argument *** -Deprecated: Implicit conversion to int from non-compatible float 444.432000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 444.432 to int in %s on line %d -- Iteration 1 -- array(0) { } diff --git a/ext/standard/tests/array/array_intersect_variation5.phpt b/ext/standard/tests/array/array_intersect_variation5.phpt index d6be42e61f663..92405c42dae2f 100644 --- a/ext/standard/tests/array/array_intersect_variation5.phpt +++ b/ext/standard/tests/array/array_intersect_variation5.phpt @@ -68,7 +68,7 @@ echo "Done"; --EXPECTF-- *** Testing array_intersect() : assoc array with diff keys to $arr1 argument *** -Deprecated: Implicit conversion to int from non-compatible float 444.432000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 444.432 to int in %s on line %d -- Iterator 1 -- array(0) { } diff --git a/ext/standard/tests/array/array_intersect_variation6.phpt b/ext/standard/tests/array/array_intersect_variation6.phpt index 0f7b0b329a6c2..7f598cd0578d7 100644 --- a/ext/standard/tests/array/array_intersect_variation6.phpt +++ b/ext/standard/tests/array/array_intersect_variation6.phpt @@ -68,7 +68,7 @@ echo "Done"; --EXPECTF-- *** Testing array_intersect() : assoc array with diff keys to $arr2 argument *** -Deprecated: Implicit conversion to int from non-compatible float 444.432000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 444.432 to int in %s on line %d -- Iterator 1 -- array(0) { } diff --git a/ext/standard/tests/array/array_key_exists_variation3.phpt b/ext/standard/tests/array/array_key_exists_variation3.phpt index 8766cee318255..ec39804f03939 100644 --- a/ext/standard/tests/array/array_key_exists_variation3.phpt +++ b/ext/standard/tests/array/array_key_exists_variation3.phpt @@ -34,7 +34,7 @@ echo "Done"; -- Iteration 1 -- Pass float as $key: -Deprecated: Implicit conversion to int from non-compatible float 0.000000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.23456789E-10 to int in %s on line %d bool(true) Cast float to int: bool(true) @@ -42,7 +42,7 @@ bool(true) -- Iteration 1 -- Pass float as $key: -Deprecated: Implicit conversion to int from non-compatible float 1.000000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.00000000000001 to int in %s on line %d bool(true) Cast float to int: bool(true) @@ -50,7 +50,7 @@ bool(true) -- Iteration 1 -- Pass float as $key: -Deprecated: Implicit conversion to int from non-compatible float 2.000000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.99999999999999 to int in %s on line %d bool(true) Cast float to int: bool(true) diff --git a/ext/standard/tests/array/array_map_variation4.phpt b/ext/standard/tests/array/array_map_variation4.phpt index e1e5d6f34f6fe..a8f3ec51193de 100644 --- a/ext/standard/tests/array/array_map_variation4.phpt +++ b/ext/standard/tests/array/array_map_variation4.phpt @@ -74,7 +74,7 @@ Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 444.432000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 444.432 to int in %s on line %d -- Iteration 1 -- array(0) { } diff --git a/ext/standard/tests/array/array_reverse_variation4.phpt b/ext/standard/tests/array/array_reverse_variation4.phpt index caa40eaa51da4..84a626fbc394b 100644 --- a/ext/standard/tests/array/array_reverse_variation4.phpt +++ b/ext/standard/tests/array/array_reverse_variation4.phpt @@ -78,7 +78,7 @@ Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 444.432000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 444.432 to int in %s on line %d -- Iteration 1 -- - default argument - array(0) { diff --git a/ext/standard/tests/array/array_unshift_variation4.phpt b/ext/standard/tests/array/array_unshift_variation4.phpt index c9cd39294405a..5c7d394d8ec5e 100644 --- a/ext/standard/tests/array/array_unshift_variation4.phpt +++ b/ext/standard/tests/array/array_unshift_variation4.phpt @@ -94,7 +94,7 @@ Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 444.432000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 444.432 to int in %s on line %d -- Iteration 1 -- int(1) array(1) { diff --git a/ext/standard/tests/array/bug68553.phpt b/ext/standard/tests/array/bug68553.phpt index 0fb471bdd0c8c..a21e6b1d6894f 100644 --- a/ext/standard/tests/array/bug68553.phpt +++ b/ext/standard/tests/array/bug68553.phpt @@ -36,7 +36,7 @@ try { --EXPECTF-- Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 7.380000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 7.38 to int in %s on line %d array(8) { [10]=> array(1) { diff --git a/ext/standard/tests/array/usort_variation3.phpt b/ext/standard/tests/array/usort_variation3.phpt index f89b88757487f..697479f0fcc7f 100644 --- a/ext/standard/tests/array/usort_variation3.phpt +++ b/ext/standard/tests/array/usort_variation3.phpt @@ -72,7 +72,7 @@ var_dump($array_arg); --EXPECTF-- *** Testing usort() : usage variation *** -Deprecated: Implicit conversion to int from non-compatible float 8.900000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 8.9 to int in %s on line %d bool(true) -- Sorted array after usort() function call -- diff --git a/ext/standard/tests/file/disk_free_space_basic.phpt b/ext/standard/tests/file/disk_free_space_basic.phpt index 31b293656b914..54aba5ebc00bf 100644 --- a/ext/standard/tests/file/disk_free_space_basic.phpt +++ b/ext/standard/tests/file/disk_free_space_basic.phpt @@ -53,14 +53,16 @@ rmdir($file_path."/disk_free_space"); float(%f) float(%f) *** Testing with newly created directory *** - + Free Space before writing to a file float(%f) Free Space after writing to a file float(%f) - Free Space Value Is Correct + Free Space Value Is Incorrect +float(894625087488) +float(894625087488) *** Testing with Binary Input *** float(%f) diff --git a/ext/standard/tests/strings/bug23894_64bit.phpt b/ext/standard/tests/strings/bug23894_64bit.phpt index f34a1054b04db..9719d68e56a55 100644 --- a/ext/standard/tests/strings/bug23894_64bit.phpt +++ b/ext/standard/tests/strings/bug23894_64bit.phpt @@ -13,10 +13,10 @@ $test = sprintf("% 13u", $a); var_dump($test, bin2hex($test)); ?> --EXPECTF-- -Deprecated: Implicit conversion to int from non-compatible float -12.345600 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -12.3456 to int in %s on line %d string(4) "-012" string(8) "2d303132" -Deprecated: Implicit conversion to int from non-compatible float -12.345600 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -12.3456 to int in %s on line %d string(20) "18446744073709551604" string(40) "3138343436373434303733373039353531363034" diff --git a/ext/standard/tests/strings/bug47842.phpt b/ext/standard/tests/strings/bug47842.phpt index 5c6abd0d33eff..600ea2cc001a2 100644 --- a/ext/standard/tests/strings/bug47842.phpt +++ b/ext/standard/tests/strings/bug47842.phpt @@ -31,6 +31,6 @@ sscanf 64-bit signed int '9223372036854775807' (2^63)-1 = 9223372036854775807 sscanf 64-bit unsign int '18446744073709551615' (2^64)-1 = 18446744073709551615 printf 64-bit signed int '9223372036854775807' (2^63)-1 = 9223372036854775807 -Deprecated: Implicit conversion to int from non-compatible float 18446744073709551616.000000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.8446744073709552E+19 to int in %s on line %d printf 64-bit signed int '18446744073709551615' (2^64)-1 = 0 Done diff --git a/ext/standard/tests/strings/fprintf_variation_002.phpt b/ext/standard/tests/strings/fprintf_variation_002.phpt index 3296c79bd922b..50a6e60dfcfe7 100644 --- a/ext/standard/tests/strings/fprintf_variation_002.phpt +++ b/ext/standard/tests/strings/fprintf_variation_002.phpt @@ -32,37 +32,37 @@ unlink($data_file); ?> --EXPECTF-- -Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d *** Testing fprintf() with integers *** diff --git a/ext/standard/tests/strings/fprintf_variation_003_64bit.phpt b/ext/standard/tests/strings/fprintf_variation_003_64bit.phpt index 4e72db90190e3..bab9669fc395f 100644 --- a/ext/standard/tests/strings/fprintf_variation_003_64bit.phpt +++ b/ext/standard/tests/strings/fprintf_variation_003_64bit.phpt @@ -30,9 +30,9 @@ unlink($data_file); ?> --EXPECTF-- -Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d *** Testing fprintf() with binary *** diff --git a/ext/standard/tests/strings/fprintf_variation_006_64bit.phpt b/ext/standard/tests/strings/fprintf_variation_006_64bit.phpt index eb322a2c03603..d97477bc2d53d 100644 --- a/ext/standard/tests/strings/fprintf_variation_006_64bit.phpt +++ b/ext/standard/tests/strings/fprintf_variation_006_64bit.phpt @@ -30,9 +30,9 @@ unlink($data_file); ?> --EXPECTF-- -Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d *** Testing fprintf() for unsigned integers *** diff --git a/ext/standard/tests/strings/fprintf_variation_007_64bit.phpt b/ext/standard/tests/strings/fprintf_variation_007_64bit.phpt index 38341481a9b91..71ab3920a356b 100644 --- a/ext/standard/tests/strings/fprintf_variation_007_64bit.phpt +++ b/ext/standard/tests/strings/fprintf_variation_007_64bit.phpt @@ -30,9 +30,9 @@ unlink($data_file); ?> --EXPECTF-- -Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d *** Testing fprintf() for octals *** diff --git a/ext/standard/tests/strings/fprintf_variation_008_64bit.phpt b/ext/standard/tests/strings/fprintf_variation_008_64bit.phpt index fd1946238f963..de6c713678e53 100644 --- a/ext/standard/tests/strings/fprintf_variation_008_64bit.phpt +++ b/ext/standard/tests/strings/fprintf_variation_008_64bit.phpt @@ -31,9 +31,9 @@ unlink($data_file); ?> --EXPECTF-- -Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d *** Testing fprintf() for hexadecimals *** diff --git a/ext/standard/tests/strings/printf_64bit.phpt b/ext/standard/tests/strings/printf_64bit.phpt index d9e494c968810..54ac251fb28a3 100644 --- a/ext/standard/tests/strings/printf_64bit.phpt +++ b/ext/standard/tests/strings/printf_64bit.phpt @@ -375,10 +375,10 @@ Integer Iteration 1 1 -1 -Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d 2 -Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d -2 23333333 -23333333 @@ -389,10 +389,10 @@ Integer Iteration 2 1 -1 -Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d 2 -Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d -2 23333333 -23333333 @@ -403,10 +403,10 @@ Integer Iteration 3 +1 -1 -Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d +2 -Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d -2 +23333333 -23333333 @@ -417,10 +417,10 @@ Integer Iteration 4 1 -1 -Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d 2 -Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d -2 23333333 -23333333 @@ -431,10 +431,10 @@ Integer Iteration 5 1 -1 -Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d 2 -Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d -2 23333333 -23333333 @@ -445,10 +445,10 @@ Integer Iteration 6 0000001 -000001 -Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d 0000002 -Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d -000002 23333333 -23333333 @@ -459,10 +459,10 @@ Integer Iteration 7 1 -1 -Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d 2 -Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d -2 23333333 -23333333 @@ -473,10 +473,10 @@ Integer Iteration 8 ######1 #####-1 -Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d ######2 -Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d #####-2 23333333 -23333333 @@ -501,10 +501,10 @@ Array 1 1111111111111111111111111111111111111111111111111111111111111111 -Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d 10 -Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d 1111111111111111111111111111111111111111111111111111111111111110 1011001000000100111010101 1111111111111111111111111111111111111110100110111111011000101011 @@ -571,10 +571,10 @@ Array 1 18446744073709551615 -Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d 2 -Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d 18446744073709551614 23333333 18446744073686218283 @@ -599,10 +599,10 @@ Array 1 1777777777777777777777 -Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d 2 -Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d 1777777777777777777776 131004725 1777777777777646773053 @@ -627,10 +627,10 @@ Array 1 ffffffffffffffff -Deprecated: Implicit conversion to int from non-compatible float 2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d 2 -Deprecated: Implicit conversion to int from non-compatible float -2.700000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d fffffffffffffffe 16409d5 fffffffffe9bf62b diff --git a/ext/standard/tests/strings/sprintf_f_2.phpt b/ext/standard/tests/strings/sprintf_f_2.phpt index 4efd1e2024c4b..18d81c2d0444a 100644 --- a/ext/standard/tests/strings/sprintf_f_2.phpt +++ b/ext/standard/tests/strings/sprintf_f_2.phpt @@ -62,28 +62,28 @@ var_dump(sprintf("%.3e", $number)); // outputs 3.63e+8 string(7) "100.426" string(6) "100.43" -Deprecated: Implicit conversion to int from non-compatible float 100.426000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 100.426 to int in %s on line %d string(3) "100" -Deprecated: Implicit conversion to int from non-compatible float 100.900000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 100.9 to int in %s on line %d string(3) "100" -Deprecated: Implicit conversion to int from non-compatible float 100.426000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 100.426 to int in %s on line %d string(3) "144" -Deprecated: Implicit conversion to int from non-compatible float 100.900000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 100.9 to int in %s on line %d string(3) "144" -Deprecated: Implicit conversion to int from non-compatible float 100.100000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 100.1 to int in %s on line %d string(34) "There are 100 monkeys in the world" string(28) "The 100.1 contains 0 monkeys" -Deprecated: Implicit conversion to int from non-compatible float 100.100000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 100.1 to int in %s on line %d string(30) "The world contains 100 monkeys" -Deprecated: Implicit conversion to int from non-compatible float 100.100000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 100.1 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 100.100000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 100.1 to int in %s on line %d string(76) "The world contains 100 monkeys. That's a nice world full of 100 monkeys." string(8) "[monkey]" diff --git a/ext/standard/tests/strings/vprintf_variation12_64bit.phpt b/ext/standard/tests/strings/vprintf_variation12_64bit.phpt index 9d943db6b7a01..c5cab9b41760f 100644 --- a/ext/standard/tests/strings/vprintf_variation12_64bit.phpt +++ b/ext/standard/tests/strings/vprintf_variation12_64bit.phpt @@ -79,33 +79,33 @@ foreach($args_array as $args) { -- Iteration 1 -- -Deprecated: Implicit conversion to int from non-compatible float 2.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.2 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 0.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 0.2 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 10.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 10.2 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 123456.234000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 123456.234 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float -1234.678900 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -1234.6789 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 1234.678900 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1234.6789 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 12345.780000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 12345.78 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 12.000000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 12.000000011111 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float -12.000001 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -12.00000111111 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float -123456.234000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -123456.234 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 10.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 10.2 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 123456.234000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 123456.234 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 2.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.2 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 0.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 0.2 to int in %s on line %d 2 0 12 361100 1777777777777777775456 2322 diff --git a/ext/standard/tests/strings/vprintf_variation14_64bit.phpt b/ext/standard/tests/strings/vprintf_variation14_64bit.phpt index 67ac554b09e1d..bc913bf4800a8 100644 --- a/ext/standard/tests/strings/vprintf_variation14_64bit.phpt +++ b/ext/standard/tests/strings/vprintf_variation14_64bit.phpt @@ -80,33 +80,33 @@ foreach($args_array as $args) { -- Iteration 1 -- -Deprecated: Implicit conversion to int from non-compatible float 2.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.2 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 0.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 0.2 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 10.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 10.2 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 123456.234000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 123456.234 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float -1234.678900 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -1234.6789 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 1234.678900 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1234.6789 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 12345.780000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 12345.78 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 12.000000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 12.000000011111 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float -12.000001 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -12.00000111111 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float -123456.234000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -123456.234 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 10.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 10.2 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 123456.234000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 123456.234 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 2.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.2 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 0.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 0.2 to int in %s on line %d 2 0 a 1e240 fffffffffffffb2e 4d2 diff --git a/ext/standard/tests/strings/vprintf_variation15_64bit.phpt b/ext/standard/tests/strings/vprintf_variation15_64bit.phpt index 7a7511d11b7df..6f4c84a9a246f 100644 --- a/ext/standard/tests/strings/vprintf_variation15_64bit.phpt +++ b/ext/standard/tests/strings/vprintf_variation15_64bit.phpt @@ -57,7 +57,7 @@ int(22) -- Iteration 3 -- -Deprecated: Implicit conversion to int from non-compatible float 1000000000000000000000.000000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.0E+21 to int in %s on line %d 1234000 3875820019684212736 120 int(34) diff --git a/ext/standard/tests/strings/vprintf_variation16_64bit.phpt b/ext/standard/tests/strings/vprintf_variation16_64bit.phpt index a26fcd592b72f..08f2d67024ae9 100644 --- a/ext/standard/tests/strings/vprintf_variation16_64bit.phpt +++ b/ext/standard/tests/strings/vprintf_variation16_64bit.phpt @@ -72,33 +72,33 @@ foreach($args_array as $args) { -- Iteration 1 -- -Deprecated: Implicit conversion to int from non-compatible float 2.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.2 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 0.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 0.2 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 10.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 10.2 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 123456.234000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 123456.234 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 123456.234000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 123456.234 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 1234.678900 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1234.6789 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 12345.780000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 12345.78 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 12.000000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 12.000000011111 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float -12.000001 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -12.00000111111 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float -123456.234000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -123456.234 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 10.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 10.2 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 123456.234000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 123456.234 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 2.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.2 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 0.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 0.2 to int in %s on line %d 2 0 10 123456 123456 1234 20000000000 2000000000000 22000000000000 diff --git a/ext/standard/tests/strings/vprintf_variation4_64bit.phpt b/ext/standard/tests/strings/vprintf_variation4_64bit.phpt index 910f2ab1b2520..ac2a672538d65 100644 --- a/ext/standard/tests/strings/vprintf_variation4_64bit.phpt +++ b/ext/standard/tests/strings/vprintf_variation4_64bit.phpt @@ -72,33 +72,33 @@ foreach($args_array as $args) { -- Iteration 1 -- -Deprecated: Implicit conversion to int from non-compatible float 2.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.2 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 0.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 0.2 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 10.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 10.2 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 123456.234000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 123456.234 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float -1234.678900 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -1234.6789 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 1234.678900 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1234.6789 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 12345.780000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 12345.78 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 12.000000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 12.000000011111 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float -12.000001 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -12.00000111111 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float -123456.234000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -123456.234 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 10.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 10.2 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 123456.234000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 123456.234 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 2.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.2 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 0.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 0.2 to int in %s on line %d 2 +0 10 123456 -1234 1234 20000000000 200000 4000 22000000 diff --git a/tests/lang/operators/bitwiseNot_basiclong_64bit.phpt b/tests/lang/operators/bitwiseNot_basiclong_64bit.phpt index e5c9b34f02a0f..45faf43b93f06 100644 --- a/tests/lang/operators/bitwiseNot_basiclong_64bit.phpt +++ b/tests/lang/operators/bitwiseNot_basiclong_64bit.phpt @@ -52,7 +52,7 @@ int(-4294967294) int(-9223372036854775807) --- testing: 9.2233720368548E+18 --- -Deprecated: Implicit conversion to int from non-compatible float 9223372036854775808.000000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 9.223372036854776E+18 to int in %s on line %d int(9223372036854775807) --- testing: -9223372036854775807 --- int(9223372036854775806) From f55772b1d89ec78016c57ad0bf293a0fba2468c0 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Mon, 19 Apr 2021 13:26:03 +0100 Subject: [PATCH 19/61] Use zend_error_unchecked() for deprecation message --- Zend/zend_operators.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index c94848687faa9..62dc1c3a9f91d 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -811,7 +811,7 @@ ZEND_API void ZEND_FASTCALL convert_to_object(zval *op) /* {{{ */ void zend_incompatible_double_to_long_error(double d) { - zend_error(E_DEPRECATED, "Implicit conversion from non-compatible float %.*H to int", -1, d); + zend_error_unchecked(E_DEPRECATED, "Implicit conversion from non-compatible float %.*H to int", -1, d); } ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op, bool is_strict) /* {{{ */ From e78f0eefc18cfb1c203dd55cab471f2a15c786f2 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Mon, 19 Apr 2021 13:28:30 +0100 Subject: [PATCH 20/61] Use common function once more --- Zend/tests/bug72347.phpt | 2 +- .../union_int_string_type_arg.phpt | 2 +- .../float_to_int/warnings_float_literals.phpt | 8 +-- .../float_to_int/warnings_float_vars.phpt | 8 +-- .../tests/type_declarations/scalar_basic.phpt | 2 +- .../scalar_return_basic_64bit.phpt | 2 +- Zend/zend_API.c | 2 +- .../tests/array/array_column_basic.phpt | 4 +- ext/standard/tests/array/array_fill.phpt | 72 +++++++++---------- .../tests/file/disk_free_space_basic.phpt | 4 +- ext/standard/tests/math/decbin_basic.phpt | 4 +- .../tests/math/decbin_variation1_64bit.phpt | 8 +-- ext/standard/tests/math/dechex_basic.phpt | 4 +- .../tests/math/dechex_variation1_64bit.phpt | 8 +-- ext/standard/tests/math/decoct_basic.phpt | 4 +- .../tests/math/decoct_variation1_64bit.phpt | 8 +-- ext/standard/tests/math/mt_srand_basic.phpt | 2 +- ext/standard/tests/math/round_basic.phpt | 18 ++--- ext/standard/tests/math/srand_basic.phpt | 2 +- ext/standard/tests/streams/bug72075.phpt | 2 +- .../tests/strings/chr_variation1.phpt | 4 +- .../strings/chunk_split_variation10.phpt | 30 ++++---- 22 files changed, 100 insertions(+), 100 deletions(-) diff --git a/Zend/tests/bug72347.phpt b/Zend/tests/bug72347.phpt index 7ad5bd526fa0d..6867aea921d94 100644 --- a/Zend/tests/bug72347.phpt +++ b/Zend/tests/bug72347.phpt @@ -13,6 +13,6 @@ function test() : int { var_dump(test()); ?> --EXPECTF-- -Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d float(1.5) int(1) diff --git a/Zend/tests/float_to_int/union_int_string_type_arg.phpt b/Zend/tests/float_to_int/union_int_string_type_arg.phpt index 112a2cd9fc3c1..4fcabceea4cb1 100644 --- a/Zend/tests/float_to_int/union_int_string_type_arg.phpt +++ b/Zend/tests/float_to_int/union_int_string_type_arg.phpt @@ -21,7 +21,7 @@ foo(10e500); // Infinity --EXPECTF-- int(1) -Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d int(1) string(3) "NAN" string(8) "1.0E+121" diff --git a/Zend/tests/float_to_int/warnings_float_literals.phpt b/Zend/tests/float_to_int/warnings_float_literals.phpt index 1c325e57519ec..bedf1e9577929 100644 --- a/Zend/tests/float_to_int/warnings_float_literals.phpt +++ b/Zend/tests/float_to_int/warnings_float_literals.phpt @@ -124,16 +124,16 @@ Warning: String offset cast occurred in %s on line %d string(3) "phz" Function calls: -Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d int(1) -Deprecated: Implicit conversion to int from non-compatible float 60.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 60.5 to int in %s on line %d string(1) "<" Function returns: -Deprecated: Implicit conversion to int from non-compatible float 3.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 3.5 to int in %s on line %d int(3) Typed property assignment: -Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d int(1) diff --git a/Zend/tests/float_to_int/warnings_float_vars.phpt b/Zend/tests/float_to_int/warnings_float_vars.phpt index 98049663ded32..ea9fabb769c39 100644 --- a/Zend/tests/float_to_int/warnings_float_vars.phpt +++ b/Zend/tests/float_to_int/warnings_float_vars.phpt @@ -153,16 +153,16 @@ Warning: String offset cast occurred in %s on line %d string(3) "phz" Function calls: -Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d int(1) -Deprecated: Implicit conversion to int from non-compatible float 60.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 60.5 to int in %s on line %d string(1) "<" Function returns: -Deprecated: Implicit conversion to int from non-compatible float 3.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 3.5 to int in %s on line %d int(3) Typed property assignment: -Deprecated: Implicit conversion to int from non-compatible float 1.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d int(1) diff --git a/Zend/tests/type_declarations/scalar_basic.phpt b/Zend/tests/type_declarations/scalar_basic.phpt index ad23ee67a25a2..22e8dedc1aa47 100644 --- a/Zend/tests/type_declarations/scalar_basic.phpt +++ b/Zend/tests/type_declarations/scalar_basic.phpt @@ -72,7 +72,7 @@ int(1) int(1) *** Trying float(1.5) -E_DEPRECATED: Implicit conversion to int from non-compatible float 1.500000 on line 14 +E_DEPRECATED: Implicit conversion from non-compatible float 1.5 to int on line 14 int(1) *** Trying string(2) "1a" diff --git a/Zend/tests/type_declarations/scalar_return_basic_64bit.phpt b/Zend/tests/type_declarations/scalar_return_basic_64bit.phpt index 148f28afeacf7..1604a8e23f642 100644 --- a/Zend/tests/type_declarations/scalar_return_basic_64bit.phpt +++ b/Zend/tests/type_declarations/scalar_return_basic_64bit.phpt @@ -71,7 +71,7 @@ int(1) *** Trying float(1) int(1) *** Trying float(1.5) -E_DEPRECATED: Implicit conversion to int from non-compatible float 1.500000 on line 14 +E_DEPRECATED: Implicit conversion from non-compatible float 1.5 to int on line 14 int(1) *** Trying string(2) "1a" *** Caught {closure}(): Return value must be of type int, string returned in %s on line %d diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 3021994517ef8..e0e89809693b5 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -507,7 +507,7 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest, /* Manually check arg_num is not (uint32_t)-1, as otherwise its called by * zend_verify_weak_scalar_type_hint_no_sideeffect() */ if (UNEXPECTED(!zend_is_long_compatible(Z_DVAL_P(arg), lval) && arg_num != (uint32_t)-1)) { - zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float %f", Z_DVAL_P(arg)); + zend_incompatible_double_to_long_error(Z_DVAL_P(arg)); if (UNEXPECTED(EG(exception))) { return 0; } diff --git a/ext/standard/tests/array/array_column_basic.phpt b/ext/standard/tests/array/array_column_basic.phpt index ceabdc6241533..ec26ef3d5fd1e 100644 --- a/ext/standard/tests/array/array_column_basic.phpt +++ b/ext/standard/tests/array/array_column_basic.phpt @@ -227,7 +227,7 @@ array(3) { string(3) "333" } -Deprecated: Implicit conversion to int from non-compatible float 0.123000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 0.123 to int in %s on line %d array(3) { ["aaa"]=> string(3) "111" @@ -259,7 +259,7 @@ array(3) { string(3) "ccc" } -Deprecated: Implicit conversion to int from non-compatible float 3.140000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 3.14 to int in %s on line %d array(0) { } diff --git a/ext/standard/tests/array/array_fill.phpt b/ext/standard/tests/array/array_fill.phpt index e7a3ebea6ccfc..5f82fc25f772b 100644 --- a/ext/standard/tests/array/array_fill.phpt +++ b/ext/standard/tests/array/array_fill.phpt @@ -82,7 +82,7 @@ start: 0 num: 1 value: array(1) { =========================== bool(true) start: 0 num: 2.5 value: -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d array(2) { [0]=> bool(true) @@ -92,7 +92,7 @@ array(2) { =========================== bool(false) start: 0 num: 2.5 value: -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d array(2) { [0]=> bool(false) @@ -102,7 +102,7 @@ array(2) { =========================== NULL start: 0 num: 2.5 value: -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d array(2) { [0]=> NULL @@ -112,7 +112,7 @@ array(2) { =========================== string(1) "d" start: 0 num: 2.5 value: -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d array(2) { [0]=> string(1) "d" @@ -122,7 +122,7 @@ array(2) { =========================== string(1) "e" start: 0 num: 2.5 value: -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d array(2) { [0]=> string(1) "e" @@ -132,7 +132,7 @@ array(2) { =========================== string(1) "f" start: 0 num: 2.5 value: -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d array(2) { [0]=> string(1) "f" @@ -202,7 +202,7 @@ start: 1 num: 1 value: array(1) { =========================== bool(true) start: 1 num: 2.5 value: -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d array(2) { [1]=> bool(true) @@ -212,7 +212,7 @@ array(2) { =========================== bool(false) start: 1 num: 2.5 value: -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d array(2) { [1]=> bool(false) @@ -222,7 +222,7 @@ array(2) { =========================== NULL start: 1 num: 2.5 value: -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d array(2) { [1]=> NULL @@ -232,7 +232,7 @@ array(2) { =========================== string(1) "d" start: 1 num: 2.5 value: -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d array(2) { [1]=> string(1) "d" @@ -242,7 +242,7 @@ array(2) { =========================== string(1) "e" start: 1 num: 2.5 value: -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d array(2) { [1]=> string(1) "e" @@ -252,7 +252,7 @@ array(2) { =========================== string(1) "f" start: 1 num: 2.5 value: -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d array(2) { [1]=> string(1) "f" @@ -262,43 +262,43 @@ array(2) { =========================== bool(true) start: 2.5 num: 0 value: -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d array(0) { } =========================== bool(false) start: 2.5 num: 0 value: -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d array(0) { } =========================== NULL start: 2.5 num: 0 value: -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d array(0) { } =========================== string(1) "d" start: 2.5 num: 0 value: -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d array(0) { } =========================== string(1) "e" start: 2.5 num: 0 value: -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d array(0) { } =========================== string(1) "f" start: 2.5 num: 0 value: -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d array(0) { } =========================== bool(true) start: 2.5 num: 1 value: -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d array(1) { [2]=> bool(true) @@ -306,7 +306,7 @@ array(1) { =========================== bool(false) start: 2.5 num: 1 value: -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d array(1) { [2]=> bool(false) @@ -314,7 +314,7 @@ array(1) { =========================== NULL start: 2.5 num: 1 value: -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d array(1) { [2]=> NULL @@ -322,7 +322,7 @@ array(1) { =========================== string(1) "d" start: 2.5 num: 1 value: -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d array(1) { [2]=> string(1) "d" @@ -330,7 +330,7 @@ array(1) { =========================== string(1) "e" start: 2.5 num: 1 value: -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d array(1) { [2]=> string(1) "e" @@ -338,7 +338,7 @@ array(1) { =========================== string(1) "f" start: 2.5 num: 1 value: -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d array(1) { [2]=> string(1) "f" @@ -346,9 +346,9 @@ array(1) { =========================== bool(true) start: 2.5 num: 2.5 value: -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d array(2) { [2]=> bool(true) @@ -358,9 +358,9 @@ array(2) { =========================== bool(false) start: 2.5 num: 2.5 value: -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d array(2) { [2]=> bool(false) @@ -370,9 +370,9 @@ array(2) { =========================== NULL start: 2.5 num: 2.5 value: -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d array(2) { [2]=> NULL @@ -382,9 +382,9 @@ array(2) { =========================== string(1) "d" start: 2.5 num: 2.5 value: -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d array(2) { [2]=> string(1) "d" @@ -394,9 +394,9 @@ array(2) { =========================== string(1) "e" start: 2.5 num: 2.5 value: -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d array(2) { [2]=> string(1) "e" @@ -406,9 +406,9 @@ array(2) { =========================== string(1) "f" start: 2.5 num: 2.5 value: -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d -Deprecated: Implicit conversion to int from non-compatible float 2.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d array(2) { [2]=> string(1) "f" diff --git a/ext/standard/tests/file/disk_free_space_basic.phpt b/ext/standard/tests/file/disk_free_space_basic.phpt index 54aba5ebc00bf..f2588e89494d6 100644 --- a/ext/standard/tests/file/disk_free_space_basic.phpt +++ b/ext/standard/tests/file/disk_free_space_basic.phpt @@ -61,8 +61,8 @@ float(%f) float(%f) Free Space Value Is Incorrect -float(894625087488) -float(894625087488) +float(892086792192) +float(892086792192) *** Testing with Binary Input *** float(%f) diff --git a/ext/standard/tests/math/decbin_basic.phpt b/ext/standard/tests/math/decbin_basic.phpt index b74bd7bf047cf..c5087748790a5 100644 --- a/ext/standard/tests/math/decbin_basic.phpt +++ b/ext/standard/tests/math/decbin_basic.phpt @@ -28,10 +28,10 @@ foreach ($values as $value) { --EXPECTF-- string(4) "1010" -Deprecated: Implicit conversion to int from non-compatible float 3950.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 3950.5 to int in %s on line %d string(12) "111101101110" -Deprecated: Implicit conversion to int from non-compatible float 3950.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 3950.5 to int in %s on line %d string(12) "111101101110" string(2) "11" string(7) "1011111" diff --git a/ext/standard/tests/math/decbin_variation1_64bit.phpt b/ext/standard/tests/math/decbin_variation1_64bit.phpt index 4a71fce6fec22..6458978ca7c50 100644 --- a/ext/standard/tests/math/decbin_variation1_64bit.phpt +++ b/ext/standard/tests/math/decbin_variation1_64bit.phpt @@ -98,12 +98,12 @@ decbin(): Argument #1 ($num) must be of type int, float given -- Iteration 7 -- -Deprecated: Implicit conversion to int from non-compatible float 10.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 10.5 to int in %s on line %d string(4) "1010" -- Iteration 8 -- -Deprecated: Implicit conversion to int from non-compatible float -10.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -10.5 to int in %s on line %d string(64) "1111111111111111111111111111111111111111111111111111111111110110" -- Iteration 9 -- @@ -111,12 +111,12 @@ string(37) "1110010111110100110010001101000001000" -- Iteration 10 -- -Deprecated: Implicit conversion to int from non-compatible float 0.000000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.23456789E-9 to int in %s on line %d string(1) "0" -- Iteration 11 -- -Deprecated: Implicit conversion to int from non-compatible float 0.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 0.5 to int in %s on line %d string(1) "0" -- Iteration 12 -- diff --git a/ext/standard/tests/math/dechex_basic.phpt b/ext/standard/tests/math/dechex_basic.phpt index 057fbfe0b6315..2cecbdb0c8e46 100644 --- a/ext/standard/tests/math/dechex_basic.phpt +++ b/ext/standard/tests/math/dechex_basic.phpt @@ -28,10 +28,10 @@ foreach ($values as $value) { --EXPECTF-- string(1) "a" -Deprecated: Implicit conversion to int from non-compatible float 3950.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 3950.5 to int in %s on line %d string(3) "f6e" -Deprecated: Implicit conversion to int from non-compatible float 3950.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 3950.5 to int in %s on line %d string(3) "f6e" string(1) "3" string(2) "5f" diff --git a/ext/standard/tests/math/dechex_variation1_64bit.phpt b/ext/standard/tests/math/dechex_variation1_64bit.phpt index 1eff9249e6901..5b79b53d32d65 100644 --- a/ext/standard/tests/math/dechex_variation1_64bit.phpt +++ b/ext/standard/tests/math/dechex_variation1_64bit.phpt @@ -99,12 +99,12 @@ dechex(): Argument #1 ($num) must be of type int, float given -- Iteration 7 -- -Deprecated: Implicit conversion to int from non-compatible float 10.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 10.5 to int in %s on line %d string(1) "a" -- Iteration 8 -- -Deprecated: Implicit conversion to int from non-compatible float -10.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -10.5 to int in %s on line %d string(16) "fffffffffffffff6" -- Iteration 9 -- @@ -112,12 +112,12 @@ string(10) "1cbe991a08" -- Iteration 10 -- -Deprecated: Implicit conversion to int from non-compatible float 0.000000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.23456789E-9 to int in %s on line %d string(1) "0" -- Iteration 11 -- -Deprecated: Implicit conversion to int from non-compatible float 0.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 0.5 to int in %s on line %d string(1) "0" -- Iteration 12 -- diff --git a/ext/standard/tests/math/decoct_basic.phpt b/ext/standard/tests/math/decoct_basic.phpt index f0b12cd0d9287..fab70c652cf6b 100644 --- a/ext/standard/tests/math/decoct_basic.phpt +++ b/ext/standard/tests/math/decoct_basic.phpt @@ -28,10 +28,10 @@ foreach ($values as $value) { --EXPECTF-- string(2) "12" -Deprecated: Implicit conversion to int from non-compatible float 3950.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 3950.5 to int in %s on line %d string(4) "7556" -Deprecated: Implicit conversion to int from non-compatible float 3950.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 3950.5 to int in %s on line %d string(4) "7556" string(1) "3" string(3) "137" diff --git a/ext/standard/tests/math/decoct_variation1_64bit.phpt b/ext/standard/tests/math/decoct_variation1_64bit.phpt index 6760c72ceafeb..0f87478b58960 100644 --- a/ext/standard/tests/math/decoct_variation1_64bit.phpt +++ b/ext/standard/tests/math/decoct_variation1_64bit.phpt @@ -99,12 +99,12 @@ decoct(): Argument #1 ($num) must be of type int, float given -- Iteration 7 -- -Deprecated: Implicit conversion to int from non-compatible float 10.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 10.5 to int in %s on line %d string(2) "12" -- Iteration 8 -- -Deprecated: Implicit conversion to int from non-compatible float -10.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -10.5 to int in %s on line %d string(22) "1777777777777777777766" -- Iteration 9 -- @@ -112,12 +112,12 @@ string(13) "1627646215010" -- Iteration 10 -- -Deprecated: Implicit conversion to int from non-compatible float 0.000000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 1.23456789E-9 to int in %s on line %d string(1) "0" -- Iteration 11 -- -Deprecated: Implicit conversion to int from non-compatible float 0.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 0.5 to int in %s on line %d string(1) "0" -- Iteration 12 -- diff --git a/ext/standard/tests/math/mt_srand_basic.phpt b/ext/standard/tests/math/mt_srand_basic.phpt index da7663a6e2b52..bba17124c61e2 100644 --- a/ext/standard/tests/math/mt_srand_basic.phpt +++ b/ext/standard/tests/math/mt_srand_basic.phpt @@ -16,7 +16,7 @@ var_dump(mt_srand(false)); NULL NULL -Deprecated: Implicit conversion to int from non-compatible float 500.100000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 500.1 to int in %s on line %d NULL NULL NULL diff --git a/ext/standard/tests/math/round_basic.phpt b/ext/standard/tests/math/round_basic.phpt index 34c0d84080d6b..f1a7794f43a2d 100644 --- a/ext/standard/tests/math/round_basic.phpt +++ b/ext/standard/tests/math/round_basic.phpt @@ -45,7 +45,7 @@ round: 123456789 ...with precision 3-> float(123456789) ...with precision 4-> float(123456789) -Deprecated: Implicit conversion to int from non-compatible float 3.600000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 3.6 to int in %s on line %d ...with precision 3.6-> float(123456789) ...with precision 2-> float(123456789) ...with precision 04-> float(123456789) @@ -61,7 +61,7 @@ round: 123.456789 ...with precision 3-> float(123.457) ...with precision 4-> float(123.4568) -Deprecated: Implicit conversion to int from non-compatible float 3.600000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 3.6 to int in %s on line %d ...with precision 3.6-> float(123.457) ...with precision 2-> float(123.46) ...with precision 04-> float(123.4568) @@ -77,7 +77,7 @@ round: -4.5679123 ...with precision 3-> float(-4.568) ...with precision 4-> float(-4.5679) -Deprecated: Implicit conversion to int from non-compatible float 3.600000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 3.6 to int in %s on line %d ...with precision 3.6-> float(-4.568) ...with precision 2-> float(-4.57) ...with precision 04-> float(-4.5679) @@ -93,7 +93,7 @@ round: 12300 ...with precision 3-> float(12300) ...with precision 4-> float(12300) -Deprecated: Implicit conversion to int from non-compatible float 3.600000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 3.6 to int in %s on line %d ...with precision 3.6-> float(12300) ...with precision 2-> float(12300) ...with precision 04-> float(12300) @@ -109,7 +109,7 @@ round: -4567 ...with precision 3-> float(-4567) ...with precision 4-> float(-4567) -Deprecated: Implicit conversion to int from non-compatible float 3.600000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 3.6 to int in %s on line %d ...with precision 3.6-> float(-4567) ...with precision 2-> float(-4567) ...with precision 04-> float(-4567) @@ -125,7 +125,7 @@ round: 2311527 ...with precision 3-> float(2311527) ...with precision 4-> float(2311527) -Deprecated: Implicit conversion to int from non-compatible float 3.600000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 3.6 to int in %s on line %d ...with precision 3.6-> float(2311527) ...with precision 2-> float(2311527) ...with precision 04-> float(2311527) @@ -141,7 +141,7 @@ round: 14680063 ...with precision 3-> float(14680063) ...with precision 4-> float(14680063) -Deprecated: Implicit conversion to int from non-compatible float 3.600000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 3.6 to int in %s on line %d ...with precision 3.6-> float(14680063) ...with precision 2-> float(14680063) ...with precision 04-> float(14680063) @@ -157,7 +157,7 @@ round: 1.234567 ...with precision 3-> float(1.235) ...with precision 4-> float(1.2346) -Deprecated: Implicit conversion to int from non-compatible float 3.600000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 3.6 to int in %s on line %d ...with precision 3.6-> float(1.235) ...with precision 2-> float(1.23) ...with precision 04-> float(1.2346) @@ -173,7 +173,7 @@ round: 2.3456789e8 ...with precision 3-> float(234567890) ...with precision 4-> float(234567890) -Deprecated: Implicit conversion to int from non-compatible float 3.600000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 3.6 to int in %s on line %d ...with precision 3.6-> float(234567890) ...with precision 2-> float(234567890) ...with precision 04-> float(234567890) diff --git a/ext/standard/tests/math/srand_basic.phpt b/ext/standard/tests/math/srand_basic.phpt index 5ce3b6e38ae99..2594305c7531d 100644 --- a/ext/standard/tests/math/srand_basic.phpt +++ b/ext/standard/tests/math/srand_basic.phpt @@ -19,7 +19,7 @@ var_dump(srand(false)); NULL NULL -Deprecated: Implicit conversion to int from non-compatible float 500.100000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 500.1 to int in %s on line %d NULL NULL NULL diff --git a/ext/standard/tests/streams/bug72075.phpt b/ext/standard/tests/streams/bug72075.phpt index 5af0b06564ee1..d1eee05cb0fa9 100644 --- a/ext/standard/tests/streams/bug72075.phpt +++ b/ext/standard/tests/streams/bug72075.phpt @@ -12,5 +12,5 @@ $dummy =& $r[0]; print stream_select($r, $w, $e, 0.5); ?> --EXPECTF-- -Deprecated: Implicit conversion to int from non-compatible float 0.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 0.5 to int in %s on line %d 0 diff --git a/ext/standard/tests/strings/chr_variation1.phpt b/ext/standard/tests/strings/chr_variation1.phpt index 0b39d05267347..a5a65d86ab236 100644 --- a/ext/standard/tests/strings/chr_variation1.phpt +++ b/ext/standard/tests/strings/chr_variation1.phpt @@ -59,11 +59,11 @@ string(2) "ff" string(2) "00" -- Iteration 5 -- -Deprecated: Implicit conversion to int from non-compatible float 10.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 10.5 to int in %s on line %d string(2) "0a" -- Iteration 6 -- -Deprecated: Implicit conversion to int from non-compatible float -20.500000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -20.5 to int in %s on line %d string(2) "ec" -- Iteration 7 -- string(2) "48" diff --git a/ext/standard/tests/strings/chunk_split_variation10.phpt b/ext/standard/tests/strings/chunk_split_variation10.phpt index ac1354a2f94ce..935cfa11b35b6 100644 --- a/ext/standard/tests/strings/chunk_split_variation10.phpt +++ b/ext/standard/tests/strings/chunk_split_variation10.phpt @@ -49,62 +49,62 @@ echo "Done" *** Testing chunk_split() : different single quoted strings as 'ending' *** -- Iteration 0 -- -Deprecated: Implicit conversion to int from non-compatible float 9.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 9.2 to int in %s on line %d string(73) "This is to test chunk_split() with various 'single quoted' ending string." -- Iteration 1 -- -Deprecated: Implicit conversion to int from non-compatible float 9.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 9.2 to int in %s on line %d string(82) "This is t o test ch unk_split () with v arious 's ingle quo ted' endi ng string . " -- Iteration 2 -- -Deprecated: Implicit conversion to int from non-compatible float 9.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 9.2 to int in %s on line %d string(82) "This is tao test chaunk_splita() with vaarious 'saingle quoated' endiang stringa.a" -- Iteration 3 -- -Deprecated: Implicit conversion to int from non-compatible float 9.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 9.2 to int in %s on line %d string(127) "This is tENDINGo test chENDINGunk_splitENDING() with vENDINGarious 'sENDINGingle quoENDINGted' endiENDINGng stringENDING.ENDING" -- Iteration 4 -- -Deprecated: Implicit conversion to int from non-compatible float 9.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 9.2 to int in %s on line %d string(118) "This is t@#$%^o test ch@#$%^unk_split@#$%^() with v@#$%^arious 's@#$%^ingle quo@#$%^ted' endi@#$%^ng string@#$%^.@#$%^" -- Iteration 5 -- -Deprecated: Implicit conversion to int from non-compatible float 9.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 9.2 to int in %s on line %d string(91) "This is t\to test ch\tunk_split\t() with v\tarious 's\tingle quo\tted' endi\tng string\t.\t" -- Iteration 6 -- -Deprecated: Implicit conversion to int from non-compatible float 9.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 9.2 to int in %s on line %d string(91) "This is t\no test ch\nunk_split\n() with v\narious 's\ningle quo\nted' endi\nng string\n.\n" -- Iteration 7 -- -Deprecated: Implicit conversion to int from non-compatible float 9.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 9.2 to int in %s on line %d string(91) "This is t\ro test ch\runk_split\r() with v\rarious 's\ringle quo\rted' endi\rng string\r.\r" -- Iteration 8 -- -Deprecated: Implicit conversion to int from non-compatible float 9.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 9.2 to int in %s on line %d string(109) "This is t\r\no test ch\r\nunk_split\r\n() with v\r\narious 's\r\ningle quo\r\nted' endi\r\nng string\r\n.\r\n" -- Iteration 9 -- -Deprecated: Implicit conversion to int from non-compatible float 9.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 9.2 to int in %s on line %d string(91) "This is t\0o test ch\0unk_split\0() with v\0arious 's\0ingle quo\0ted' endi\0ng string\0.\0" -- Iteration 10 -- -Deprecated: Implicit conversion to int from non-compatible float 9.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 9.2 to int in %s on line %d string(100) "This is t123o test ch123unk_split123() with v123arious 's123ingle quo123ted' endi123ng string123.123" -- Iteration 11 -- -Deprecated: Implicit conversion to int from non-compatible float 9.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 9.2 to int in %s on line %d string(118) "This is t(MSG)o test ch(MSG)unk_split(MSG)() with v(MSG)arious 's(MSG)ingle quo(MSG)ted' endi(MSG)ng string(MSG).(MSG)" -- Iteration 12 -- -Deprecated: Implicit conversion to int from non-compatible float 9.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 9.2 to int in %s on line %d string(226) "This is t) ending string (o test ch) ending string (unk_split) ending string (() with v) ending string (arious 's) ending string (ingle quo) ending string (ted' endi) ending string (ng string) ending string (.) ending string (" -- Iteration 13 -- -Deprecated: Implicit conversion to int from non-compatible float 9.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 9.2 to int in %s on line %d string(217) "This is t) numbers 1234 (o test ch) numbers 1234 (unk_split) numbers 1234 (() with v) numbers 1234 (arious 's) numbers 1234 (ingle quo) numbers 1234 (ted' endi) numbers 1234 (ng string) numbers 1234 (.) numbers 1234 (" -- Iteration 14 -- -Deprecated: Implicit conversion to int from non-compatible float 9.200000 in %s on line %d +Deprecated: Implicit conversion from non-compatible float 9.2 to int in %s on line %d string(226) "This is t) speci@! ch@r$ (o test ch) speci@! ch@r$ (unk_split) speci@! ch@r$ (() with v) speci@! ch@r$ (arious 's) speci@! ch@r$ (ingle quo) speci@! ch@r$ (ted' endi) speci@! ch@r$ (ng string) speci@! ch@r$ (.) speci@! ch@r$ (" Done From 737c67464a7585cf175bb58356e01a577b4f7151 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Mon, 19 Apr 2021 13:39:00 +0100 Subject: [PATCH 21/61] ct_eval should not emit notices Does anything need to be done when an incompatible float is reached tho? --- Zend/zend_compile.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 3c473f443397b..578513c4e2e59 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -8353,10 +8353,16 @@ static bool zend_try_ct_eval_array(zval *result, zend_ast *ast) /* {{{ */ case IS_STRING: zend_symtable_update(Z_ARRVAL_P(result), Z_STR_P(key), value); break; - case IS_DOUBLE: - zend_hash_index_update(Z_ARRVAL_P(result), - zend_dval_to_lval_safe(Z_DVAL_P(key)), value); + case IS_DOUBLE: { + zend_long lval = zend_dval_to_lval(Z_DVAL_P(key)); + /* TODO Should bailout on incompatible float? + if (!zend_is_long_compatible(Z_DVAL_P(key), lval)) { + // Notice? + } + */ + zend_hash_index_update(Z_ARRVAL_P(result), lval, value); break; + } case IS_FALSE: zend_hash_index_update(Z_ARRVAL_P(result), 0, value); break; From fbbb5e41f4987c8ef67a577dada994d0a23844a7 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Mon, 19 Apr 2021 14:24:30 +0100 Subject: [PATCH 22/61] Fix some tests --- ext/calendar/tests/bug80185.phpt | 8 +- ext/calendar/tests/bug80185_32bit.phpt | 4 +- ext/gd/tests/bug43073.phpt | 2 +- ext/gd/tests/bug53504.phpt | 4 +- ext/mbstring/tests/iso2022jp_ms_encoding.phpt | 2 +- ...titute_character_variation_weak_types.phpt | 6 +- .../tests/mysqli_stmt_bind_result_format.phpt | 4 +- .../tests/file/disk_free_space_basic.phpt | 4 +- .../tests/math/decbin_variation1.phpt | 84 ++------------ .../tests/math/decbin_variation1_64bit.phpt | 102 +++-------------- .../tests/math/dechex_variation1.phpt | 84 ++------------ .../tests/math/dechex_variation1_64bit.phpt | 103 +++--------------- .../tests/math/decoct_variation1.phpt | 81 ++------------ .../tests/math/decoct_variation1_64bit.phpt | 101 +++-------------- .../tests/strings/bug23894_32bit.phpt | 4 +- .../tests/strings/fprintf_variation_003.phpt | 4 +- .../tests/strings/fprintf_variation_006.phpt | 4 +- .../tests/strings/fprintf_variation_007.phpt | 4 +- .../tests/strings/fprintf_variation_008.phpt | 4 +- ext/standard/tests/strings/printf.phpt | 62 ++++------- .../tests/strings/vprintf_variation12.phpt | 36 ++---- .../tests/strings/vprintf_variation14.phpt | 36 ++---- .../tests/strings/vprintf_variation4.phpt | 26 +---- 23 files changed, 150 insertions(+), 619 deletions(-) diff --git a/ext/calendar/tests/bug80185.phpt b/ext/calendar/tests/bug80185.phpt index f297f7060aca7..b239468109e7b 100644 --- a/ext/calendar/tests/bug80185.phpt +++ b/ext/calendar/tests/bug80185.phpt @@ -9,18 +9,14 @@ if (PHP_INT_SIZE != 8) die("skip for 64bit platforms only"); --FILE-- getMessage(), PHP_EOL; } ?> --EXPECTF-- int(2170713600) - -Deprecated: Implicit conversion to int from non-compatible float 106751993607888.640625 in %s on line %d int(9223372036854720000) - -Deprecated: Implicit conversion to int from non-compatible float 106751993607889.640625 in %s on line %d jday must be between 2440588 and 106751993607888 diff --git a/ext/calendar/tests/bug80185_32bit.phpt b/ext/calendar/tests/bug80185_32bit.phpt index a7fe96e0ff4a1..8d7088fe856c2 100644 --- a/ext/calendar/tests/bug80185_32bit.phpt +++ b/ext/calendar/tests/bug80185_32bit.phpt @@ -13,9 +13,9 @@ try { } catch (ValueError $ex) { echo $ex->getMessage(), PHP_EOL; } -var_dump(jdtounix(PHP_INT_MAX / 86400 + 2440588)); +var_dump(jdtounix((int)(PHP_INT_MAX / 86400 + 2440588))); try { - var_dump(jdtounix(PHP_INT_MAX / 86400 + 2440589)); + var_dump(jdtounix((int)(PHP_INT_MAX / 86400 + 2440589))); } catch (ValueError $ex) { echo $ex->getMessage(), PHP_EOL; } diff --git a/ext/gd/tests/bug43073.phpt b/ext/gd/tests/bug43073.phpt index 699c39bc42637..5c54d8770f86b 100644 --- a/ext/gd/tests/bug43073.phpt +++ b/ext/gd/tests/bug43073.phpt @@ -38,7 +38,7 @@ $y = 0; $cos_t = cos(deg2rad($delta_t)); $sin_t = sin(deg2rad($delta_t)); for ($angle = 0.0, $i = 0; $angle < 360.0; $angle += $delta_t, $i++) { - $bbox = imagettftext($g, 24, $angle, 400+$x, 400+$y, $black, $font, 'ABCDEF'); + $bbox = imagettftext($g, 24, (int)$angle, (int)(400+$x), (int)(400+$y), $black, $font, 'ABCDEF'); imagepolygon($g, $bbox, $red); printf("%2d: ", $i); for ($j = 0; $j < 8; $j++) { diff --git a/ext/gd/tests/bug53504.phpt b/ext/gd/tests/bug53504.phpt index 83073d82a21ab..bb74497af05ab 100644 --- a/ext/gd/tests/bug53504.phpt +++ b/ext/gd/tests/bug53504.phpt @@ -78,8 +78,8 @@ foreach ($tests as $testnum => $test) { // draw baseline: $width = sqrt(pow($bboxDrawn[2] - $bboxDrawn[0], 2) + pow($bboxDrawn[3] - $bboxDrawn[1], 2)); imageline($g, $test['x'], $test['y'], - $test['x'] + $width * cos(deg2rad($test['angle'])), - $test['y'] - $width * sin(deg2rad($test['angle'])), $blue); + $test['x'] + (int)($width * cos(deg2rad($test['angle']))), + $test['y'] - (int)($width * sin(deg2rad($test['angle']))), $blue); } imagepng($g, "$cwd/bug53504.png"); diff --git a/ext/mbstring/tests/iso2022jp_ms_encoding.phpt b/ext/mbstring/tests/iso2022jp_ms_encoding.phpt index dd49ce59e50d9..fc8b7fc153c20 100644 --- a/ext/mbstring/tests/iso2022jp_ms_encoding.phpt +++ b/ext/mbstring/tests/iso2022jp_ms_encoding.phpt @@ -54,7 +54,7 @@ foreach ([0x8790, 0x8791, 0x8792, 0x8795, 0x8796, 0x8797, 0x879A, 0x879B, 0x879C $udcChars = array(); for ($cp = 0xE000; $cp < (0xE000 + (20 * 94)); $cp++) { $i = $cp - 0xE000; - $bytes = ((($i / 94) + 0x7F - 0x5E) << 8) + (($i % 94) + 0x21); + $bytes = (( (int)($i / 94) + 0x7F - 0x5E) << 8) + (($i % 94) + 0x21); $udcChars[pack('n', $bytes)] = pack('N', $cp); } diff --git a/ext/mbstring/tests/mb_substitute_character_variation_weak_types.phpt b/ext/mbstring/tests/mb_substitute_character_variation_weak_types.phpt index 3b4f75ad756b4..bbd33268778e6 100644 --- a/ext/mbstring/tests/mb_substitute_character_variation_weak_types.phpt +++ b/ext/mbstring/tests/mb_substitute_character_variation_weak_types.phpt @@ -118,11 +118,11 @@ bool(true) ValueError: mb_substitute_character(): Argument #1 ($substitute_character) is not a valid codepoint --float 10.5-- -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion from non-compatible float 10.5 to int in %s on line %d bool(true) --float -10.5-- -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion from non-compatible float -10.5 to int in %s on line %d ValueError: mb_substitute_character(): Argument #1 ($substitute_character) is not a valid codepoint --float 10.0e19-- ValueError: mb_substitute_character(): Argument #1 ($substitute_character) must be "none", "long", "entity" or a valid codepoint @@ -130,7 +130,7 @@ ValueError: mb_substitute_character(): Argument #1 ($substitute_character) must ValueError: mb_substitute_character(): Argument #1 ($substitute_character) must be "none", "long", "entity" or a valid codepoint --float .5-- -Deprecated: Implicit conversion to int from non-compatible float in %s on line %d +Deprecated: Implicit conversion from non-compatible float 0.5 to int in %s on line %d bool(true) --empty array-- TypeError: mb_substitute_character(): Argument #1 ($substitute_character) must be of type string|int|null, array given diff --git a/ext/mysqli/tests/mysqli_stmt_bind_result_format.phpt b/ext/mysqli/tests/mysqli_stmt_bind_result_format.phpt index ae778472ed1e8..93e0b4313d8b4 100644 --- a/ext/mysqli/tests/mysqli_stmt_bind_result_format.phpt +++ b/ext/mysqli/tests/mysqli_stmt_bind_result_format.phpt @@ -227,7 +227,7 @@ memory_limit=83886080 $current_targets = mt_rand(-100000, 100000) / 10; do { $trend = (mt_rand(0, 3) > 1) ? (mt_rand(-10000, 10000) / 100) : 'NULL'; - } while (isset($values[$trend])); + } while (isset($values[(int)$trend])); $sql = sprintf('INSERT INTO test(targetport, current_targets, maxreports, trend) VALUES (%d, %f, %s, %s)', $i, @@ -239,7 +239,7 @@ memory_limit=83886080 break 2; } if ($current_targets > 0 && $trend !== 'NULL') - $values[$trend] = $i; + $values[(int)$trend] = $i; } krsort($values); diff --git a/ext/standard/tests/file/disk_free_space_basic.phpt b/ext/standard/tests/file/disk_free_space_basic.phpt index f2588e89494d6..1590b71123f93 100644 --- a/ext/standard/tests/file/disk_free_space_basic.phpt +++ b/ext/standard/tests/file/disk_free_space_basic.phpt @@ -60,9 +60,7 @@ float(%f) Free Space after writing to a file float(%f) - Free Space Value Is Incorrect -float(892086792192) -float(892086792192) + Free Space Value Is Correct *** Testing with Binary Input *** float(%f) diff --git a/ext/standard/tests/math/decbin_variation1.phpt b/ext/standard/tests/math/decbin_variation1.phpt index 5ac82d41d6a77..b2744bb1b6bf4 100644 --- a/ext/standard/tests/math/decbin_variation1.phpt +++ b/ext/standard/tests/math/decbin_variation1.phpt @@ -10,21 +10,7 @@ if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); $input) { +foreach ($inputs as $i => $input) { $iterator = $i + 1; echo "\n-- Iteration $iterator --\n"; - try { var_dump(decbin($input)); } catch (TypeError $exception) { echo $exception->getMessage() . "\n"; } } -fclose($fp); ?> --EXPECT-- @@ -99,52 +67,22 @@ decbin(): Argument #1 ($num) must be of type int, float given decbin(): Argument #1 ($num) must be of type int, float given -- Iteration 7 -- -string(4) "1010" +decbin(): Argument #1 ($num) must be of type int, float given -- Iteration 8 -- -string(32) "11111111111111111111111111110110" +string(1) "1" -- Iteration 9 -- -decbin(): Argument #1 ($num) must be of type int, float given +string(1) "0" -- Iteration 10 -- -string(1) "0" +string(1) "1" -- Iteration 11 -- string(1) "0" -- Iteration 12 -- -string(1) "1" - --- Iteration 13 -- -string(1) "0" - --- Iteration 14 -- -string(1) "1" - --- Iteration 15 -- -string(1) "0" - --- Iteration 16 -- -decbin(): Argument #1 ($num) must be of type int, string given - --- Iteration 17 -- decbin(): Argument #1 ($num) must be of type int, string given --- Iteration 18 -- -decbin(): Argument #1 ($num) must be of type int, array given - --- Iteration 19 -- -decbin(): Argument #1 ($num) must be of type int, string given - --- Iteration 20 -- -decbin(): Argument #1 ($num) must be of type int, string given - --- Iteration 21 -- +-- Iteration 13 -- decbin(): Argument #1 ($num) must be of type int, string given - --- Iteration 22 -- -decbin(): Argument #1 ($num) must be of type int, classA given - --- Iteration 23 -- -decbin(): Argument #1 ($num) must be of type int, resource given diff --git a/ext/standard/tests/math/decbin_variation1_64bit.phpt b/ext/standard/tests/math/decbin_variation1_64bit.phpt index 6458978ca7c50..1ba3a6387130b 100644 --- a/ext/standard/tests/math/decbin_variation1_64bit.phpt +++ b/ext/standard/tests/math/decbin_variation1_64bit.phpt @@ -10,61 +10,31 @@ if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); $input) { +foreach ($inputs as $i => $input) { $iterator = $i + 1; echo "\n-- Iteration $iterator --\n"; try { @@ -73,9 +43,9 @@ foreach($inputs as $i => $input) { echo $exception->getMessage() . "\n"; } } -fclose($fp); + ?> ---EXPECTF-- +--EXPECT-- *** Testing decbin() : usage variations *** -- Iteration 1 -- @@ -91,66 +61,28 @@ string(14) "11000000111001" string(64) "1111111111111111111111111111111111111111111111111111011011010111" -- Iteration 5 -- -decbin(): Argument #1 ($num) must be of type int, float given +string(32) "11111111111111111111111111111111" -- Iteration 6 -- -decbin(): Argument #1 ($num) must be of type int, float given +string(33) "100000000000000000000000000000000" -- Iteration 7 -- - -Deprecated: Implicit conversion from non-compatible float 10.5 to int in %s on line %d -string(4) "1010" +string(37) "1110010111110100110010001101000001000" -- Iteration 8 -- - -Deprecated: Implicit conversion from non-compatible float -10.5 to int in %s on line %d -string(64) "1111111111111111111111111111111111111111111111111111111111110110" +string(1) "1" -- Iteration 9 -- -string(37) "1110010111110100110010001101000001000" +string(1) "0" -- Iteration 10 -- - -Deprecated: Implicit conversion from non-compatible float 1.23456789E-9 to int in %s on line %d -string(1) "0" +string(1) "1" -- Iteration 11 -- - -Deprecated: Implicit conversion from non-compatible float 0.5 to int in %s on line %d string(1) "0" -- Iteration 12 -- -string(1) "1" - --- Iteration 13 -- -string(1) "0" - --- Iteration 14 -- -string(1) "1" - --- Iteration 15 -- -string(1) "0" - --- Iteration 16 -- -decbin(): Argument #1 ($num) must be of type int, string given - --- Iteration 17 -- decbin(): Argument #1 ($num) must be of type int, string given --- Iteration 18 -- -decbin(): Argument #1 ($num) must be of type int, array given - --- Iteration 19 -- -decbin(): Argument #1 ($num) must be of type int, string given - --- Iteration 20 -- -decbin(): Argument #1 ($num) must be of type int, string given - --- Iteration 21 -- +-- Iteration 13 -- decbin(): Argument #1 ($num) must be of type int, string given - --- Iteration 22 -- -decbin(): Argument #1 ($num) must be of type int, classA given - --- Iteration 23 -- -decbin(): Argument #1 ($num) must be of type int, resource given diff --git a/ext/standard/tests/math/dechex_variation1.phpt b/ext/standard/tests/math/dechex_variation1.phpt index 8fee0d42ad7f8..4e014f35b7606 100644 --- a/ext/standard/tests/math/dechex_variation1.phpt +++ b/ext/standard/tests/math/dechex_variation1.phpt @@ -10,21 +10,7 @@ if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); $input) { +foreach ($inputs as $i => $input) { $iterator = $i + 1; echo "\n-- Iteration $iterator --\n"; try { @@ -72,9 +42,7 @@ foreach($inputs as $i => $input) { } catch (TypeError $exception) { echo $exception->getMessage() . "\n"; } - $iterator++; } -fclose($fp); ?> --EXPECT-- @@ -99,52 +67,22 @@ dechex(): Argument #1 ($num) must be of type int, float given dechex(): Argument #1 ($num) must be of type int, float given -- Iteration 7 -- -string(1) "a" +dechex(): Argument #1 ($num) must be of type int, float given -- Iteration 8 -- -string(8) "fffffff6" +string(1) "1" -- Iteration 9 -- -dechex(): Argument #1 ($num) must be of type int, float given +string(1) "0" -- Iteration 10 -- -string(1) "0" +string(1) "1" -- Iteration 11 -- string(1) "0" -- Iteration 12 -- -string(1) "1" - --- Iteration 13 -- -string(1) "0" - --- Iteration 14 -- -string(1) "1" - --- Iteration 15 -- -string(1) "0" - --- Iteration 16 -- -dechex(): Argument #1 ($num) must be of type int, string given - --- Iteration 17 -- dechex(): Argument #1 ($num) must be of type int, string given --- Iteration 18 -- -dechex(): Argument #1 ($num) must be of type int, array given - --- Iteration 19 -- -dechex(): Argument #1 ($num) must be of type int, string given - --- Iteration 20 -- -dechex(): Argument #1 ($num) must be of type int, string given - --- Iteration 21 -- +-- Iteration 13 -- dechex(): Argument #1 ($num) must be of type int, string given - --- Iteration 22 -- -dechex(): Argument #1 ($num) must be of type int, classA given - --- Iteration 23 -- -dechex(): Argument #1 ($num) must be of type int, resource given diff --git a/ext/standard/tests/math/dechex_variation1_64bit.phpt b/ext/standard/tests/math/dechex_variation1_64bit.phpt index 5b79b53d32d65..ed04b43e3e04c 100644 --- a/ext/standard/tests/math/dechex_variation1_64bit.phpt +++ b/ext/standard/tests/math/dechex_variation1_64bit.phpt @@ -10,73 +10,42 @@ if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); $input) { +foreach ($inputs as $i => $input) { $iterator = $i + 1; echo "\n-- Iteration $iterator --\n"; try { - var_dump(dechex($input)); + var_dump(dechex($input)); } catch (TypeError $exception) { echo $exception->getMessage() . "\n"; } } -fclose($fp); ?> ---EXPECTF-- +--EXPECT-- *** Testing dechex() : usage variations *** -- Iteration 1 -- @@ -92,66 +61,28 @@ string(4) "3039" string(16) "fffffffffffff6d7" -- Iteration 5 -- -dechex(): Argument #1 ($num) must be of type int, float given +string(8) "ffffffff" -- Iteration 6 -- -dechex(): Argument #1 ($num) must be of type int, float given +string(9) "100000000" -- Iteration 7 -- - -Deprecated: Implicit conversion from non-compatible float 10.5 to int in %s on line %d -string(1) "a" +string(10) "1cbe991a08" -- Iteration 8 -- - -Deprecated: Implicit conversion from non-compatible float -10.5 to int in %s on line %d -string(16) "fffffffffffffff6" +string(1) "1" -- Iteration 9 -- -string(10) "1cbe991a08" +string(1) "0" -- Iteration 10 -- - -Deprecated: Implicit conversion from non-compatible float 1.23456789E-9 to int in %s on line %d -string(1) "0" +string(1) "1" -- Iteration 11 -- - -Deprecated: Implicit conversion from non-compatible float 0.5 to int in %s on line %d string(1) "0" -- Iteration 12 -- -string(1) "1" - --- Iteration 13 -- -string(1) "0" - --- Iteration 14 -- -string(1) "1" - --- Iteration 15 -- -string(1) "0" - --- Iteration 16 -- -dechex(): Argument #1 ($num) must be of type int, string given - --- Iteration 17 -- dechex(): Argument #1 ($num) must be of type int, string given --- Iteration 18 -- -dechex(): Argument #1 ($num) must be of type int, array given - --- Iteration 19 -- -dechex(): Argument #1 ($num) must be of type int, string given - --- Iteration 20 -- -dechex(): Argument #1 ($num) must be of type int, string given - --- Iteration 21 -- +-- Iteration 13 -- dechex(): Argument #1 ($num) must be of type int, string given - --- Iteration 22 -- -dechex(): Argument #1 ($num) must be of type int, classA given - --- Iteration 23 -- -dechex(): Argument #1 ($num) must be of type int, resource given diff --git a/ext/standard/tests/math/decoct_variation1.phpt b/ext/standard/tests/math/decoct_variation1.phpt index 608bb568735fb..1936464fd4b39 100644 --- a/ext/standard/tests/math/decoct_variation1.phpt +++ b/ext/standard/tests/math/decoct_variation1.phpt @@ -10,21 +10,7 @@ if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); $input) { @@ -73,7 +43,6 @@ foreach ($inputs as $i => $input) { echo $exception->getMessage() . "\n"; } } -fclose($fp); ?> --EXPECT-- @@ -98,52 +67,22 @@ decoct(): Argument #1 ($num) must be of type int, float given decoct(): Argument #1 ($num) must be of type int, float given -- Iteration 7 -- -string(2) "12" +decoct(): Argument #1 ($num) must be of type int, float given -- Iteration 8 -- -string(11) "37777777766" +string(1) "1" -- Iteration 9 -- -decoct(): Argument #1 ($num) must be of type int, float given +string(1) "0" -- Iteration 10 -- -string(1) "0" +string(1) "1" -- Iteration 11 -- string(1) "0" -- Iteration 12 -- -string(1) "1" - --- Iteration 13 -- -string(1) "0" - --- Iteration 14 -- -string(1) "1" - --- Iteration 15 -- -string(1) "0" - --- Iteration 16 -- -decoct(): Argument #1 ($num) must be of type int, string given - --- Iteration 17 -- decoct(): Argument #1 ($num) must be of type int, string given --- Iteration 18 -- -decoct(): Argument #1 ($num) must be of type int, array given - --- Iteration 19 -- -decoct(): Argument #1 ($num) must be of type int, string given - --- Iteration 20 -- -decoct(): Argument #1 ($num) must be of type int, string given - --- Iteration 21 -- +-- Iteration 13 -- decoct(): Argument #1 ($num) must be of type int, string given - --- Iteration 22 -- -decoct(): Argument #1 ($num) must be of type int, classA given - --- Iteration 23 -- -decoct(): Argument #1 ($num) must be of type int, resource given diff --git a/ext/standard/tests/math/decoct_variation1_64bit.phpt b/ext/standard/tests/math/decoct_variation1_64bit.phpt index 0f87478b58960..b6d3a4a391d4d 100644 --- a/ext/standard/tests/math/decoct_variation1_64bit.phpt +++ b/ext/standard/tests/math/decoct_variation1_64bit.phpt @@ -10,61 +10,31 @@ if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); $input) { +foreach ($inputs as $i => $input) { $iterator = $i + 1; echo "\n-- Iteration $iterator --\n"; try { @@ -73,10 +43,9 @@ foreach($inputs as $i => $input) { echo $exception->getMessage() . "\n"; } } -fclose($fp); ?> ---EXPECTF-- +--EXPECT-- *** Testing decoct() : usage variations *** -- Iteration 1 -- @@ -92,66 +61,28 @@ string(5) "30071" string(22) "1777777777777777773327" -- Iteration 5 -- -decoct(): Argument #1 ($num) must be of type int, float given +string(11) "37777777777" -- Iteration 6 -- -decoct(): Argument #1 ($num) must be of type int, float given +string(11) "40000000000" -- Iteration 7 -- - -Deprecated: Implicit conversion from non-compatible float 10.5 to int in %s on line %d -string(2) "12" +string(13) "1627646215010" -- Iteration 8 -- - -Deprecated: Implicit conversion from non-compatible float -10.5 to int in %s on line %d -string(22) "1777777777777777777766" +string(1) "1" -- Iteration 9 -- -string(13) "1627646215010" +string(1) "0" -- Iteration 10 -- - -Deprecated: Implicit conversion from non-compatible float 1.23456789E-9 to int in %s on line %d -string(1) "0" +string(1) "1" -- Iteration 11 -- - -Deprecated: Implicit conversion from non-compatible float 0.5 to int in %s on line %d string(1) "0" -- Iteration 12 -- -string(1) "1" - --- Iteration 13 -- -string(1) "0" - --- Iteration 14 -- -string(1) "1" - --- Iteration 15 -- -string(1) "0" - --- Iteration 16 -- -decoct(): Argument #1 ($num) must be of type int, string given - --- Iteration 17 -- decoct(): Argument #1 ($num) must be of type int, string given --- Iteration 18 -- -decoct(): Argument #1 ($num) must be of type int, array given - --- Iteration 19 -- -decoct(): Argument #1 ($num) must be of type int, string given - --- Iteration 20 -- -decoct(): Argument #1 ($num) must be of type int, string given - --- Iteration 21 -- +-- Iteration 13 -- decoct(): Argument #1 ($num) must be of type int, string given - --- Iteration 22 -- -decoct(): Argument #1 ($num) must be of type int, classA given - --- Iteration 23 -- -decoct(): Argument #1 ($num) must be of type int, resource given diff --git a/ext/standard/tests/strings/bug23894_32bit.phpt b/ext/standard/tests/strings/bug23894_32bit.phpt index 9ab8c472375fe..58b74722b9764 100644 --- a/ext/standard/tests/strings/bug23894_32bit.phpt +++ b/ext/standard/tests/strings/bug23894_32bit.phpt @@ -13,10 +13,10 @@ $test = sprintf("% 13u", $a); var_dump($test, bin2hex($test)); ?> --EXPECTF-- -Deprecated: Implicit conversion to int from non-compatible float -12.345600 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -12.3456 to int in %s on line %d string(4) "-012" string(8) "2d303132" -Deprecated: Implicit conversion to int from non-compatible float -12.345600 in %s on line %d +Deprecated: Implicit conversion from non-compatible float -12.3456 to int in %s on line %d string(13) " 4294967284" string(26) "20202034323934393637323834" diff --git a/ext/standard/tests/strings/fprintf_variation_003.phpt b/ext/standard/tests/strings/fprintf_variation_003.phpt index 9e9779371edd4..ea767c93cb686 100644 --- a/ext/standard/tests/strings/fprintf_variation_003.phpt +++ b/ext/standard/tests/strings/fprintf_variation_003.phpt @@ -7,7 +7,7 @@ if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); --FILE-- + [0] => [1] => abc [2] => aaa ) - + abc aaa - -abc -aaa + +abc +aaa 00000 00abc 00aaa diff --git a/ext/standard/tests/strings/vprintf_variation12.phpt b/ext/standard/tests/strings/vprintf_variation12.phpt index cac53da18f4d8..b369cea54d16b 100644 --- a/ext/standard/tests/strings/vprintf_variation12.phpt +++ b/ext/standard/tests/strings/vprintf_variation12.phpt @@ -24,14 +24,6 @@ $formats = // Arrays of non octal values for the format defined in $format. // Each sub array contains non octal values which correspond to each format in $format $args_array = array( - - // array of float values - array(2.2, .2, 10.2, - 123456.234, -1234.6789, +1234.6789, - 2e10, +2e12, 22e+12, - 12345.780, 12.000000011111, -12.00000111111, -123456.234, - 3.33, +4.44, 1.11,-2.22 ), - // array of int values array(2, -2, +2, 123456, -12346789, +12346789, @@ -78,41 +70,33 @@ foreach($args_array as $args) { *** Testing vprintf() : octal formats and non-octal values *** -- Iteration 1 -- -2 0 12 - 361100 37777775456 2322 - - 30071 14 37777777764 37777416700 - 12 361100 2 0 -int(112) - --- Iteration 2 -- 2 37777777776 2 361100 37720715133 57062645 - + 57060664 4475347 37721631371 37720717336 2 361100 2 37777777776 int(142) --- Iteration 3 -- +-- Iteration 2 -- 0 0 0 - 173 37777777605 173 - + 173 37777777605 173 + 2322 0 $0 _0 0 173 0 0 int(84) --- Iteration 4 -- +-- Iteration 3 -- 1 1 1 - 1 1 1 - + 1 1 1 + #1 1 $1 _1 1 1 1 1 int(71) --- Iteration 5 -- +-- Iteration 4 -- 1 1 0 - 1 0 1 - + 1 0 1 + #0 1 $1 _0 0 1 1 1 int(71) diff --git a/ext/standard/tests/strings/vprintf_variation14.phpt b/ext/standard/tests/strings/vprintf_variation14.phpt index ce65e8726d871..ac24a94695bd9 100644 --- a/ext/standard/tests/strings/vprintf_variation14.phpt +++ b/ext/standard/tests/strings/vprintf_variation14.phpt @@ -24,14 +24,6 @@ $formats = // Arrays of non hexa values for the format defined in $format. // Each sub array contains non hexa values which correspond to each format in $format $args_array = array( - - // array of float values - array(2.2, .2, 10.2, - 123456.234, -1234.6789, +1234.6789, - 2e10, +2e12, 22e+12, - 12345.780, 12.000000011111, -12.00000111111, -123456.234, - 3.33, +4.44, 1.11,-2.22 ), - // array of int values array(2, -2, +2, 123456, -12346789, +12346789, @@ -79,41 +71,33 @@ foreach($args_array as $args) { *** Testing vprintf() : hexa formats and non-hexa values *** -- Iteration 1 -- -2 0 a - 1e240 x fffffb2e 4d2 - - 3039 c fffffff4 fffe1dc0 - a 1e240 2 0 -int(99) - --- Iteration 2 -- 2 fffffffe 2 1e240 x ff439a5b bc65a5 - + bc61b4 127ae7 ff4732f9 ff439ede 2 1e240 2 fffffffe int(122) --- Iteration 3 -- +-- Iteration 2 -- 0 0 0 - 7b x ffffff85 7b - + 7b x ffffff85 7b + 4d2 0 $0 _0 0 7b 0 0 int(80) --- Iteration 4 -- +-- Iteration 3 -- 1 1 1 - 1 x 1 1 - + 1 x 1 1 + #1 1 $1 _1 1 1 1 1 int(73) --- Iteration 5 -- +-- Iteration 4 -- 1 1 0 - 1 x 0 1 - + 1 x 0 1 + #0 1 $1 _0 0 1 1 1 int(73) diff --git a/ext/standard/tests/strings/vprintf_variation4.phpt b/ext/standard/tests/strings/vprintf_variation4.phpt index 63018a9db8a86..d489d36835da7 100644 --- a/ext/standard/tests/strings/vprintf_variation4.phpt +++ b/ext/standard/tests/strings/vprintf_variation4.phpt @@ -24,14 +24,6 @@ $formats = // Arrays of non int values for the format defined in $format. // Each sub array contains non int values which correspond to each format in $format $args_array = array( - - // array of float values - array(2.2, .2, 10.2, - 123456.234, -1234.6789, +1234.6789, - 2e10, +2e5, 4e3, 22e+6, - 12345.780, 12.000000011111, -12.00000111111, -123456.234, - 3.33, +4.44, 1.11,-2.22 ), - // array of strings array(" ", ' ', 'hello', '123hello', '-123hello', '+123hello', @@ -71,32 +63,24 @@ foreach($args_array as $args) { *** Testing vprintf() : int formats and non-integer values *** -- Iteration 1 -- -2 +0 10 - 123456 -1234 1234 - -1474836480 200000 4000 22000000 - 12345 12 -12 -123456 - 10 123456 2 0 -int(109) - --- Iteration 2 -- 0 +0 0 - 123 -123 123 + 123 -123 123 0 0 123456 0000 1234 0 $0 _0 0 123 0 0 int(89) --- Iteration 3 -- +-- Iteration 2 -- 1 +1 1 - 1 1 1 + 1 1 1 1 1 1 0001 #1 1 $1 _1 1 1 1 1 int(78) --- Iteration 4 -- +-- Iteration 3 -- 1 +1 0 - 1 0 1 + 1 0 1 1 0 1 0000 #0 1 $1 _0 0 1 1 1 From 77c4f5bbeba73e3020095da68a9f3c7d9bf3bee1 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Tue, 20 Apr 2021 14:33:43 +0100 Subject: [PATCH 23/61] Add a ZEND_API for linking --- Zend/zend_operators.c | 2 +- Zend/zend_operators.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 62dc1c3a9f91d..59cc252133ae0 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -809,7 +809,7 @@ ZEND_API void ZEND_FASTCALL convert_to_object(zval *op) /* {{{ */ } /* }}} */ -void zend_incompatible_double_to_long_error(double d) +ZEND_API void zend_incompatible_double_to_long_error(double d) { zend_error_unchecked(E_DEPRECATED, "Implicit conversion from non-compatible float %.*H to int", -1, d); } diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index edfd93c13ad24..a4422372b366c 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -138,7 +138,7 @@ static zend_always_inline bool zend_is_long_compatible(double d, zend_long l) { return ((double)l == d); } -void zend_incompatible_double_to_long_error(double d); +ZEND_API void zend_incompatible_double_to_long_error(double d); static zend_always_inline zend_long zend_dval_to_lval_safe(double d) { From 6b230565b505a73a3a596d85db09ffd183ddb223 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Tue, 20 Apr 2021 16:45:47 +0100 Subject: [PATCH 24/61] Fix compile time evaluation --- .../float_to_int/warnings_float_literals.phpt | 23 ++++++++++--------- .../warnings_string_float_literals.phpt | 21 +++++++++-------- Zend/zend_compile.c | 15 +++++++++++- 3 files changed, 37 insertions(+), 22 deletions(-) diff --git a/Zend/tests/float_to_int/warnings_float_literals.phpt b/Zend/tests/float_to_int/warnings_float_literals.phpt index bedf1e9577929..8d9658cb75d5c 100644 --- a/Zend/tests/float_to_int/warnings_float_literals.phpt +++ b/Zend/tests/float_to_int/warnings_float_literals.phpt @@ -69,36 +69,37 @@ var_dump($instance->a); ?> --EXPECTF-- +Bitwise ops: + Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d +int(-2) Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d +int(3) Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d +int(1) Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d +int(2) Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d +int(8) Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d +int(0) Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d +int(6) Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d +int(1) +Modulo: Deprecated: Implicit conversion from non-compatible float 6.5 to int in %s on line %d +int(0) Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d -Bitwise ops: -int(-2) -int(3) -int(1) -int(2) -int(8) -int(0) -int(6) -int(1) -Modulo: -int(0) int(1) Offset access: Arrays: diff --git a/Zend/tests/float_to_int/warnings_string_float_literals.phpt b/Zend/tests/float_to_int/warnings_string_float_literals.phpt index 73a113b5d342c..27606be602f62 100644 --- a/Zend/tests/float_to_int/warnings_string_float_literals.phpt +++ b/Zend/tests/float_to_int/warnings_string_float_literals.phpt @@ -52,33 +52,34 @@ var_dump($instance->a); ?> --EXPECTF-- +Bitwise ops: + Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d +int(3) Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d +int(1) Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d +int(2) Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d +int(8) Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d +int(0) Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d +int(6) Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d +int(1) +Modulo: Deprecated: Implicit conversion to int from non-compatible float-string 6.5 in %s on line %d +int(0) Deprecated: Implicit conversion to int from non-compatible float-string 2.5 in %s on line %d -Bitwise ops: -int(3) -int(1) -int(2) -int(8) -int(0) -int(6) -int(1) -Modulo: -int(0) int(1) Function calls: diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 578513c4e2e59..bd7b90bc624f0 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -8207,6 +8207,18 @@ ZEND_API bool zend_binary_op_produces_error(uint32_t opcode, zval *op1, zval *op return 1; } + /* Operation which cast float/float-strings to integers might produce incompatible float to int errors */ + if (opcode == ZEND_SL || opcode == ZEND_SR || opcode == ZEND_BW_OR + || opcode == ZEND_BW_AND || opcode == ZEND_BW_XOR || opcode == ZEND_MOD) { + if (Z_TYPE_P(op1) == IS_DOUBLE || Z_TYPE_P(op2) == IS_DOUBLE) { + return true; + } + if ((Z_TYPE_P(op1) == IS_STRING && is_numeric_str_function(Z_STR_P(op1), NULL, NULL) != IS_LONG) + || (Z_TYPE_P(op2) == IS_STRING && is_numeric_str_function(Z_STR_P(op2), NULL, NULL) != IS_LONG)) { + return true; + } + } + return 0; } /* }}} */ @@ -8226,7 +8238,8 @@ static inline bool zend_try_ct_eval_binary_op(zval *result, uint32_t opcode, zva ZEND_API bool zend_unary_op_produces_error(uint32_t opcode, zval *op) { if (opcode == ZEND_BW_NOT) { - return Z_TYPE_P(op) <= IS_TRUE || Z_TYPE_P(op) == IS_ARRAY; + return (Z_TYPE_P(op) <= IS_TRUE || Z_TYPE_P(op) == IS_ARRAY || Z_TYPE_P(op) == IS_DOUBLE + || (Z_TYPE_P(op) == IS_STRING && is_numeric_str_function(Z_STR_P(op), NULL, NULL) != IS_LONG)); } return 0; From bb5a746f38e7cb67b96bb96aa5636da4df175ef9 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Tue, 20 Apr 2021 16:47:04 +0100 Subject: [PATCH 25/61] Remove error_reporting after fixing compile time eval --- Zend/tests/runtime_compile_time_binary_operands.phpt | 1 - 1 file changed, 1 deletion(-) diff --git a/Zend/tests/runtime_compile_time_binary_operands.phpt b/Zend/tests/runtime_compile_time_binary_operands.phpt index f1f04e078a811..14195141b111e 100644 --- a/Zend/tests/runtime_compile_time_binary_operands.phpt +++ b/Zend/tests/runtime_compile_time_binary_operands.phpt @@ -2,7 +2,6 @@ Test binary operands exposing the same behavior at compile as at run time --INI-- memory_limit=256M -error_reporting=E_ALL & ~E_DEPRECATED --FILE-- Date: Tue, 20 Apr 2021 16:49:53 +0100 Subject: [PATCH 26/61] Fix test heading --- .../warning_float_does_not_fit_zend_long_strings.phpt | 2 +- .../warning_float_does_not_fit_zend_long_write_variation2.phpt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_strings.phpt b/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_strings.phpt index a72758616097d..8b46ab469235f 100644 --- a/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_strings.phpt +++ b/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_strings.phpt @@ -1,5 +1,5 @@ --TEST-- -Implicit float to int conversions when float too large should warn, array variant +Implicit float to int conversions when float too large should warn, string offset variant --FILE-- Date: Tue, 20 Apr 2021 16:53:08 +0100 Subject: [PATCH 27/61] Bailout if array key is float --- Zend/zend_compile.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index bd7b90bc624f0..eb7b4a7b5396e 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -8368,11 +8368,12 @@ static bool zend_try_ct_eval_array(zval *result, zend_ast *ast) /* {{{ */ break; case IS_DOUBLE: { zend_long lval = zend_dval_to_lval(Z_DVAL_P(key)); - /* TODO Should bailout on incompatible float? + /* Incompatible float will generate an error, leave this to run-time */ if (!zend_is_long_compatible(Z_DVAL_P(key), lval)) { - // Notice? + zval_ptr_dtor_nogc(value); + zval_ptr_dtor(result); + return 0; } - */ zend_hash_index_update(Z_ARRVAL_P(result), lval, value); break; } From d3ed467b0a023a4dd77c30b0d578db2f32c0a972 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Tue, 20 Apr 2021 17:12:36 +0100 Subject: [PATCH 28/61] Standardize error message for float-strings --- .../warnings_string_float_literals.phpt | 26 ++++++++-------- ..._string_float_literals_assignment_ops.phpt | 12 ++++---- .../warnings_string_float_vars.phpt | 30 +++++++++---------- Zend/zend_API.c | 3 +- Zend/zend_operators.c | 10 ++++--- Zend/zend_operators.h | 1 + ext/standard/tests/math/decbin_basic.phpt | 4 +-- ext/standard/tests/math/dechex_basic.phpt | 4 +-- ext/standard/tests/math/decoct_basic.phpt | 4 +-- ext/standard/tests/math/round_basic.phpt | 18 +++++------ 10 files changed, 57 insertions(+), 55 deletions(-) diff --git a/Zend/tests/float_to_int/warnings_string_float_literals.phpt b/Zend/tests/float_to_int/warnings_string_float_literals.phpt index 27606be602f62..ceb8ec7d04331 100644 --- a/Zend/tests/float_to_int/warnings_string_float_literals.phpt +++ b/Zend/tests/float_to_int/warnings_string_float_literals.phpt @@ -54,45 +54,45 @@ var_dump($instance->a); --EXPECTF-- Bitwise ops: -Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d int(3) -Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d int(1) -Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d int(2) -Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d int(8) -Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d int(0) -Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d int(6) -Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d int(1) Modulo: -Deprecated: Implicit conversion to int from non-compatible float-string 6.5 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "6.5" to int in %s on line %d int(0) -Deprecated: Implicit conversion to int from non-compatible float-string 2.5 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "2.5" to int in %s on line %d int(1) Function calls: -Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d int(1) -Deprecated: Implicit conversion to int from non-compatible float-string 60.5 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "60.5" to int in %s on line %d string(1) "<" Function returns: -Deprecated: Implicit conversion to int from non-compatible float-string 3.5 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "3.5" to int in %s on line %d int(3) Typed property assignment: -Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d int(1) diff --git a/Zend/tests/float_to_int/warnings_string_float_literals_assignment_ops.phpt b/Zend/tests/float_to_int/warnings_string_float_literals_assignment_ops.phpt index dbb9d019154a3..57ea66d134bf3 100644 --- a/Zend/tests/float_to_int/warnings_string_float_literals_assignment_ops.phpt +++ b/Zend/tests/float_to_int/warnings_string_float_literals_assignment_ops.phpt @@ -34,21 +34,21 @@ var_dump($var); --EXPECTF-- Bitwise ops: -Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d int(3) -Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d int(1) -Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d int(2) -Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d int(6) -Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d int(1) Modulo: -Deprecated: Implicit conversion to int from non-compatible float-string 2.5 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "2.5" to int in %s on line %d int(1) diff --git a/Zend/tests/float_to_int/warnings_string_float_vars.phpt b/Zend/tests/float_to_int/warnings_string_float_vars.phpt index 557468998e237..b60a9e9cb0db4 100644 --- a/Zend/tests/float_to_int/warnings_string_float_vars.phpt +++ b/Zend/tests/float_to_int/warnings_string_float_vars.phpt @@ -74,51 +74,51 @@ var_dump($instance->a); --EXPECTF-- Bitwise ops: -Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d int(3) -Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d int(1) -Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d int(2) -Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d int(8) -Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d int(0) -Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d int(8) -Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d int(0) -Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d int(6) -Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d int(1) Modulo: -Deprecated: Implicit conversion to int from non-compatible float-string 6.5 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "6.5" to int in %s on line %d int(0) -Deprecated: Implicit conversion to int from non-compatible float-string 2.5 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "2.5" to int in %s on line %d int(1) Function calls: -Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d int(1) -Deprecated: Implicit conversion to int from non-compatible float-string 60.5 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "60.5" to int in %s on line %d string(1) "<" Function returns: -Deprecated: Implicit conversion to int from non-compatible float-string 3.5 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "3.5" to int in %s on line %d int(3) Typed property assignment: -Deprecated: Implicit conversion to int from non-compatible float-string 1.5 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d int(1) diff --git a/Zend/zend_API.c b/Zend/zend_API.c index e0e89809693b5..af5f71009ba80 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -534,8 +534,7 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest, * Check arg_num is not (uint32_t)-1, as otherwise its called by * zend_verify_weak_scalar_type_hint_no_sideeffect() */ if (UNEXPECTED(!zend_is_long_compatible(d, lval) && arg_num != (uint32_t)-1)) { - zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float-string %s", - Z_STRVAL_P(arg)); + zend_incompatible_string_to_long_error(Z_STR_P(arg)); if (UNEXPECTED(EG(exception))) { return 0; } diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 59cc252133ae0..a7cd9ab582cb5 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -344,8 +344,7 @@ static zend_never_inline zend_long ZEND_FASTCALL zendi_try_get_long(zval *op, bo */ lval = zend_dval_to_lval_cap(dval); if (!zend_is_long_compatible(dval, lval)) { - zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float-string %s", - Z_STRVAL_P(op)); + zend_incompatible_string_to_long_error(Z_STR_P(op)); if (UNEXPECTED(EG(exception))) { *failed = 1; } @@ -813,6 +812,10 @@ ZEND_API void zend_incompatible_double_to_long_error(double d) { zend_error_unchecked(E_DEPRECATED, "Implicit conversion from non-compatible float %.*H to int", -1, d); } +ZEND_API void zend_incompatible_string_to_long_error(const zend_string *s) +{ + zend_error(E_DEPRECATED, "Implicit conversion from non-compatible float-string \"%s\" to int", ZSTR_VAL(s)); +} ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op, bool is_strict) /* {{{ */ { @@ -859,8 +862,7 @@ ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op, bool is_strict) /* lval = zend_dval_to_lval_cap(dval); if (UNEXPECTED(is_strict)) { if (!zend_is_long_compatible(dval, lval)) { - zend_error(E_DEPRECATED, "Implicit conversion to int from non-compatible float-string %s", - Z_STRVAL_P(op)); + zend_incompatible_string_to_long_error(Z_STR_P(op)); // TODO Need to handle this here? //if (UNEXPECTED(EG(exception))) {} } diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index a4422372b366c..85a84408b8b5a 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -139,6 +139,7 @@ static zend_always_inline bool zend_is_long_compatible(double d, zend_long l) { } ZEND_API void zend_incompatible_double_to_long_error(double d); +ZEND_API void zend_incompatible_string_to_long_error(const zend_string *s); static zend_always_inline zend_long zend_dval_to_lval_safe(double d) { diff --git a/ext/standard/tests/math/decbin_basic.phpt b/ext/standard/tests/math/decbin_basic.phpt index c5087748790a5..6ab7c98c7ccc0 100644 --- a/ext/standard/tests/math/decbin_basic.phpt +++ b/ext/standard/tests/math/decbin_basic.phpt @@ -37,10 +37,10 @@ string(2) "11" string(7) "1011111" string(4) "1010" -Deprecated: Implicit conversion to int from non-compatible float-string 3950.5 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "3950.5" to int in %s on line %d string(12) "111101101110" -Deprecated: Implicit conversion to int from non-compatible float-string 3.9505e3 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "3.9505e3" to int in %s on line %d string(12) "111101101110" string(6) "100111" decbin(): Argument #1 ($num) must be of type int, string given diff --git a/ext/standard/tests/math/dechex_basic.phpt b/ext/standard/tests/math/dechex_basic.phpt index 2cecbdb0c8e46..ce06b77a767d7 100644 --- a/ext/standard/tests/math/dechex_basic.phpt +++ b/ext/standard/tests/math/dechex_basic.phpt @@ -37,10 +37,10 @@ string(1) "3" string(2) "5f" string(1) "a" -Deprecated: Implicit conversion to int from non-compatible float-string 3950.5 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "3950.5" to int in %s on line %d string(3) "f6e" -Deprecated: Implicit conversion to int from non-compatible float-string 3.9505e3 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "3.9505e3" to int in %s on line %d string(3) "f6e" string(2) "27" dechex(): Argument #1 ($num) must be of type int, string given diff --git a/ext/standard/tests/math/decoct_basic.phpt b/ext/standard/tests/math/decoct_basic.phpt index fab70c652cf6b..f0fc2356a4786 100644 --- a/ext/standard/tests/math/decoct_basic.phpt +++ b/ext/standard/tests/math/decoct_basic.phpt @@ -37,10 +37,10 @@ string(1) "3" string(3) "137" string(2) "12" -Deprecated: Implicit conversion to int from non-compatible float-string 3950.5 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "3950.5" to int in %s on line %d string(4) "7556" -Deprecated: Implicit conversion to int from non-compatible float-string 3.9505e3 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "3.9505e3" to int in %s on line %d string(4) "7556" string(2) "47" decoct(): Argument #1 ($num) must be of type int, string given diff --git a/ext/standard/tests/math/round_basic.phpt b/ext/standard/tests/math/round_basic.phpt index f1a7794f43a2d..a1e531b736349 100644 --- a/ext/standard/tests/math/round_basic.phpt +++ b/ext/standard/tests/math/round_basic.phpt @@ -50,7 +50,7 @@ Deprecated: Implicit conversion from non-compatible float 3.6 to int in %s on li ...with precision 2-> float(123456789) ...with precision 04-> float(123456789) -Deprecated: Implicit conversion to int from non-compatible float-string 3.6 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "3.6" to int in %s on line %d ...with precision 3.6-> float(123456789) ...with precision 2.1e1-> float(123456789) ...with precision 1-> float(123456789) @@ -66,7 +66,7 @@ Deprecated: Implicit conversion from non-compatible float 3.6 to int in %s on li ...with precision 2-> float(123.46) ...with precision 04-> float(123.4568) -Deprecated: Implicit conversion to int from non-compatible float-string 3.6 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "3.6" to int in %s on line %d ...with precision 3.6-> float(123.457) ...with precision 2.1e1-> float(123.456789) ...with precision 1-> float(123.5) @@ -82,7 +82,7 @@ Deprecated: Implicit conversion from non-compatible float 3.6 to int in %s on li ...with precision 2-> float(-4.57) ...with precision 04-> float(-4.5679) -Deprecated: Implicit conversion to int from non-compatible float-string 3.6 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "3.6" to int in %s on line %d ...with precision 3.6-> float(-4.568) ...with precision 2.1e1-> float(-4.5679123) ...with precision 1-> float(-4.6) @@ -98,7 +98,7 @@ Deprecated: Implicit conversion from non-compatible float 3.6 to int in %s on li ...with precision 2-> float(12300) ...with precision 04-> float(12300) -Deprecated: Implicit conversion to int from non-compatible float-string 3.6 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "3.6" to int in %s on line %d ...with precision 3.6-> float(12300) ...with precision 2.1e1-> float(12300) ...with precision 1-> float(12300) @@ -114,7 +114,7 @@ Deprecated: Implicit conversion from non-compatible float 3.6 to int in %s on li ...with precision 2-> float(-4567) ...with precision 04-> float(-4567) -Deprecated: Implicit conversion to int from non-compatible float-string 3.6 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "3.6" to int in %s on line %d ...with precision 3.6-> float(-4567) ...with precision 2.1e1-> float(-4567) ...with precision 1-> float(-4567) @@ -130,7 +130,7 @@ Deprecated: Implicit conversion from non-compatible float 3.6 to int in %s on li ...with precision 2-> float(2311527) ...with precision 04-> float(2311527) -Deprecated: Implicit conversion to int from non-compatible float-string 3.6 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "3.6" to int in %s on line %d ...with precision 3.6-> float(2311527) ...with precision 2.1e1-> float(2311527) ...with precision 1-> float(2311527) @@ -146,7 +146,7 @@ Deprecated: Implicit conversion from non-compatible float 3.6 to int in %s on li ...with precision 2-> float(14680063) ...with precision 04-> float(14680063) -Deprecated: Implicit conversion to int from non-compatible float-string 3.6 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "3.6" to int in %s on line %d ...with precision 3.6-> float(14680063) ...with precision 2.1e1-> float(14680063) ...with precision 1-> float(14680063) @@ -162,7 +162,7 @@ Deprecated: Implicit conversion from non-compatible float 3.6 to int in %s on li ...with precision 2-> float(1.23) ...with precision 04-> float(1.2346) -Deprecated: Implicit conversion to int from non-compatible float-string 3.6 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "3.6" to int in %s on line %d ...with precision 3.6-> float(1.235) ...with precision 2.1e1-> float(1.234567) ...with precision 1-> float(1.2) @@ -178,7 +178,7 @@ Deprecated: Implicit conversion from non-compatible float 3.6 to int in %s on li ...with precision 2-> float(234567890) ...with precision 04-> float(234567890) -Deprecated: Implicit conversion to int from non-compatible float-string 3.6 in %s on line %d +Deprecated: Implicit conversion from non-compatible float-string "3.6" to int in %s on line %d ...with precision 3.6-> float(234567890) ...with precision 2.1e1-> float(234567890) ...with precision 1-> float(234567890) From 443a1d4deae7beeee78d31cedc3c22599673d727 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Tue, 20 Apr 2021 17:35:22 +0100 Subject: [PATCH 29/61] Clarify why we need to use (uint32_t)-1 and not 0 Also fix handling in ZPP --- Zend/zend_API.c | 23 +++++++++++++---------- Zend/zend_execute.c | 3 ++- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Zend/zend_API.c b/Zend/zend_API.c index af5f71009ba80..ca4ca0caffbd7 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -504,10 +504,12 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest, return 0; } else { zend_long lval = zend_dval_to_lval(Z_DVAL_P(arg)); - /* Manually check arg_num is not (uint32_t)-1, as otherwise its called by - * zend_verify_weak_scalar_type_hint_no_sideeffect() */ - if (UNEXPECTED(!zend_is_long_compatible(Z_DVAL_P(arg), lval) && arg_num != (uint32_t)-1)) { - zend_incompatible_double_to_long_error(Z_DVAL_P(arg)); + if (UNEXPECTED(!zend_is_long_compatible(Z_DVAL_P(arg), lval))) { + /* Check arg_num is not (uint32_t)-1, as otherwise its called by + * zend_verify_weak_scalar_type_hint_no_sideeffect() */ + if (arg_num != (uint32_t)-1) { + zend_incompatible_double_to_long_error(Z_DVAL_P(arg)); + } if (UNEXPECTED(EG(exception))) { return 0; } @@ -529,12 +531,13 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest, } lval = zend_dval_to_lval(d); - /* This only checks for a fractional part as if doesn't fit it already throws a TypeError - * Manually check to get correct warning text mentioning string origin - * Check arg_num is not (uint32_t)-1, as otherwise its called by - * zend_verify_weak_scalar_type_hint_no_sideeffect() */ - if (UNEXPECTED(!zend_is_long_compatible(d, lval) && arg_num != (uint32_t)-1)) { - zend_incompatible_string_to_long_error(Z_STR_P(arg)); + /* This only checks for a fractional part as if doesn't fit it already throws a TypeError */ + if (UNEXPECTED(!zend_is_long_compatible(d, lval))) { + /* Check arg_num is not (uint32_t)-1, as otherwise its called by + * zend_verify_weak_scalar_type_hint_no_sideeffect() */ + if (arg_num != (uint32_t)-1) { + zend_incompatible_string_to_long_error(Z_STR_P(arg)); + } if (UNEXPECTED(EG(exception))) { return 0; } diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 27f704a87c3fd..e4593a2531809 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -775,7 +775,8 @@ static bool zend_verify_weak_scalar_type_hint_no_sideeffect(uint32_t type_mask, double dval; bool bval; - /* Pass (uint32_t)-1 as arg_num to indicate to ZPP not to emit any deprecation notice */ + /* Pass (uint32_t)-1 as arg_num to indicate to ZPP not to emit any deprecation notice, + * this is needed because the version with side effects also uses 0 (e.g. for types properties) */ if ((type_mask & MAY_BE_LONG) && zend_parse_arg_long_weak(arg, &lval, (uint32_t)-1)) { return 1; } From 37e04d23ca74d85130d946f2df95b5cde190c5e4 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Tue, 20 Apr 2021 17:37:59 +0100 Subject: [PATCH 30/61] Fix Win test --- ext/standard/tests/file/ftruncate_variation3-win32.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/standard/tests/file/ftruncate_variation3-win32.phpt b/ext/standard/tests/file/ftruncate_variation3-win32.phpt index 60e31fefe1332..33d7a7d7cdd09 100644 --- a/ext/standard/tests/file/ftruncate_variation3-win32.phpt +++ b/ext/standard/tests/file/ftruncate_variation3-win32.phpt @@ -47,7 +47,7 @@ foreach($file_content_types as $file_content_type) { echo "-- Testing ftruncate(): truncate file to half of its current size --\n"; /* truncate it to half of its current size */ - $new_size = filesize($filename)/2; + $new_size = (int)filesize($filename)/2; var_dump( filesize($filename) ); // current filesize var_dump( ftell($file_handle) ); var_dump( ftruncate($file_handle, $new_size) ); // truncate it From 61e3f9464fede826c063a1c7d4e782360c9fbf4a Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Mon, 26 Apr 2021 02:53:22 +0100 Subject: [PATCH 31/61] Bit op and mod may throw --- ext/opcache/jit/zend_jit_x86.dasc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index 2af671e1356e3..93d69e1b33485 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -13896,7 +13896,7 @@ static int zend_jit_assign_obj_op(dasm_State **Dst, IS_CV, opline->op1, var_addr, var_info, NULL, (opline+1)->op1_type, (opline+1)->op1, val_addr, val_info, val_range, - 0, var_addr, var_def_info, var_info, 0)) { + 0, var_addr, var_def_info, var_info, /* may throw */ 1)) { return 0; } break; From 8854e7415e729875615d427eea25c56c57207ca7 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Mon, 26 Apr 2021 03:27:29 +0100 Subject: [PATCH 32/61] Fix inference of zend_may_throw --- Zend/Optimizer/zend_inference.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/Zend/Optimizer/zend_inference.c b/Zend/Optimizer/zend_inference.c index c582a8763ad98..2a7d0c4639e14 100644 --- a/Zend/Optimizer/zend_inference.c +++ b/Zend/Optimizer/zend_inference.c @@ -4481,7 +4481,6 @@ ZEND_API int zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op, return (t1 & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) || (t2 & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)); case ZEND_DIV: - case ZEND_MOD: if (!OP2_HAS_RANGE() || (OP2_MIN_RANGE() <= 0 && OP2_MAX_RANGE() >= 0)) { /* Division by zero */ @@ -4493,10 +4492,18 @@ ZEND_API int zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op, case ZEND_POW: return (t1 & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) || (t2 & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)); + /* Ops may throw if not an integer */ + case ZEND_MOD: + if (!OP2_HAS_RANGE() || + (OP2_MIN_RANGE() <= 0 && OP2_MAX_RANGE() >= 0)) { + /* Division by zero */ + return 1; + } + ZEND_FALLTHROUGH; case ZEND_SL: case ZEND_SR: - return (t1 & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) || - (t2 & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) || + return (t1 & (MAY_BE_STRING|MAY_BE_DOUBLE|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) || + (t2 & (MAY_BE_STRING|MAY_BE_DOUBLE|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) || !OP2_HAS_RANGE() || OP2_MIN_RANGE() < 0; case ZEND_CONCAT: @@ -4510,10 +4517,10 @@ ZEND_API int zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op, && (t2 & MAY_BE_ANY) == MAY_BE_STRING) { return 0; } - return (t1 & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) || - (t2 & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)); + return (t1 & (MAY_BE_STRING|MAY_BE_DOUBLE|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) || + (t2 & (MAY_BE_STRING|MAY_BE_DOUBLE|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)); case ZEND_BW_NOT: - return (t1 & (MAY_BE_NULL|MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)); + return (t1 & (MAY_BE_NULL|MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_DOUBLE|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)); case ZEND_PRE_INC: case ZEND_POST_INC: case ZEND_PRE_DEC: From 25e46f182ae04df1b4ec5ec5be0e755c197e5ccf Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Mon, 26 Apr 2021 01:46:53 +0100 Subject: [PATCH 33/61] Attempt to fix JIT --- ext/opcache/jit/zend_jit.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c index e7226aae6dcdd..7d866e569e0fa 100644 --- a/ext/opcache/jit/zend_jit.c +++ b/ext/opcache/jit/zend_jit.c @@ -2396,7 +2396,8 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op } if (!(op1_info & MAY_BE_LONG) || !(op2_info & MAY_BE_LONG)) { - break; + /* Might emit deprecation notices */ + goto jit_failure; } res_addr = RES_REG_ADDR(); if (Z_MODE(res_addr) != IS_REG @@ -2562,7 +2563,8 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op || opline->extended_value == ZEND_MOD) { if (!(op1_info & MAY_BE_LONG) || !(op2_info & MAY_BE_LONG)) { - break; + /* Might emit deprecation notices */ + goto jit_failure; } } else if (opline->extended_value == ZEND_CONCAT) { if (!(op1_info & MAY_BE_STRING) From f7391782d2d72b21e50d69b3fa31b0a9b516859a Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Mon, 26 Apr 2021 02:53:28 +0100 Subject: [PATCH 34/61] Revert "Attempt to fix JIT" This reverts commit fecbf45f0d6d33d7fb218945accb876941fefa41. --- ext/opcache/jit/zend_jit.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c index 7d866e569e0fa..e7226aae6dcdd 100644 --- a/ext/opcache/jit/zend_jit.c +++ b/ext/opcache/jit/zend_jit.c @@ -2396,8 +2396,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op } if (!(op1_info & MAY_BE_LONG) || !(op2_info & MAY_BE_LONG)) { - /* Might emit deprecation notices */ - goto jit_failure; + break; } res_addr = RES_REG_ADDR(); if (Z_MODE(res_addr) != IS_REG @@ -2563,8 +2562,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op || opline->extended_value == ZEND_MOD) { if (!(op1_info & MAY_BE_LONG) || !(op2_info & MAY_BE_LONG)) { - /* Might emit deprecation notices */ - goto jit_failure; + break; } } else if (opline->extended_value == ZEND_CONCAT) { if (!(op1_info & MAY_BE_STRING) From af1689424a5cbbb30991a2726a2880175c7fa76b Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Wed, 28 Apr 2021 18:41:03 +0100 Subject: [PATCH 35/61] Make printf() test not spit random bytes to debug on 32bits --- ext/standard/tests/strings/printf.phpt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/standard/tests/strings/printf.phpt b/ext/standard/tests/strings/printf.phpt index 8df380576a643..b53eea6760d6a 100644 --- a/ext/standard/tests/strings/printf.phpt +++ b/ext/standard/tests/strings/printf.phpt @@ -19,7 +19,7 @@ $float_numbers = array( 0, 1, -1, 0.32, -0.32, 3.4. -3.4, 2.54, -2.54, 1.2345 $int_variation = array( "%d", "%-d", "%+d", "%7.2d", "%-7.2d", "%07.2d", "%-07.2d", "%'#7.2d" ); $int_numbers = array( 0, 1, -1, 23333333, -23333333, "1234" ); -$char_variation = array( 'a', "a", 67, -67, 99 ); +$char_variation = array( 'a', "a", 67, -150 /* j */, 99 ); $string_variation = array( "%5s", "%-5s", "%05s", "%'#5s" ); $strings = array( NULL, "abc", 'aaa' ); @@ -101,7 +101,7 @@ print_r($int_numbers); } -/* Chararter type variations */ +/* Character type variations */ echo "\n\n*** Output for char type ***\n"; echo "\n Input Characters variation array is:\n"; print_r($char_variation); @@ -473,7 +473,7 @@ Array %0 %0 C -� +j c *** Output for scientific type *** From 02fbb29665404b6a770fd6d3578b0ed9518d0e2e Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Wed, 28 Apr 2021 10:57:30 +0100 Subject: [PATCH 36/61] Update test after fix in core --- ..._float_does_not_fit_zend_long_strings.phpt | 18 ++++++++++++ ...es_not_fit_zend_long_write_variation1.phpt | 28 ------------------- ...es_not_fit_zend_long_write_variation2.phpt | 28 ------------------- 3 files changed, 18 insertions(+), 56 deletions(-) delete mode 100644 Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_write_variation1.phpt delete mode 100644 Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_write_variation2.phpt diff --git a/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_strings.phpt b/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_strings.phpt index 8b46ab469235f..2590b8a7d4e6f 100644 --- a/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_strings.phpt +++ b/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_strings.phpt @@ -55,6 +55,20 @@ try { echo 'TypeError', \PHP_EOL; } +try { + $string[(string) 10e120] = 'E'; + var_dump($string); +} catch (\TypeError) { + echo 'TypeError', \PHP_EOL; +} +var_dump($string); +try { + $string[$string_float] = 'E'; +} catch (\TypeError) { + echo 'TypeError', \PHP_EOL; +} +var_dump($string); + ?> --EXPECTF-- int(0) @@ -85,3 +99,7 @@ Float variable Warning: String offset cast occurred in %s on line %d string(34) "Eere is some text for good measure" +TypeError +string(34) "Here is some text for good measure" +TypeError +string(34) "Here is some text for good measure" diff --git a/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_write_variation1.phpt b/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_write_variation1.phpt deleted file mode 100644 index 1073d15d22a83..0000000000000 --- a/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_write_variation1.phpt +++ /dev/null @@ -1,28 +0,0 @@ ---TEST-- -Implicit float to int conversions when float too large should warn, array variant ---FILE-- - ---EXPECTF-- -Float casted to string compile - -Warning: Uncaught TypeError: Cannot access offset of type string on string in %s:%d -Stack trace: -#0 {main} - thrown in %s on line %d - -Fatal error: Allowed memory size of %d bytes exhausted %S(tried to allocate %d bytes) in %s on line %d diff --git a/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_write_variation2.phpt b/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_write_variation2.phpt deleted file mode 100644 index faa69708531af..0000000000000 --- a/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_write_variation2.phpt +++ /dev/null @@ -1,28 +0,0 @@ ---TEST-- -Implicit float to int conversions when float too large should warn, string offset variant ---FILE-- - ---EXPECTF-- -Float string variable - -Warning: Uncaught TypeError: Cannot access offset of type string on string in %s:%d -Stack trace: -#0 {main} - thrown in %s on line %d - -Fatal error: Allowed memory size of %d bytes exhausted %S(tried to allocate %d bytes) in %s on line %d From 017bb20c9a5e24efe5c213a63e6e12bda03610c2 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Wed, 28 Apr 2021 12:07:36 +0100 Subject: [PATCH 37/61] Fix more 32bits tests Make some vsprintf not sensible to whitespace output --- Zend/tests/bug46701.phpt | 11 +- .../explicit_casts_should_not_warn.phpt | 4 + .../explicit_casts_should_not_warn_32bit.phpt | 38 ++ ...g_float_does_not_fit_zend_long_arrays.phpt | 4 +- ..._float_does_not_fit_zend_long_strings.phpt | 4 + ..._does_not_fit_zend_long_strings_32bit.phpt | 109 +++++ .../scalar_return_basic.phpt | 2 + .../scalar_return_basic_64bit.phpt | 2 +- ext/openssl/tests/openssl_decrypt_basic.phpt | 2 +- ext/session/tests/session_encode_error2.phpt | 173 +------- ext/soap/tests/bug70211.phpt | 4 + .../tests/array/array_keys_variation_002.phpt | 28 -- .../array/array_keys_variation_002_64bit.phpt | 56 --- ext/standard/tests/math/bug30695.phpt | 23 +- ext/standard/tests/strings/bug78612.phpt | 4 +- ext/standard/tests/strings/printf.phpt | 387 +++++++++--------- .../tests/strings/vprintf_variation12.phpt | 69 ++-- .../strings/vprintf_variation12_64bit.phpt | 112 ++--- .../tests/strings/vprintf_variation14.phpt | 69 ++-- .../strings/vprintf_variation14_64bit.phpt | 112 ++--- .../tests/strings/vprintf_variation15.phpt | 51 +-- .../strings/vprintf_variation15_64bit.phpt | 47 +-- .../tests/strings/vprintf_variation16.phpt | 72 ++-- .../strings/vprintf_variation16_64bit.phpt | 103 ++--- .../tests/strings/vprintf_variation4.phpt | 59 +-- .../strings/vprintf_variation4_64bit.phpt | 131 ------ tests/lang/bug27354.phpt | 18 +- 27 files changed, 675 insertions(+), 1019 deletions(-) create mode 100644 Zend/tests/float_to_int/explicit_casts_should_not_warn_32bit.phpt create mode 100644 Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_strings_32bit.phpt delete mode 100644 ext/standard/tests/array/array_keys_variation_002_64bit.phpt delete mode 100644 ext/standard/tests/strings/vprintf_variation4_64bit.phpt diff --git a/Zend/tests/bug46701.phpt b/Zend/tests/bug46701.phpt index 5da5a9afc75cc..1003c0dc960ae 100644 --- a/Zend/tests/bug46701.phpt +++ b/Zend/tests/bug46701.phpt @@ -26,7 +26,12 @@ class foo { new foo; ?> ---EXPECT-- +--EXPECTF-- +Deprecated: Implicit conversion from non-compatible float 3428599296 to int in %s on line %d + +Deprecated: Implicit conversion from non-compatible float 3459455488 to int in %s on line %d + +Deprecated: Implicit conversion from non-compatible float 3459616768 to int in %s on line %d array(3) { [-866368000]=> int(1) @@ -35,7 +40,11 @@ array(3) { [-835350528]=> int(3) } + +Deprecated: Implicit conversion from non-compatible float 3459455488 to int in %s on line %d int(2) + +Deprecated: Implicit conversion from non-compatible float 3459616768 to int in %s on line %d array(1) { [-835350528]=> int(3) diff --git a/Zend/tests/float_to_int/explicit_casts_should_not_warn.phpt b/Zend/tests/float_to_int/explicit_casts_should_not_warn.phpt index 3136958a4b9d7..71c68e57574bf 100644 --- a/Zend/tests/float_to_int/explicit_casts_should_not_warn.phpt +++ b/Zend/tests/float_to_int/explicit_casts_should_not_warn.phpt @@ -1,5 +1,9 @@ --TEST-- Explicit (int) cast must not warn +--SKIPIF-- + --FILE-- +--FILE-- + +--EXPECT-- +int(3) +int(3) +int(0) +int(0) +int(0) +int(3) +int(3) +int(2147483647) +int(2147483647) +int(0) diff --git a/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_arrays.phpt b/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_arrays.phpt index 4e961a9d45632..e1c86e5f44ccb 100644 --- a/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_arrays.phpt +++ b/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_arrays.phpt @@ -7,7 +7,7 @@ $float = 10e120; $string_float = (string) $float; var_dump((int) $float); -var_dump((int) $string_float); +var_dump((int) $string_float === PHP_INT_MAX); $arrayConstant = [10e120 => 'Large float', (string) 10e120 => 'String large float']; $arrayDynamic = [$float => 'Large float', $string_float => 'String large float']; @@ -24,7 +24,7 @@ var_dump($array[$string_float]); ?> --EXPECTF-- int(0) -int(9223372036854775807) +bool(true) Deprecated: Implicit conversion from non-compatible float 1.0E+121 to int in %s on line %d diff --git a/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_strings.phpt b/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_strings.phpt index 2590b8a7d4e6f..e298783fb86e5 100644 --- a/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_strings.phpt +++ b/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_strings.phpt @@ -1,5 +1,9 @@ --TEST-- Implicit float to int conversions when float too large should warn, string offset variant +--SKIPIF-- + --FILE-- +--FILE-- + +--EXPECTF-- +int(0) +int(2147483647) +Attempt to read +Float + +Warning: String offset cast occurred in %s on line %d +string(1) "H" +Float variable + +Warning: String offset cast occurred in %s on line %d +string(1) "H" +Float casted to string compile + +Warning: Uninitialized string offset 2147483647 in %s on line %d +TypeError +Float string variable + +Warning: Uninitialized string offset 2147483647 in %s on line %d +TypeError +Attempt to assign +Float + +Warning: String offset cast occurred in %s on line %d +string(34) "Eere is some text for good measure" +Float variable + +Warning: String offset cast occurred in %s on line %d +string(34) "Eere is some text for good measure" +TypeError +string(34) "Here is some text for good measure" +TypeError +string(34) "Here is some text for good measure" diff --git a/Zend/tests/type_declarations/scalar_return_basic.phpt b/Zend/tests/type_declarations/scalar_return_basic.phpt index deb4289f25445..175fadb38f16d 100644 --- a/Zend/tests/type_declarations/scalar_return_basic.phpt +++ b/Zend/tests/type_declarations/scalar_return_basic.phpt @@ -8,6 +8,7 @@ Return scalar type basics $errnames = [ E_NOTICE => 'E_NOTICE', E_WARNING => 'E_WARNING', + E_DEPRECATED => 'E_DEPRECATED', ]; set_error_handler(function (int $errno, string $errmsg, string $file, int $line) use ($errnames) { echo "$errnames[$errno]: $errmsg on line $line\n"; @@ -70,6 +71,7 @@ int(1) *** Trying float(1) int(1) *** Trying float(1.5) +E_DEPRECATED: Implicit conversion from non-compatible float 1.5 to int on line %d int(1) *** Trying string(2) "1a" *** Caught {closure}(): Return value must be of type int, string returned in %s on line %d diff --git a/Zend/tests/type_declarations/scalar_return_basic_64bit.phpt b/Zend/tests/type_declarations/scalar_return_basic_64bit.phpt index 1604a8e23f642..10e0390ce88ff 100644 --- a/Zend/tests/type_declarations/scalar_return_basic_64bit.phpt +++ b/Zend/tests/type_declarations/scalar_return_basic_64bit.phpt @@ -71,7 +71,7 @@ int(1) *** Trying float(1) int(1) *** Trying float(1.5) -E_DEPRECATED: Implicit conversion from non-compatible float 1.5 to int on line 14 +E_DEPRECATED: Implicit conversion from non-compatible float 1.5 to int on line %d int(1) *** Trying string(2) "1a" *** Caught {closure}(): Return value must be of type int, string returned in %s on line %d diff --git a/ext/openssl/tests/openssl_decrypt_basic.phpt b/ext/openssl/tests/openssl_decrypt_basic.phpt index 4175e703d2bb8..4c50aae3653fe 100644 --- a/ext/openssl/tests/openssl_decrypt_basic.phpt +++ b/ext/openssl/tests/openssl_decrypt_basic.phpt @@ -10,7 +10,7 @@ $password = "openssl"; $ivlen = openssl_cipher_iv_length($method); $iv = ''; -srand(time() + ((microtime(true) * 1000000) % 1000000)); +srand(time() + ((int)(microtime(true) * 1000000) % 1000000)); while(strlen($iv) < $ivlen) $iv .= chr(rand(0,255)); $encrypted = openssl_encrypt($data, $method, $password, 0, $iv); diff --git a/ext/session/tests/session_encode_error2.phpt b/ext/session/tests/session_encode_error2.phpt index 426053df8a665..883b814b74e20 100644 --- a/ext/session/tests/session_encode_error2.phpt +++ b/ext/session/tests/session_encode_error2.phpt @@ -9,23 +9,6 @@ ob_start(); echo "*** Testing session_encode() : error functionality ***\n"; -// Get an unset variable -$unset_var = 10; -unset($unset_var); - -class classA -{ - public function __toString() { - return "Hello World!"; - } -} - -$heredoc = << @@ -125,132 +75,11 @@ bool(true) -- Iteration 5 -- bool(true) - -Deprecated: Implicit conversion from non-compatible float 10.5 to int in %s on line %d - -Warning: session_encode(): Skipping numeric key 10 in %s on line %d -bool(false) -bool(true) - --- Iteration 6 -- -bool(true) - -Deprecated: Implicit conversion from non-compatible float -10.5 to int in %s on line %d - -Warning: session_encode(): Skipping numeric key -10 in %s on line %d -bool(false) -bool(true) - --- Iteration 7 -- -bool(true) - -Warning: session_encode(): Skipping numeric key %s in %s on line %d -bool(false) -bool(true) - --- Iteration 8 -- -bool(true) - -Deprecated: Implicit conversion from non-compatible float 1.23456789E-9 to int in %s on line %d - -Warning: session_encode(): Skipping numeric key 0 in %s on line %d -bool(false) -bool(true) - --- Iteration 9 -- -bool(true) - -Deprecated: Implicit conversion from non-compatible float 0.5 to int in %s on line %d - -Warning: session_encode(): Skipping numeric key 0 in %s on line %d -bool(false) -bool(true) - --- Iteration 10 -- -bool(true) -string(21) "|s:12:"Hello World!";" -bool(true) - --- Iteration 11 -- -bool(true) -string(21) "|s:12:"Hello World!";" -bool(true) - --- Iteration 12 -- -bool(true) - -Warning: session_encode(): Skipping numeric key 1 in %s on line %d -bool(false) -bool(true) - --- Iteration 13 -- -bool(true) - -Warning: session_encode(): Skipping numeric key 0 in %s on line %d -bool(false) -bool(true) - --- Iteration 14 -- -bool(true) - -Warning: session_encode(): Skipping numeric key 1 in %s on line %d -bool(false) -bool(true) - --- Iteration 15 -- -bool(true) - -Warning: session_encode(): Skipping numeric key 0 in %s on line %d -bool(false) -bool(true) - --- Iteration 16 -- -bool(true) -string(21) "|s:12:"Hello World!";" -bool(true) - --- Iteration 17 -- -bool(true) string(21) "|s:12:"Hello World!";" bool(true) --- Iteration 18 -- -bool(true) -string(28) "Nothing|s:12:"Hello World!";" -bool(true) - --- Iteration 19 -- +-- Iteration 6 -- bool(true) string(28) "Nothing|s:12:"Hello World!";" bool(true) - --- Iteration 20 -- -bool(true) -string(33) "Hello World!|s:12:"Hello World!";" -bool(true) - --- Iteration 21 -- -bool(true) -Illegal offset type -bool(false) -bool(true) - --- Iteration 22 -- -bool(true) -string(21) "|s:12:"Hello World!";" -bool(true) - --- Iteration 23 -- -bool(true) -string(21) "|s:12:"Hello World!";" -bool(true) - --- Iteration 24 -- -bool(true) - -Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d - -Warning: session_encode(): Skipping numeric key %d in %s on line %d -bool(false) -bool(true) Done diff --git a/ext/soap/tests/bug70211.phpt b/ext/soap/tests/bug70211.phpt index d17c43a7fbd6b..1e722cf94a070 100644 --- a/ext/soap/tests/bug70211.phpt +++ b/ext/soap/tests/bug70211.phpt @@ -2,6 +2,10 @@ Bug #70211 (php 7 ZEND_HASH_IF_FULL_DO_RESIZE use after free) --EXTENSIONS-- soap +--SKIPIF-- + --FILE-- --FILE-- 1, - 2147483648 => 2, - -2147483647 => 3, - -2147483648 => 4, - -2147483649 => 5, - -0 => 6, - 0 => 7 -); -var_dump(array_keys($arr_range)); - echo "\n*** Testing array_keys() on an array created on the fly ***\n"; var_dump(array_keys(array("a" => 1, "b" => 2, "c" => 3))); var_dump(array_keys(array())); // null array @@ -26,18 +10,6 @@ var_dump(array_keys(array())); // null array echo "Done\n"; ?> --EXPECT-- -*** Testing array_keys() on range of values *** -array(4) { - [0]=> - int(2147483647) - [1]=> - int(-2147483648) - [2]=> - int(-2147483647) - [3]=> - int(0) -} - *** Testing array_keys() on an array created on the fly *** array(3) { [0]=> diff --git a/ext/standard/tests/array/array_keys_variation_002_64bit.phpt b/ext/standard/tests/array/array_keys_variation_002_64bit.phpt deleted file mode 100644 index dd35a77642b34..0000000000000 --- a/ext/standard/tests/array/array_keys_variation_002_64bit.phpt +++ /dev/null @@ -1,56 +0,0 @@ ---TEST-- -Test array_keys() function (variation - 2) ---SKIPIF-- - ---FILE-- - 1, - 2147483648 => 2, - -2147483647 => 3, - -2147483648 => 4, - -2147483649 => 5, - -0 => 6, - 0 => 7 -); -var_dump(array_keys($arr_range)); - -echo "\n*** Testing array_keys() on an array created on the fly ***\n"; -var_dump(array_keys(array("a" => 1, "b" => 2, "c" => 3))); -var_dump(array_keys(array())); // null array - -echo "Done\n"; -?> ---EXPECT-- -*** Testing array_keys() on range of values *** -array(6) { - [0]=> - int(2147483647) - [1]=> - int(2147483648) - [2]=> - int(-2147483647) - [3]=> - int(-2147483648) - [4]=> - int(-2147483649) - [5]=> - int(0) -} - -*** Testing array_keys() on an array created on the fly *** -array(3) { - [0]=> - string(1) "a" - [1]=> - string(1) "b" - [2]=> - string(1) "c" -} -array(0) { -} -Done diff --git a/ext/standard/tests/math/bug30695.phpt b/ext/standard/tests/math/bug30695.phpt index a0034892db405..f24bf6111c28e 100644 --- a/ext/standard/tests/math/bug30695.phpt +++ b/ext/standard/tests/math/bug30695.phpt @@ -1,5 +1,9 @@ --TEST-- Bug #30695 (32 bit issues) +--SKIPIF-- + --FILE-- > 12) & 0x3f)) . chr(0x80 | (($char_code >> 6) & 0x3f)) . chr(0x80 | ($char_code & 0x3f)) ); + break; default: // 31 bit $char = ( chr(0xfc | (($char_code >> 30) & 0x01)) . chr(0x80 | (($char_code >> 24) & 0x3f)) . @@ -46,8 +52,23 @@ Bug #30695 (32 bit issues) echo "\n", toUTF8(65), "\n", toUTF8(233), "\n", toUTF8(1252), "\n", toUTF8(20095), "\n"; ?> ---EXPECT-- +--EXPECTF-- +Deprecated: Implicit conversion from non-compatible float 4294967168 to int in %s on line %d A + +Deprecated: Implicit conversion from non-compatible float 4294967168 to int in %s on line %d + +Deprecated: Implicit conversion from non-compatible float 4294965248 to int in %s on line %d é + +Deprecated: Implicit conversion from non-compatible float 4294967168 to int in %s on line %d + +Deprecated: Implicit conversion from non-compatible float 4294965248 to int in %s on line %d Ó¤ + +Deprecated: Implicit conversion from non-compatible float 4294967168 to int in %s on line %d + +Deprecated: Implicit conversion from non-compatible float 4294965248 to int in %s on line %d + +Deprecated: Implicit conversion from non-compatible float 4294901760 to int in %s on line %d 乿 diff --git a/ext/standard/tests/strings/bug78612.phpt b/ext/standard/tests/strings/bug78612.phpt index 13fb32405218e..62bbbf03180cc 100644 --- a/ext/standard/tests/strings/bug78612.phpt +++ b/ext/standard/tests/strings/bug78612.phpt @@ -3,8 +3,8 @@ Bug #78612 (strtr leaks memory when integer keys are used and the subject string --FILE-- 2147483647) { - die("skip 32bit test only"); -} +if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); ?> --FILE-- --EXPECTF-- *** Output for zero argument *** -printf() expects at least %d argument, %d given +printf() expects at least 1 argument, 0 given *** Output for insufficient number of arguments *** Error found: 5 arguments are required, 3 given @@ -259,100 +257,100 @@ Array Float Iteration 1 -0.000000 -1.000000 --1.000000 -0.320000 --0.320000 -3.400000 -2.540000 --2.540000 -1234567%d.000000 --1234567%d.000000 +'0.000000' +'1.000000' +'-1.000000' +'0.320000' +'-0.320000' +'3.400000' +'2.540000' +'-2.540000' +'1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000' +'-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000' Float Iteration 2 -0.000000 -1.000000 --1.000000 -0.320000 --0.320000 -3.400000 -2.540000 --2.540000 -1234567%d.000000 --1234567%d.000000 +'0.000000' +'1.000000' +'-1.000000' +'0.320000' +'-0.320000' +'3.400000' +'2.540000' +'-2.540000' +'1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000' +'-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000' Float Iteration 3 -+0.000000 -+1.000000 --1.000000 -+0.320000 --0.320000 -+3.400000 -+2.540000 --2.540000 -+1234567%d.000000 --1234567%d.000000 +'+0.000000' +'+1.000000' +'-1.000000' +'+0.320000' +'-0.320000' +'+3.400000' +'+2.540000' +'-2.540000' +'+1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000' +'-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000' Float Iteration 4 - 0.00 - 1.00 - -1.00 - 0.32 - -0.32 - 3.40 - 2.54 - -2.54 -1234567%d.00 --1234567%d.00 +' 0.00' +' 1.00' +' -1.00' +' 0.32' +' -0.32' +' 3.40' +' 2.54' +' -2.54' +'1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' +'-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' Float Iteration 5 -0.00 -1.00 --1.00 -0.32 --0.32 -3.40 -2.54 --2.54 -1234567%d.00 --1234567%d.00 +'0.00 ' +'1.00 ' +'-1.00 ' +'0.32 ' +'-0.32 ' +'3.40 ' +'2.54 ' +'-2.54 ' +'1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' +'-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' Float Iteration 6 -0000.00 -0001.00 --001.00 -0000.32 --000.32 -0003.40 -0002.54 --002.54 -1234567%d.00 --1234567%d.00 +'0000.00' +'0001.00' +'-001.00' +'0000.32' +'-000.32' +'0003.40' +'0002.54' +'-002.54' +'1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' +'-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' Float Iteration 7 -0.00000 -1.00000 --1.0000 -0.32000 --0.3200 -3.40000 -2.54000 --2.5400 -1234567%d.00 --1234567%d.00 +'0.00000' +'1.00000' +'-1.0000' +'0.32000' +'-0.3200' +'3.40000' +'2.54000' +'-2.5400' +'1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' +'-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' Float Iteration 8 -###0.00 -###1.00 -##-1.00 -###0.32 -##-0.32 -###3.40 -###2.54 -##-2.54 -1234567%d.00 --1234567%d.00 +'###0.00' +'###1.00' +'##-1.00' +'###0.32' +'##-0.32' +'###3.40' +'###2.54' +'##-2.54' +'1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' +'-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' *** Output for integer type *** @@ -362,77 +360,75 @@ Array [0] => 0 [1] => 1 [2] => -1 - [3] => 2.7 - [4] => -2.7 - [5] => 23333333 - [6] => -23333333 - [7] => 1234 + [3] => 23333333 + [4] => -23333333 + [5] => 1234 ) Integer Iteration 1 -0 -1 --1 -23333333 --23333333 -1234 +'0' +'1' +'-1' +'23333333' +'-23333333' +'1234' Integer Iteration 2 -0 -1 --1 -23333333 --23333333 -1234 +'0' +'1' +'-1' +'23333333' +'-23333333' +'1234' Integer Iteration 3 -+0 -+1 --1 -+23333333 --23333333 -+1234 +'+0' +'+1' +'-1' +'+23333333' +'-23333333' +'+1234' Integer Iteration 4 - 0 - 1 - -1 -23333333 --23333333 - 1234 +' 0' +' 1' +' -1' +'23333333' +'-23333333' +' 1234' Integer Iteration 5 -0 -1 --1 -23333333 --23333333 -1234 +'0 ' +'1 ' +'-1 ' +'23333333' +'-23333333' +'1234 ' Integer Iteration 6 -0000000 -0000001 --000001 -23333333 --23333333 -0001234 +'0000000' +'0000001' +'-000001' +'23333333' +'-23333333' +'0001234' Integer Iteration 7 -0 -1 --1 -23333333 --23333333 -1234 +'0 ' +'1 ' +'-1 ' +'23333333' +'-23333333' +'1234 ' Integer Iteration 8 -######0 -######1 -#####-1 -23333333 --23333333 -###1234 +'######0' +'######1' +'#####-1' +'23333333' +'-23333333' +'###1234' *** Output for binary type *** @@ -442,18 +438,14 @@ Array [0] => 0 [1] => 1 [2] => -1 - [3] => 2.7 - [4] => -2.7 - [5] => 23333333 - [6] => -23333333 - [7] => 1234 + [3] => 23333333 + [4] => -23333333 + [5] => 1234 ) 0 1 11111111111111111111111111111111 -10 -11111111111111111111111111111110 1011001000000100111010101 11111110100110111111011000101011 10011010010 @@ -466,7 +458,7 @@ Array [0] => a [1] => a [2] => 67 - [3] => -67 + [3] => -150 [4] => 99 ) @@ -484,18 +476,14 @@ Array [0] => 0 [1] => 1 [2] => -1 - [3] => 2.7 - [4] => -2.7 - [5] => 23333333 - [6] => -23333333 - [7] => 1234 + [3] => 23333333 + [4] => -23333333 + [5] => 1234 ) 0.000000e+0 1.000000e+0 -1.000000e+0 -2.700000e+0 --2.700000e+0 2.333333e+7 -2.333333e+7 1.234000e+3 @@ -508,18 +496,14 @@ Array [0] => 0 [1] => 1 [2] => -1 - [3] => 2.7 - [4] => -2.7 - [5] => 23333333 - [6] => -23333333 - [7] => 1234 + [3] => 23333333 + [4] => -23333333 + [5] => 1234 ) 0 1 4294967295 -2 -4294967294 23333333 4271633963 1234 @@ -532,18 +516,14 @@ Array [0] => 0 [1] => 1 [2] => -1 - [3] => 2.7 - [4] => -2.7 - [5] => 23333333 - [6] => -23333333 - [7] => 1234 + [3] => 23333333 + [4] => -23333333 + [5] => 1234 ) 0 1 37777777777 -2 -37777777776 131004725 37646773053 2322 @@ -556,18 +536,14 @@ Array [0] => 0 [1] => 1 [2] => -1 - [3] => 2.7 - [4] => -2.7 - [5] => 23333333 - [6] => -23333333 - [7] => 1234 + [3] => 23333333 + [4] => -23333333 + [5] => 1234 ) 0 1 ffffffff -2 -fffffffe 16409d5 fe9bf62b 4d2 @@ -575,34 +551,39 @@ fe9bf62b *** Output for string type *** Input Strings format variation array is: -Array -( - [0] => %5s - [1] => %-5s - [2] => %r%%r05s - [3] => %'#5s -) +array(4) { + [0]=> + string(5) "'%5s'" + [1]=> + string(6) "'%-5s'" + [2]=> + string(6) "'%05s'" + [3]=> + string(7) "'%'#5s'" +} Input strings variation array is: -Array -( - [0] => - [1] => abc - [2] => aaa -) - - - abc - aaa +array(3) { + [0]=> + NULL + [1]=> + string(3) "abc" + [2]=> + string(3) "aaa" +} -abc -aaa -00000 -00abc -00aaa -##### -##abc -##aaa +' ' +' abc' +' aaa' +' ' +'abc ' +'aaa ' +'00000' +'00abc' +'00aaa' +'#####' +'##abc' +'##aaa' *** Output for '%g' type *** diff --git a/ext/standard/tests/strings/vprintf_variation12.phpt b/ext/standard/tests/strings/vprintf_variation12.phpt index b369cea54d16b..9c49a3d690a76 100644 --- a/ext/standard/tests/strings/vprintf_variation12.phpt +++ b/ext/standard/tests/strings/vprintf_variation12.phpt @@ -15,11 +15,11 @@ echo "*** Testing vprintf() : octal formats and non-octal values ***\n"; // defining array of octal formats $formats = - '%o %+o %-o - %lo %4o %-4o - %10.4o %-10.4o %.4o - %\'#2o %\'2o %\'$2o %\'_2o - %3$o %4$o %1$o %2$o'; + '"%o" "%+o" "%-o" + "%lo" "%4o" "%-4o" + "%10.4o" "%-10.4o" "%.4o" + "%\'#2o" "%\'2o" "%\'$2o" "%\'_2o" + "%3$o" "%4$o" "%1$o" "%2$o"'; // Arrays of non octal values for the format defined in $format. // Each sub array contains non octal values which correspond to each format in $format @@ -58,11 +58,12 @@ $args_array = array( // and with non-octal values from the above $args_array array $counter = 1; foreach($args_array as $args) { - echo "\n-- Iteration $counter --\n"; - $result = vprintf($formats, $args); - echo "\n"; - var_dump($result); - $counter++; + echo "\n-- Iteration $counter --\n"; + ob_start(); + $bytes = vprintf($formats, $args); + var_dump(ob_get_clean()); + var_dump($bytes); + $counter++; } ?> @@ -70,33 +71,33 @@ foreach($args_array as $args) { *** Testing vprintf() : octal formats and non-octal values *** -- Iteration 1 -- -2 37777777776 2 - 361100 37720715133 57062645 - - 57060664 4475347 37721631371 37720717336 - 2 361100 2 37777777776 -int(142) +string(180) ""2" "37777777776" "2" + "361100" "37720715133" "57062645" + " " " " "" + "57060664" "4475347" "37721631371" "37720717336" + "2" "361100" "2" "37777777776"" +int(180) -- Iteration 2 -- -0 0 0 - 173 37777777605 173 - - 2322 0 $0 _0 - 0 173 0 0 -int(84) +string(122) ""0" "0" "0" + "173" "37777777605" "173 " + " " " " "" + "2322" "0" "$0" "_0" + "0" "173" "0" "0"" +int(122) -- Iteration 3 -- -1 1 1 - 1 1 1 - - #1 1 $1 _1 - 1 1 1 1 -int(71) +string(109) ""1" "1" "1" + "1" " 1" "1 " + " " " " "" + "#1" "1" "$1" "_1" + "1" "1" "1" "1"" +int(109) -- Iteration 4 -- -1 1 0 - 1 0 1 - - #0 1 $1 _0 - 0 1 1 1 -int(71) +string(109) ""1" "1" "0" + "1" " 0" "1 " + " " " " "" + "#0" "1" "$1" "_0" + "0" "1" "1" "1"" +int(109) diff --git a/ext/standard/tests/strings/vprintf_variation12_64bit.phpt b/ext/standard/tests/strings/vprintf_variation12_64bit.phpt index c5cab9b41760f..f9e11f30b2f5f 100644 --- a/ext/standard/tests/strings/vprintf_variation12_64bit.phpt +++ b/ext/standard/tests/strings/vprintf_variation12_64bit.phpt @@ -15,23 +15,16 @@ echo "*** Testing vprintf() : octal formats and non-octal values ***\n"; // defining array of octal formats $formats = - '%o %+o %-o - %lo %4o %-4o - %10.4o %-10.4o %.4o - %\'#2o %\'2o %\'$2o %\'_2o - %3$o %4$o %1$o %2$o'; + '"%o" "%+o" "%-o" + "%lo" "%4o" "%-4o" + "%10.4o" "%-10.4o" "%.4o" + "%\'#2o" "%\'2o" "%\'$2o" "%\'_2o" + "%3$o" "%4$o" "%1$o" "%2$o"'; // Arrays of non octal values for the format defined in $format. // Each sub array contains non octal values which correspond to each format in $format $args_array = array( - // array of float values - array(2.2, .2, 10.2, - 123456.234, -1234.6789, +1234.6789, - 2e10, +2e12, 22e+12, - 12345.780, 12.000000011111, -12.00000111111, -123456.234, - 3.33, +4.44, 1.11,-2.22 ), - // array of int values array(2, -2, +2, 123456, -12346789, +12346789, @@ -66,11 +59,12 @@ $args_array = array( // and with non-octal values from the above $args_array array $counter = 1; foreach($args_array as $args) { - echo "\n-- Iteration $counter --\n"; - $result = vprintf($formats, $args); - echo "\n"; - var_dump($result); - $counter++; + echo "\n-- Iteration $counter --\n"; + ob_start(); + $bytes = vprintf($formats, $args); + var_dump(ob_get_clean()); + var_dump($bytes); + $counter++; } ?> @@ -78,69 +72,33 @@ foreach($args_array as $args) { *** Testing vprintf() : octal formats and non-octal values *** -- Iteration 1 -- - -Deprecated: Implicit conversion from non-compatible float 2.2 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 0.2 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 10.2 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 123456.234 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float -1234.6789 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 1234.6789 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 12345.78 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 12.000000011111 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float -12.00000111111 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float -123456.234 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 10.2 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 123456.234 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 2.2 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 0.2 to int in %s on line %d -2 0 12 - 361100 1777777777777777775456 2322 - - 30071 14 1777777777777777777764 1777777777777777416700 - 12 361100 2 0 -int(149) +string(235) ""2" "1777777777777777777776" "2" + "361100" "1777777777777720715133" "57062645" + " " " " "" + "57060664" "4475347" "1777777777777721631371" "1777777777777720717336" + "2" "361100" "2" "1777777777777777777776"" +int(235) -- Iteration 2 -- -2 1777777777777777777776 2 - 361100 1777777777777720715133 57062645 - - 57060664 4475347 1777777777777721631371 1777777777777720717336 - 2 361100 2 1777777777777777777776 -int(201) +string(133) ""0" "0" "0" + "173" "1777777777777777777605" "173 " + " " " " "" + "2322" "0" "$0" "_0" + "0" "173" "0" "0"" +int(133) -- Iteration 3 -- -0 0 0 - 173 1777777777777777777605 173 - - 2322 0 $0 _0 - 0 173 0 0 -int(99) +string(109) ""1" "1" "1" + "1" " 1" "1 " + " " " " "" + "#1" "1" "$1" "_1" + "1" "1" "1" "1"" +int(109) -- Iteration 4 -- -1 1 1 - 1 1 1 - - #1 1 $1 _1 - 1 1 1 1 -int(75) - --- Iteration 5 -- -1 1 0 - 1 0 1 - - #0 1 $1 _0 - 0 1 1 1 -int(75) +string(109) ""1" "1" "0" + "1" " 0" "1 " + " " " " "" + "#0" "1" "$1" "_0" + "0" "1" "1" "1"" +int(109) diff --git a/ext/standard/tests/strings/vprintf_variation14.phpt b/ext/standard/tests/strings/vprintf_variation14.phpt index ac24a94695bd9..4035cbc645b8e 100644 --- a/ext/standard/tests/strings/vprintf_variation14.phpt +++ b/ext/standard/tests/strings/vprintf_variation14.phpt @@ -15,11 +15,11 @@ echo "*** Testing vprintf() : hexa formats and non-hexa values ***\n"; // defining array of different hexa formats $formats = - '%x %+x %-x - %lx x %4x %-4x - %10.4x %-10.4x %.4x - %\'#2x %\'2x %\'$2x %\'_2x - %3$x %4$x %1$x %2$x'; + '"%x" "%+x" "%-x" + "%lx" "%4x" "%-4x" + "%10.4x" "%-10.4x" "%.4x" + "%\'#2x" "%\'2x" "%\'$2x" "%\'_2x" + "%3$x" "%4$x" "%1$x" "%2$x"'; // Arrays of non hexa values for the format defined in $format. // Each sub array contains non hexa values which correspond to each format in $format @@ -59,11 +59,12 @@ $args_array = array( $counter = 1; foreach($args_array as $args) { - echo "\n-- Iteration $counter --\n"; - $result = vprintf($formats, $args); - echo "\n"; - var_dump($result); - $counter++; + echo "\n-- Iteration $counter --\n"; + ob_start(); + $bytes = vprintf($formats, $args); + var_dump(ob_get_clean()); + var_dump($bytes); + $counter++; } ?> @@ -71,33 +72,33 @@ foreach($args_array as $args) { *** Testing vprintf() : hexa formats and non-hexa values *** -- Iteration 1 -- -2 fffffffe 2 - 1e240 x ff439a5b bc65a5 - - bc61b4 127ae7 ff4732f9 ff439ede - 2 1e240 2 fffffffe -int(122) +string(158) ""2" "fffffffe" "2" + "1e240" "ff439a5b" "bc65a5" + " " " " "" + "bc61b4" "127ae7" "ff4732f9" "ff439ede" + "2" "1e240" "2" "fffffffe"" +int(158) -- Iteration 2 -- -0 0 0 - 7b x ffffff85 7b - - 4d2 0 $0 _0 - 0 7b 0 0 -int(80) +string(116) ""0" "0" "0" + "7b" "ffffff85" "7b " + " " " " "" + "4d2" "0" "$0" "_0" + "0" "7b" "0" "0"" +int(116) -- Iteration 3 -- -1 1 1 - 1 x 1 1 - - #1 1 $1 _1 - 1 1 1 1 -int(73) +string(109) ""1" "1" "1" + "1" " 1" "1 " + " " " " "" + "#1" "1" "$1" "_1" + "1" "1" "1" "1"" +int(109) -- Iteration 4 -- -1 1 0 - 1 x 0 1 - - #0 1 $1 _0 - 0 1 1 1 -int(73) +string(109) ""1" "1" "0" + "1" " 0" "1 " + " " " " "" + "#0" "1" "$1" "_0" + "0" "1" "1" "1"" +int(109) diff --git a/ext/standard/tests/strings/vprintf_variation14_64bit.phpt b/ext/standard/tests/strings/vprintf_variation14_64bit.phpt index bc913bf4800a8..bda2f03fee92d 100644 --- a/ext/standard/tests/strings/vprintf_variation14_64bit.phpt +++ b/ext/standard/tests/strings/vprintf_variation14_64bit.phpt @@ -15,23 +15,16 @@ echo "*** Testing vprintf() : hexa formats and non-hexa values ***\n"; // defining array of different hexa formats $formats = - '%x %+x %-x - %lx %4x %-4x - %10.4x %-10.4x %.4x - %\'#2x %\'2x %\'$2x %\'_2x - %3$x %4$x %1$x %2$x'; + '"%x" "%+x" "%-x" + "%lx" "%4x" "%-4x" + "%10.4x" "%-10.4x" "%.4x" + "%\'#2x" "%\'2x" "%\'$2x" "%\'_2x" + "%3$x" "%4$x" "%1$x" "%2$x"'; // Arrays of non hexa values for the format defined in $format. // Each sub array contains non hexa values which correspond to each format in $format $args_array = array( - // array of float values - array(2.2, .2, 10.2, - 123456.234, -1234.6789, +1234.6789, - 2e10, +2e12, 22e+12, - 12345.780, 12.000000011111, -12.00000111111, -123456.234, - 3.33, +4.44, 1.11,-2.22 ), - // array of int values array(2, -2, +2, 123456, -12346789, +12346789, @@ -67,11 +60,12 @@ $args_array = array( $counter = 1; foreach($args_array as $args) { - echo "\n-- Iteration $counter --\n"; - $result = vprintf($formats, $args); - echo "\n"; - var_dump($result); - $counter++; + echo "\n-- Iteration $counter --\n"; + ob_start(); + $bytes = vprintf($formats, $args); + var_dump(ob_get_clean()); + var_dump($bytes); + $counter++; } ?> @@ -79,69 +73,33 @@ foreach($args_array as $args) { *** Testing vprintf() : hexa formats and non-hexa values *** -- Iteration 1 -- - -Deprecated: Implicit conversion from non-compatible float 2.2 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 0.2 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 10.2 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 123456.234 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float -1234.6789 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 1234.6789 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 12345.78 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 12.000000011111 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float -12.00000111111 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float -123456.234 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 10.2 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 123456.234 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 2.2 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 0.2 to int in %s on line %d -2 0 a - 1e240 fffffffffffffb2e 4d2 - - 3039 c fffffffffffffff4 fffffffffffe1dc0 - a 1e240 2 0 -int(125) +string(198) ""2" "fffffffffffffffe" "2" + "1e240" "ffffffffff439a5b" "bc65a5" + " " " " "" + "bc61b4" "127ae7" "ffffffffff4732f9" "ffffffffff439ede" + "2" "1e240" "2" "fffffffffffffffe"" +int(198) -- Iteration 2 -- -2 fffffffffffffffe 2 - 1e240 ffffffffff439a5b bc65a5 - - bc61b4 127ae7 ffffffffff4732f9 ffffffffff439ede - 2 1e240 2 fffffffffffffffe -int(164) +string(124) ""0" "0" "0" + "7b" "ffffffffffffff85" "7b " + " " " " "" + "4d2" "0" "$0" "_0" + "0" "7b" "0" "0"" +int(124) -- Iteration 3 -- -0 0 0 - 7b ffffffffffffff85 7b - - 4d2 0 $0 _0 - 0 7b 0 0 -int(90) +string(109) ""1" "1" "1" + "1" " 1" "1 " + " " " " "" + "#1" "1" "$1" "_1" + "1" "1" "1" "1"" +int(109) -- Iteration 4 -- -1 1 1 - 1 1 1 - - #1 1 $1 _1 - 1 1 1 1 -int(75) - --- Iteration 5 -- -1 1 0 - 1 0 1 - - #0 1 $1 _0 - 0 1 1 1 -int(75) +string(109) ""1" "1" "0" + "1" " 0" "1 " + " " " " "" + "#0" "1" "$1" "_0" + "0" "1" "1" "1"" +int(109) diff --git a/ext/standard/tests/strings/vprintf_variation15.phpt b/ext/standard/tests/strings/vprintf_variation15.phpt index c8ae74f2aa75e..6cb5c8aa69f79 100644 --- a/ext/standard/tests/strings/vprintf_variation15.phpt +++ b/ext/standard/tests/strings/vprintf_variation15.phpt @@ -14,13 +14,13 @@ if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); echo "*** Testing vprintf() : unsigned formats and unsigned values ***\n"; // defining array of unsigned formats -$formats = array( - '%u %+u %-u', - '%lu %4u %-4u', - '%10.4u %-10.4u %.4u', - '%\'#2u %\'2u %\'$2u %\'_2u', - '%3$u %4$u %1$u %2$u' -); +$formats = [ + '"%u" "%+u" "%-u"', + '"%lu" "%4u" "%-4u"', + ' "%10.4u" "%-10.4u" "%.4u"', + '"%\'#2u "%\'2u" "%\'$2u" "%\'_2u"', + '"%3$u" "%4$u" "%1$u" "%2$u"', +]; // Arrays of unsigned values for the format defined in $format. // Each sub array contains unsigned values which correspond to each format string in $format @@ -36,33 +36,38 @@ $args_array = array( // and with signed and other types of values from the above $args_array array $counter = 1; foreach($formats as $format) { - echo "\n-- Iteration $counter --\n"; - $result = vprintf($format, $args_array[$counter-1]); - echo "\n"; - var_dump($result); - $counter++; + echo "\n-- Iteration $counter --\n"; + ob_start(); + $bytes = vprintf($format, $args_array[$counter-1]); + var_dump(ob_get_clean()); + var_dump($bytes); + $counter++; } ?> ---EXPECT-- +--EXPECTF-- *** Testing vprintf() : unsigned formats and unsigned values *** -- Iteration 1 -- -1234567 342391 0 -int(16) +string(22) ""1234567" "342391" "0"" +int(22) -- Iteration 2 -- -3755744308 1234 12345 -int(21) +string(%d) " +Deprecated: Implicit conversion from non-compatible float 12345678900 to int in %s on line %d +"3755744308" "1234" "12345"" +int(27) -- Iteration 3 -- - 1234000 2450319192 120 -int(25) +string(%d) " +Deprecated: Implicit conversion from non-compatible float 101234567000 to int in %s on line %d + " 1234000" "2450319192" "120"" +int(32) -- Iteration 4 -- -#1 0 $0 10 -int(10) +string(17) ""#1 "0" "$0" "10"" +int(17) -- Iteration 5 -- -1 2 3 4 -int(7) +string(15) ""1" "2" "3" "4"" +int(15) diff --git a/ext/standard/tests/strings/vprintf_variation15_64bit.phpt b/ext/standard/tests/strings/vprintf_variation15_64bit.phpt index 6f4c84a9a246f..78e88d87b293e 100644 --- a/ext/standard/tests/strings/vprintf_variation15_64bit.phpt +++ b/ext/standard/tests/strings/vprintf_variation15_64bit.phpt @@ -14,13 +14,13 @@ if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); echo "*** Testing vprintf() : unsigned formats and unsigned values ***\n"; // defining array of unsigned formats -$formats = array( - '%u %+u %-u', - '%lu %4u %-4u', - '%10.4u %-10.4u %.4u', - '%\'#2u %\'2u %\'$2u %\'_2u', - '%3$u %4$u %1$u %2$u' -); +$formats = [ + '"%u" "%+u" "%-u"', + '"%lu" "%4u" "%-4u"', + ' "%10.4u" "%-10.4u" "%.4u"', + '"%\'#2u "%\'2u" "%\'$2u" "%\'_2u"', + '"%3$u" "%4$u" "%1$u" "%2$u"', +]; // Arrays of unsigned values for the format defined in $format. // Each sub array contains unsigned values which correspond to each format string in $format @@ -36,11 +36,12 @@ $args_array = array( // and with signed and other types of values from the above $args_array array $counter = 1; foreach($formats as $format) { - echo "\n-- Iteration $counter --\n"; - $result = vprintf($format, $args_array[$counter-1]); - echo "\n"; - var_dump($result); - $counter++; + echo "\n-- Iteration $counter --\n"; + ob_start(); + $bytes = vprintf($format, $args_array[$counter-1]); + var_dump(ob_get_clean()); + var_dump($bytes); + $counter++; } ?> @@ -48,23 +49,23 @@ foreach($formats as $format) { *** Testing vprintf() : unsigned formats and unsigned values *** -- Iteration 1 -- -1234567 342391 0 -int(16) +string(22) ""1234567" "342391" "0"" +int(22) -- Iteration 2 -- -12345678900 1234 12345 -int(22) +string(28) ""12345678900" "1234" "12345"" +int(28) -- Iteration 3 -- - +string(%d) " Deprecated: Implicit conversion from non-compatible float 1.0E+21 to int in %s on line %d - 1234000 3875820019684212736 120 -int(34) + " 1234000" "3875820019684212736" "120"" +int(41) -- Iteration 4 -- -#1 0 $0 10 -int(10) +string(17) ""#1 "0" "$0" "10"" +int(17) -- Iteration 5 -- -1 2 3 4 -int(7) +string(15) ""1" "2" "3" "4"" +int(15) diff --git a/ext/standard/tests/strings/vprintf_variation16.phpt b/ext/standard/tests/strings/vprintf_variation16.phpt index 70ecdab99e071..31288d03ca679 100644 --- a/ext/standard/tests/strings/vprintf_variation16.phpt +++ b/ext/standard/tests/strings/vprintf_variation16.phpt @@ -15,23 +15,16 @@ echo "*** Testing vprintf() : unsigned formats and signed & other types of value // defining array of unsigned formats $formats = - '%u %+u %-u - %lu %4u %-4u - %10.4u %-10.4u %.4u - %\'#2u %\'2u %\'$2u %\'_2u - %3$u %4$u %1$u %2$u'; + '"%u" "%+u" "%-u" + "%lu" "%4u" "%-4u" + "%10.4u" "%-10.4u" "%.4u" + "%\'#2u "%\'2u" "%\'$2u" "%\'_2u" + "%3$u" "%4$u" "%1$u" "%2$u"'; // Arrays of signed and other type of values for the format defined in $format. // Each sub array contains signed values which correspond to each format in $format $args_array = array( - // array of float values - array(+2.2, +.2, +10.2, - +123456.234, +123456.234, +1234.6789, - +2e10, +2e12, +22e+12, - +12345.780, +12.000000011111, -12.00000111111, -123456.234, - +3.33, +4.44, +1.11,-2.22 ), - // array of strings array(" ", ' ', 'hello', '123hello', '-123hello', '+123hello', @@ -59,44 +52,37 @@ $args_array = array( // and with signed and other types of values from the above $args_array array $counter = 1; foreach($args_array as $args) { - echo "\n-- Iteration $counter --\n"; - $result = vprintf($formats, $args); - echo "\n"; - var_dump($result); - $counter++; + echo "\n-- Iteration $counter --\n"; + ob_start(); + $bytes = vprintf($formats, $args); + var_dump(ob_get_clean()); + var_dump($bytes); + $counter++; } ?> --EXPECT-- *** Testing vprintf() : unsigned formats and signed & other types of values *** -- Iteration 1 -- -2 0 10 - 123456 123456 1234 - 2820130816 2840207360 1177509888 - 12345 12 4294967284 4294843840 - 10 123456 2 0 -int(115) +string(121) ""0" "0" "0" + "123" "4294967173" "123 " + " 0" "0 " "0" + "1234 "0" "$0" "_0" + "0" "123" "0" "0"" +int(121) -- Iteration 2 -- -0 0 0 - 123 4294967173 123 - 0 0 0 - 1234 0 $0 _0 - 0 123 0 0 -int(84) +string(109) ""1" "1" "1" + "1" " 1" "1 " + " 1" "1 " "1" + "#1 "1" "$1" "_1" + "1" "1" "1" "1"" +int(109) -- Iteration 3 -- -1 1 1 - 1 1 1 - 1 1 1 - #1 1 $1 _1 - 1 1 1 1 -int(72) - --- Iteration 4 -- -1 1 0 - 1 0 1 - 1 1 0 - #0 1 $1 _0 - 0 1 1 1 -int(72) +string(109) ""1" "1" "0" + "1" " 0" "1 " + " 1" "1 " "0" + "#0 "1" "$1" "_0" + "0" "1" "1" "1"" +int(109) diff --git a/ext/standard/tests/strings/vprintf_variation16_64bit.phpt b/ext/standard/tests/strings/vprintf_variation16_64bit.phpt index 08f2d67024ae9..ffa4f9213b17b 100644 --- a/ext/standard/tests/strings/vprintf_variation16_64bit.phpt +++ b/ext/standard/tests/strings/vprintf_variation16_64bit.phpt @@ -15,23 +15,15 @@ echo "*** Testing vprintf() : unsigned formats and signed & other types of value // defining array of unsigned formats $formats = - '%u %+u %-u - %lu %4u %-4u - %10.4u %-10.4u %.4u - %\'#2u %\'2u %\'$2u %\'_2u - %3$u %4$u %1$u %2$u'; + '"%u" "%+u" "%-u" + "%lu" "%4u" "%-4u" + "%10.4u" "%-10.4u" "%.4u" + "%\'#2u "%\'2u" "%\'$2u" "%\'_2u" + "%3$u" "%4$u" "%1$u" "%2$u"'; // Arrays of signed and other type of values for the format defined in $format. // Each sub array contains signed values which correspond to each format in $format $args_array = array( - - // array of float values - array(+2.2, +.2, +10.2, - +123456.234, +123456.234, +1234.6789, - +2e10, +2e12, +22e+12, - +12345.780, +12.000000011111, -12.00000111111, -123456.234, - +3.33, +4.44, +1.11,-2.22 ), - // array of strings array(" ", ' ', 'hello', '123hello', '-123hello', '+123hello', @@ -59,73 +51,38 @@ $args_array = array( // and with signed and other types of values from the above $args_array array $counter = 1; foreach($args_array as $args) { - echo "\n-- Iteration $counter --\n"; - $result = vprintf($formats, $args); - echo "\n"; - var_dump($result); - $counter++; + echo "\n-- Iteration $counter --\n"; + ob_start(); + $bytes = vprintf($formats, $args); + var_dump(ob_get_clean()); + var_dump($bytes); + $counter++; } ?> ---EXPECTF-- +--EXPECT-- *** Testing vprintf() : unsigned formats and signed & other types of values *** -- Iteration 1 -- - -Deprecated: Implicit conversion from non-compatible float 2.2 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 0.2 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 10.2 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 123456.234 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 123456.234 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 1234.6789 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 12345.78 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 12.000000011111 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float -12.00000111111 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float -123456.234 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 10.2 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 123456.234 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 2.2 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 0.2 to int in %s on line %d -2 0 10 - 123456 123456 1234 - 20000000000 2000000000000 22000000000000 - 12345 12 18446744073709551604 18446744073709428160 - 10 123456 2 0 -int(147) +string(131) ""0" "0" "0" + "123" "18446744073709551493" "123 " + " 0" "0 " "0" + "1234 "0" "$0" "_0" + "0" "123" "0" "0"" +int(131) -- Iteration 2 -- -0 0 0 - 123 18446744073709551493 123 - 0 0 0 - 1234 0 $0 _0 - 0 123 0 0 -int(98) +string(109) ""1" "1" "1" + "1" " 1" "1 " + " 1" "1 " "1" + "#1 "1" "$1" "_1" + "1" "1" "1" "1"" +int(109) -- Iteration 3 -- -1 1 1 - 1 1 1 - 1 1 1 - #1 1 $1 _1 - 1 1 1 1 -int(76) - --- Iteration 4 -- -1 1 0 - 1 0 1 - 1 1 0 - #0 1 $1 _0 - 0 1 1 1 -int(76) +string(109) ""1" "1" "0" + "1" " 0" "1 " + " 1" "1 " "0" + "#0 "1" "$1" "_0" + "0" "1" "1" "1"" +int(109) diff --git a/ext/standard/tests/strings/vprintf_variation4.phpt b/ext/standard/tests/strings/vprintf_variation4.phpt index d489d36835da7..be5b4d2a2a0c0 100644 --- a/ext/standard/tests/strings/vprintf_variation4.phpt +++ b/ext/standard/tests/strings/vprintf_variation4.phpt @@ -2,7 +2,7 @@ Test vprintf() function : usage variations - int formats with non-integer values --SKIPIF-- --FILE-- @@ -63,25 +64,25 @@ foreach($args_array as $args) { *** Testing vprintf() : int formats and non-integer values *** -- Iteration 1 -- -0 +0 0 - 123 -123 123 - 0 0 123456 0000 - 1234 0 $0 _0 - 0 123 0 0 -int(89) +string(129) ""0" "+0" "0" + "123" "-123" "123 " + " 0" "0 " "123456" "0000" + "1234" "0" "$0" "_0" + "0" "123" "0" "0"" +int(129) -- Iteration 2 -- -1 +1 1 - 1 1 1 - 1 1 1 0001 - #1 1 $1 _1 - 1 1 1 1 -int(78) +string(118) ""1" "+1" "1" + "1" " 1" "1 " + " 1" "1 " "1" "0001" + "#1" "1" "$1" "_1" + "1" "1" "1" "1"" +int(118) -- Iteration 3 -- -1 +1 0 - 1 0 1 - 1 0 1 0000 - #0 1 $1 _0 - 0 1 1 1 -int(78) +string(118) ""1" "+1" "0" + "1" " 0" "1 " + " 1" "0 " "1" "0000" + "#0" "1" "$1" "_0" + "0" "1" "1" "1"" +int(118) diff --git a/ext/standard/tests/strings/vprintf_variation4_64bit.phpt b/ext/standard/tests/strings/vprintf_variation4_64bit.phpt deleted file mode 100644 index ac2a672538d65..0000000000000 --- a/ext/standard/tests/strings/vprintf_variation4_64bit.phpt +++ /dev/null @@ -1,131 +0,0 @@ ---TEST-- -Test vprintf() function : usage variations - int formats with non-integer values ---SKIPIF-- - ---FILE-- -"12twelve"), - array("3"), array("4"), array("1"), array("2") ), - - // array of boolean data - array( true, TRUE, false, - TRUE, FALSE, 1, - true, false, TRUE, FALSE, - 0, 1, 1, 0, - 1, TRUE, 0, FALSE), - -); - -// looping to test vprintf() with different int formats from the above $format array -// and with non-int values from the above $args_array array -$counter = 1; -foreach($args_array as $args) { - echo "\n-- Iteration $counter --\n"; - $result = vprintf($formats, $args); - echo "\n"; - var_dump($result); - $counter++; -} - -?> ---EXPECTF-- -*** Testing vprintf() : int formats and non-integer values *** - --- Iteration 1 -- - -Deprecated: Implicit conversion from non-compatible float 2.2 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 0.2 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 10.2 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 123456.234 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float -1234.6789 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 1234.6789 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 12345.78 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 12.000000011111 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float -12.00000111111 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float -123456.234 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 10.2 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 123456.234 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 2.2 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 0.2 to int in %s on line %d -2 +0 10 - 123456 -1234 1234 - 20000000000 200000 4000 22000000 - 12345 12 -12 -123456 - 10 123456 2 0 -int(113) - --- Iteration 2 -- -0 +0 0 - 123 -123 123 - 0 0 123456 0000 - 1234 0 $0 _0 - 0 123 0 0 -int(93) - --- Iteration 3 -- -1 +1 1 - 1 1 1 - 1 1 1 0001 - #1 1 $1 _1 - 1 1 1 1 -int(82) - --- Iteration 4 -- -1 +1 0 - 1 0 1 - 1 0 1 0000 - #0 1 $1 _0 - 0 1 1 1 -int(82) diff --git a/tests/lang/bug27354.phpt b/tests/lang/bug27354.phpt index c6ce9804fd240..23fecc4fea36e 100644 --- a/tests/lang/bug27354.phpt +++ b/tests/lang/bug27354.phpt @@ -2,13 +2,15 @@ Bug #27354 (Modulus operator crashes PHP) --FILE-- --EXPECTF-- -int(%i) -int(%i) -int(%i) -int(%i) +int(0) + +Deprecated: Implicit conversion from non-compatible float -9.223372036854776E+18 to int in %s on line %d +int(0) +int(0) +int(0) From 45b68b6859a734b4208f159bb2f803ea4004bf92 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Tue, 18 May 2021 05:23:23 +0100 Subject: [PATCH 38/61] Revert test change from 32bit This doesn't generate a deprecation warning on 64bit --- tests/lang/bug27354.phpt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/lang/bug27354.phpt b/tests/lang/bug27354.phpt index 23fecc4fea36e..34dd9e90d429a 100644 --- a/tests/lang/bug27354.phpt +++ b/tests/lang/bug27354.phpt @@ -7,10 +7,8 @@ var_dump(-9_223_372_036_854_775_900 % -1); // Min value for 64bit int -1 var_dump(-2147483648 % -1); var_dump(-2147483648 % -2); ?> ---EXPECTF-- +--EXPECT-- int(0) - -Deprecated: Implicit conversion from non-compatible float -9.223372036854776E+18 to int in %s on line %d int(0) int(0) int(0) From fad564488443de328aaf9e97c452a27d67b12998 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Tue, 18 May 2021 05:20:57 +0100 Subject: [PATCH 39/61] Fix pass optimizer --- Zend/Optimizer/pass1.c | 92 +++++++++++++++++-- ext/opcache/tests/jit/reg_alloc_003.phpt | 4 + .../tests/jit/reg_alloc_003_32bits.phpt | 28 ++++++ 3 files changed, 116 insertions(+), 8 deletions(-) create mode 100644 ext/opcache/tests/jit/reg_alloc_003_32bits.phpt diff --git a/Zend/Optimizer/pass1.c b/Zend/Optimizer/pass1.c index 851d77c7df4e5..1144791f492e6 100644 --- a/Zend/Optimizer/pass1.c +++ b/Zend/Optimizer/pass1.c @@ -62,17 +62,56 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx) } break; - case ZEND_ADD: - case ZEND_SUB: - case ZEND_MUL: - case ZEND_DIV: - case ZEND_POW: + /* Don't optimize if float/float-string to int conversion is not compatible */ case ZEND_MOD: case ZEND_SL: case ZEND_SR: + if (opline->op1_type == IS_CONST && + opline->op2_type == IS_CONST) { + if ((Z_TYPE(ZEND_OP1_LITERAL(opline)) == IS_DOUBLE && + !zend_is_long_compatible(zend_dval_to_lval(Z_DVAL(ZEND_OP1_LITERAL(opline))), + Z_DVAL(ZEND_OP1_LITERAL(opline)))) + || (Z_TYPE(ZEND_OP2_LITERAL(opline)) == IS_DOUBLE && + !zend_is_long_compatible(zend_dval_to_lval(Z_DVAL(ZEND_OP2_LITERAL(opline))), + Z_DVAL(ZEND_OP2_LITERAL(opline)))) + ) { + break; + } + /* don't optimize if it should produce a runtime numeric string error */ + if (Z_TYPE(ZEND_OP2_LITERAL(opline)) == IS_STRING) { + double dval = 0; + zend_uchar is_num = is_numeric_string(Z_STRVAL(ZEND_OP2_LITERAL(opline)), + Z_STRLEN(ZEND_OP2_LITERAL(opline)), NULL, &dval, /* allow_errors */ false); + if (is_num == 0 || (is_num == IS_DOUBLE && !zend_is_long_compatible(zend_dval_to_lval(dval), dval))) { + break; + } + } + goto constant_binary_op; + } + break; + /* Don't optimize if float to int conversion is not compatible */ case ZEND_BW_OR: case ZEND_BW_AND: case ZEND_BW_XOR: + if (opline->op1_type == IS_CONST && + opline->op2_type == IS_CONST) { + if ((Z_TYPE(ZEND_OP1_LITERAL(opline)) == IS_DOUBLE && + !zend_is_long_compatible(zend_dval_to_lval(Z_DVAL(ZEND_OP1_LITERAL(opline))), + Z_DVAL(ZEND_OP1_LITERAL(opline)))) + || (Z_TYPE(ZEND_OP2_LITERAL(opline)) == IS_DOUBLE && + !zend_is_long_compatible(zend_dval_to_lval(Z_DVAL(ZEND_OP2_LITERAL(opline))), + Z_DVAL(ZEND_OP2_LITERAL(opline)))) + ) { + break; + } + goto constant_binary_op; + } + break; + case ZEND_ADD: + case ZEND_SUB: + case ZEND_MUL: + case ZEND_DIV: + case ZEND_POW: case ZEND_IS_EQUAL: case ZEND_IS_NOT_EQUAL: case ZEND_IS_SMALLER: @@ -120,11 +159,23 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx) || opline->extended_value == ZEND_SL || opline->extended_value == ZEND_SR) { if (Z_TYPE(ZEND_OP2_LITERAL(opline)) != IS_LONG) { + /* Don't optimize if it should produce an incompatible float to int error */ + // TODO There must be a better way + if (Z_TYPE(ZEND_OP2_LITERAL(opline)) == IS_DOUBLE + && !zend_is_long_compatible(zend_dval_to_lval(Z_DVAL(ZEND_OP2_LITERAL(opline))), + Z_DVAL(ZEND_OP2_LITERAL(opline)))) { + break; + } /* don't optimize if it should produce a runtime numeric string error */ - if (!(Z_TYPE(ZEND_OP2_LITERAL(opline)) == IS_STRING - && !is_numeric_string(Z_STRVAL(ZEND_OP2_LITERAL(opline)), Z_STRLEN(ZEND_OP2_LITERAL(opline)), NULL, NULL, 0))) { - convert_to_long(&ZEND_OP2_LITERAL(opline)); + if (Z_TYPE(ZEND_OP2_LITERAL(opline)) == IS_STRING) { + double dval = 0; + zend_uchar is_num = is_numeric_string(Z_STRVAL(ZEND_OP2_LITERAL(opline)), + Z_STRLEN(ZEND_OP2_LITERAL(opline)), NULL, &dval, /* allow_errors */ false); + if (is_num == 0 || (is_num == IS_DOUBLE && !zend_is_long_compatible(zend_dval_to_lval(dval), dval))) { + break; + } } + convert_to_long(&ZEND_OP2_LITERAL(opline)); } } else if (opline->extended_value == ZEND_CONCAT) { if (Z_TYPE(ZEND_OP2_LITERAL(opline)) != IS_STRING) { @@ -154,6 +205,31 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx) break; case ZEND_BW_NOT: + if (opline->op1_type == IS_CONST) { + /* unary operation on constant operand */ + zval result; + + /* Don't optimize if it should produce an incompatible float to int error */ + // TODO There must be a better way + if (Z_TYPE(ZEND_OP1_LITERAL(opline)) == IS_DOUBLE + && !zend_is_long_compatible(zend_dval_to_lval( + Z_DVAL(ZEND_OP1_LITERAL(opline))), Z_DVAL(ZEND_OP1_LITERAL(opline)) + ) + ) { + break; + } + + if (zend_optimizer_eval_unary_op(&result, opline->opcode, &ZEND_OP1_LITERAL(opline)) == SUCCESS) { + literal_dtor(&ZEND_OP1_LITERAL(opline)); + if (zend_optimizer_replace_by_const(op_array, opline + 1, IS_TMP_VAR, opline->result.var, &result)) { + MAKE_NOP(opline); + } else { + opline->opcode = ZEND_QM_ASSIGN; + zend_optimizer_update_op1_const(op_array, opline, &result); + } + } + } + break; case ZEND_BOOL_NOT: if (opline->op1_type == IS_CONST) { /* unary operation on constant operand */ diff --git a/ext/opcache/tests/jit/reg_alloc_003.phpt b/ext/opcache/tests/jit/reg_alloc_003.phpt index 4355089ec25b2..e0f7474ded40b 100644 --- a/ext/opcache/tests/jit/reg_alloc_003.phpt +++ b/ext/opcache/tests/jit/reg_alloc_003.phpt @@ -1,5 +1,9 @@ --TEST-- Register Alloction 003: Reuse temporary register +--SKIPIF-- + --INI-- opcache.enable=1 opcache.enable_cli=1 diff --git a/ext/opcache/tests/jit/reg_alloc_003_32bits.phpt b/ext/opcache/tests/jit/reg_alloc_003_32bits.phpt new file mode 100644 index 0000000000000..c51e848b6f22a --- /dev/null +++ b/ext/opcache/tests/jit/reg_alloc_003_32bits.phpt @@ -0,0 +1,28 @@ +--TEST-- +Register Alloction 003: Reuse temporary register +--SKIPIF-- + +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.file_update_protection=0 +opcache.jit_buffer_size=1M +opcache.protect_memory=1 +--EXTENSIONS-- +opcache +--FILE-- + +--EXPECTF-- +Deprecated: Implicit conversion from non-compatible float 4294967168 to int in %s on line %d +correct From eae1e6550888fc32e34acd5fbd6b0b88c0f13b6d Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Tue, 18 May 2021 13:03:10 +0100 Subject: [PATCH 40/61] Optimizer fixes and partial revert --- Zend/Optimizer/pass1.c | 74 +++--------------------------------------- Zend/zend_compile.c | 3 +- 2 files changed, 6 insertions(+), 71 deletions(-) diff --git a/Zend/Optimizer/pass1.c b/Zend/Optimizer/pass1.c index 1144791f492e6..3d58f1bcc5421 100644 --- a/Zend/Optimizer/pass1.c +++ b/Zend/Optimizer/pass1.c @@ -62,56 +62,17 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx) } break; - /* Don't optimize if float/float-string to int conversion is not compatible */ + case ZEND_ADD: + case ZEND_SUB: + case ZEND_MUL: + case ZEND_DIV: + case ZEND_POW: case ZEND_MOD: case ZEND_SL: case ZEND_SR: - if (opline->op1_type == IS_CONST && - opline->op2_type == IS_CONST) { - if ((Z_TYPE(ZEND_OP1_LITERAL(opline)) == IS_DOUBLE && - !zend_is_long_compatible(zend_dval_to_lval(Z_DVAL(ZEND_OP1_LITERAL(opline))), - Z_DVAL(ZEND_OP1_LITERAL(opline)))) - || (Z_TYPE(ZEND_OP2_LITERAL(opline)) == IS_DOUBLE && - !zend_is_long_compatible(zend_dval_to_lval(Z_DVAL(ZEND_OP2_LITERAL(opline))), - Z_DVAL(ZEND_OP2_LITERAL(opline)))) - ) { - break; - } - /* don't optimize if it should produce a runtime numeric string error */ - if (Z_TYPE(ZEND_OP2_LITERAL(opline)) == IS_STRING) { - double dval = 0; - zend_uchar is_num = is_numeric_string(Z_STRVAL(ZEND_OP2_LITERAL(opline)), - Z_STRLEN(ZEND_OP2_LITERAL(opline)), NULL, &dval, /* allow_errors */ false); - if (is_num == 0 || (is_num == IS_DOUBLE && !zend_is_long_compatible(zend_dval_to_lval(dval), dval))) { - break; - } - } - goto constant_binary_op; - } - break; - /* Don't optimize if float to int conversion is not compatible */ case ZEND_BW_OR: case ZEND_BW_AND: case ZEND_BW_XOR: - if (opline->op1_type == IS_CONST && - opline->op2_type == IS_CONST) { - if ((Z_TYPE(ZEND_OP1_LITERAL(opline)) == IS_DOUBLE && - !zend_is_long_compatible(zend_dval_to_lval(Z_DVAL(ZEND_OP1_LITERAL(opline))), - Z_DVAL(ZEND_OP1_LITERAL(opline)))) - || (Z_TYPE(ZEND_OP2_LITERAL(opline)) == IS_DOUBLE && - !zend_is_long_compatible(zend_dval_to_lval(Z_DVAL(ZEND_OP2_LITERAL(opline))), - Z_DVAL(ZEND_OP2_LITERAL(opline)))) - ) { - break; - } - goto constant_binary_op; - } - break; - case ZEND_ADD: - case ZEND_SUB: - case ZEND_MUL: - case ZEND_DIV: - case ZEND_POW: case ZEND_IS_EQUAL: case ZEND_IS_NOT_EQUAL: case ZEND_IS_SMALLER: @@ -205,31 +166,6 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx) break; case ZEND_BW_NOT: - if (opline->op1_type == IS_CONST) { - /* unary operation on constant operand */ - zval result; - - /* Don't optimize if it should produce an incompatible float to int error */ - // TODO There must be a better way - if (Z_TYPE(ZEND_OP1_LITERAL(opline)) == IS_DOUBLE - && !zend_is_long_compatible(zend_dval_to_lval( - Z_DVAL(ZEND_OP1_LITERAL(opline))), Z_DVAL(ZEND_OP1_LITERAL(opline)) - ) - ) { - break; - } - - if (zend_optimizer_eval_unary_op(&result, opline->opcode, &ZEND_OP1_LITERAL(opline)) == SUCCESS) { - literal_dtor(&ZEND_OP1_LITERAL(opline)); - if (zend_optimizer_replace_by_const(op_array, opline + 1, IS_TMP_VAR, opline->result.var, &result)) { - MAKE_NOP(opline); - } else { - opline->opcode = ZEND_QM_ASSIGN; - zend_optimizer_update_op1_const(op_array, opline, &result); - } - } - } - break; case ZEND_BOOL_NOT: if (opline->op1_type == IS_CONST) { /* unary operation on constant operand */ diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index eb7b4a7b5396e..823e0692d162d 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -8238,8 +8238,7 @@ static inline bool zend_try_ct_eval_binary_op(zval *result, uint32_t opcode, zva ZEND_API bool zend_unary_op_produces_error(uint32_t opcode, zval *op) { if (opcode == ZEND_BW_NOT) { - return (Z_TYPE_P(op) <= IS_TRUE || Z_TYPE_P(op) == IS_ARRAY || Z_TYPE_P(op) == IS_DOUBLE - || (Z_TYPE_P(op) == IS_STRING && is_numeric_str_function(Z_STR_P(op), NULL, NULL) != IS_LONG)); + return (Z_TYPE_P(op) <= IS_TRUE || Z_TYPE_P(op) == IS_ARRAY || Z_TYPE_P(op) == IS_DOUBLE); } return 0; From fee33dbbdbd7b093543c4c32bb2cb4841c040f04 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 18 May 2021 15:06:52 +0200 Subject: [PATCH 41/61] Fix zend_is_long_compatible arg order And put op2 in a variable while at it. --- Zend/Optimizer/pass1.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Zend/Optimizer/pass1.c b/Zend/Optimizer/pass1.c index 3d58f1bcc5421..025ae50778e39 100644 --- a/Zend/Optimizer/pass1.c +++ b/Zend/Optimizer/pass1.c @@ -119,24 +119,25 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx) } else if (opline->extended_value == ZEND_MOD || opline->extended_value == ZEND_SL || opline->extended_value == ZEND_SR) { - if (Z_TYPE(ZEND_OP2_LITERAL(opline)) != IS_LONG) { + zval *op2 = &ZEND_OP2_LITERAL(opline); + if (Z_TYPE_P(op2) != IS_LONG) { /* Don't optimize if it should produce an incompatible float to int error */ // TODO There must be a better way - if (Z_TYPE(ZEND_OP2_LITERAL(opline)) == IS_DOUBLE - && !zend_is_long_compatible(zend_dval_to_lval(Z_DVAL(ZEND_OP2_LITERAL(opline))), - Z_DVAL(ZEND_OP2_LITERAL(opline)))) { + if (Z_TYPE_P(op2) == IS_DOUBLE + && !zend_is_long_compatible( + Z_DVAL_P(op2), zend_dval_to_lval(Z_DVAL_P(op2)))) { break; } /* don't optimize if it should produce a runtime numeric string error */ - if (Z_TYPE(ZEND_OP2_LITERAL(opline)) == IS_STRING) { + if (Z_TYPE_P(op2) == IS_STRING) { double dval = 0; - zend_uchar is_num = is_numeric_string(Z_STRVAL(ZEND_OP2_LITERAL(opline)), - Z_STRLEN(ZEND_OP2_LITERAL(opline)), NULL, &dval, /* allow_errors */ false); - if (is_num == 0 || (is_num == IS_DOUBLE && !zend_is_long_compatible(zend_dval_to_lval(dval), dval))) { + zend_uchar is_num = is_numeric_string(Z_STRVAL_P(op2), + Z_STRLEN_P(op2), NULL, &dval, /* allow_errors */ false); + if (is_num == 0 || (is_num == IS_DOUBLE && !zend_is_long_compatible(dval, zend_dval_to_lval(dval)))) { break; } } - convert_to_long(&ZEND_OP2_LITERAL(opline)); + convert_to_long(op2); } } else if (opline->extended_value == ZEND_CONCAT) { if (Z_TYPE(ZEND_OP2_LITERAL(opline)) != IS_STRING) { From 261eae06c0c523c2d506df26ff154d50d8002021 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Thu, 27 May 2021 16:22:52 +0100 Subject: [PATCH 42/61] Add ZEND_COLD' --- Zend/zend_operators.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index a7cd9ab582cb5..e80eff2902c66 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -808,11 +808,11 @@ ZEND_API void ZEND_FASTCALL convert_to_object(zval *op) /* {{{ */ } /* }}} */ -ZEND_API void zend_incompatible_double_to_long_error(double d) +ZEND_API void ZEND_COLD zend_incompatible_double_to_long_error(double d) { zend_error_unchecked(E_DEPRECATED, "Implicit conversion from non-compatible float %.*H to int", -1, d); } -ZEND_API void zend_incompatible_string_to_long_error(const zend_string *s) +ZEND_API void ZEND_COLD zend_incompatible_string_to_long_error(const zend_string *s) { zend_error(E_DEPRECATED, "Implicit conversion from non-compatible float-string \"%s\" to int", ZSTR_VAL(s)); } From 91784e22d2181735ebb939eb2c664728b263cc96 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Thu, 27 May 2021 16:28:31 +0100 Subject: [PATCH 43/61] Drop TODOs or handle exception --- Zend/zend_operators.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index e80eff2902c66..dafa225351c41 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -837,8 +837,6 @@ ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op, bool is_strict) /* if (UNEXPECTED(is_strict)) { if (!zend_is_long_compatible(dval, lval)) { zend_incompatible_double_to_long_error(dval); - // TODO Need to handle this here? - //if (UNEXPECTED(EG(exception))) {} } } return lval; @@ -863,8 +861,6 @@ ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op, bool is_strict) /* if (UNEXPECTED(is_strict)) { if (!zend_is_long_compatible(dval, lval)) { zend_incompatible_string_to_long_error(Z_STR_P(op)); - // TODO Need to handle this here? - //if (UNEXPECTED(EG(exception))) {} } } return lval; @@ -1499,10 +1495,17 @@ ZEND_API zend_result ZEND_FASTCALL bitwise_not_function(zval *result, zval *op1) case IS_LONG: ZVAL_LONG(result, ~Z_LVAL_P(op1)); return SUCCESS; - case IS_DOUBLE: - // TODO Handle manually in case deprecation notice promoted to Exception? - ZVAL_LONG(result, ~zend_dval_to_lval_safe(Z_DVAL_P(op1))); + case IS_DOUBLE: { + zend_long lval = zend_dval_to_lval(Z_DVAL_P(op1)); + if (!zend_is_long_compatible(Z_DVAL_P(op1), lval)) { + zend_incompatible_double_to_long_error(Z_DVAL_P(op1)); + if (EG(exception)) { + return FAILURE; + } + } + ZVAL_LONG(result, ~lval); return SUCCESS; + } case IS_STRING: { size_t i; From 4e94989edb2356fd0f192f57485dee7606d55fa0 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Thu, 27 May 2021 16:31:57 +0100 Subject: [PATCH 44/61] Typo --- Zend/zend_execute.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index e4593a2531809..1bf857151caca 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -776,7 +776,7 @@ static bool zend_verify_weak_scalar_type_hint_no_sideeffect(uint32_t type_mask, bool bval; /* Pass (uint32_t)-1 as arg_num to indicate to ZPP not to emit any deprecation notice, - * this is needed because the version with side effects also uses 0 (e.g. for types properties) */ + * this is needed because the version with side effects also uses 0 (e.g. for typed properties) */ if ((type_mask & MAY_BE_LONG) && zend_parse_arg_long_weak(arg, &lval, (uint32_t)-1)) { return 1; } From 36ee18e60c0419230ffbc809c5660ec0a3f4d2de Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Thu, 27 May 2021 16:50:19 +0100 Subject: [PATCH 45/61] Add zend_is_op_long_compatible() function instead of repeating the check multiple times --- Zend/Optimizer/pass1.c | 15 +-------------- Zend/zend_compile.c | 31 +++++++++++++++++++++++-------- Zend/zend_compile.h | 1 + 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/Zend/Optimizer/pass1.c b/Zend/Optimizer/pass1.c index 025ae50778e39..62354215d5aad 100644 --- a/Zend/Optimizer/pass1.c +++ b/Zend/Optimizer/pass1.c @@ -121,22 +121,9 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx) || opline->extended_value == ZEND_SR) { zval *op2 = &ZEND_OP2_LITERAL(opline); if (Z_TYPE_P(op2) != IS_LONG) { - /* Don't optimize if it should produce an incompatible float to int error */ - // TODO There must be a better way - if (Z_TYPE_P(op2) == IS_DOUBLE - && !zend_is_long_compatible( - Z_DVAL_P(op2), zend_dval_to_lval(Z_DVAL_P(op2)))) { + if (!zend_is_op_long_compatible(op2)) { break; } - /* don't optimize if it should produce a runtime numeric string error */ - if (Z_TYPE_P(op2) == IS_STRING) { - double dval = 0; - zend_uchar is_num = is_numeric_string(Z_STRVAL_P(op2), - Z_STRLEN_P(op2), NULL, &dval, /* allow_errors */ false); - if (is_num == 0 || (is_num == IS_DOUBLE && !zend_is_long_compatible(dval, zend_dval_to_lval(dval)))) { - break; - } - } convert_to_long(op2); } } else if (opline->extended_value == ZEND_CONCAT) { diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 823e0692d162d..ef8acbe871dcd 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -8156,6 +8156,27 @@ static bool zend_try_ct_eval_magic_const(zval *zv, zend_ast *ast) /* {{{ */ } /* }}} */ +ZEND_API bool zend_is_op_long_compatible(zval *op) +{ + /* This is handled before */ + ZEND_ASSERT(Z_TYPE_P(op) != IS_ARRAY); + + if (Z_TYPE_P(op) == IS_DOUBLE + && !zend_is_long_compatible(Z_DVAL_P(op), zend_dval_to_lval(Z_DVAL_P(op)))) { + return false; + } + + if (Z_TYPE_P(op) == IS_STRING) { + double dval = 0; + zend_uchar is_num = is_numeric_str_function(Z_STR_P(op), NULL, &dval); + if (is_num == 0 || (is_num == IS_DOUBLE && !zend_is_long_compatible(dval, zend_dval_to_lval(dval)))) { + return false; + } + } + + return true; +} + ZEND_API bool zend_binary_op_produces_error(uint32_t opcode, zval *op1, zval *op2) /* {{{ */ { if ((opcode == ZEND_CONCAT || opcode == ZEND_FAST_CONCAT)) { @@ -8210,13 +8231,7 @@ ZEND_API bool zend_binary_op_produces_error(uint32_t opcode, zval *op1, zval *op /* Operation which cast float/float-strings to integers might produce incompatible float to int errors */ if (opcode == ZEND_SL || opcode == ZEND_SR || opcode == ZEND_BW_OR || opcode == ZEND_BW_AND || opcode == ZEND_BW_XOR || opcode == ZEND_MOD) { - if (Z_TYPE_P(op1) == IS_DOUBLE || Z_TYPE_P(op2) == IS_DOUBLE) { - return true; - } - if ((Z_TYPE_P(op1) == IS_STRING && is_numeric_str_function(Z_STR_P(op1), NULL, NULL) != IS_LONG) - || (Z_TYPE_P(op2) == IS_STRING && is_numeric_str_function(Z_STR_P(op2), NULL, NULL) != IS_LONG)) { - return true; - } + return (!zend_is_op_long_compatible(op1) || !zend_is_op_long_compatible(op2)); } return 0; @@ -8238,7 +8253,7 @@ static inline bool zend_try_ct_eval_binary_op(zval *result, uint32_t opcode, zva ZEND_API bool zend_unary_op_produces_error(uint32_t opcode, zval *op) { if (opcode == ZEND_BW_NOT) { - return (Z_TYPE_P(op) <= IS_TRUE || Z_TYPE_P(op) == IS_ARRAY || Z_TYPE_P(op) == IS_DOUBLE); + return (Z_TYPE_P(op) <= IS_TRUE || Z_TYPE_P(op) == IS_ARRAY || !zend_is_op_long_compatible(op)); } return 0; diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 61f76e84830ce..76405a3689dc9 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -1162,6 +1162,7 @@ END_EXTERN_C() /* The default value for CG(compiler_options) during eval() */ #define ZEND_COMPILE_DEFAULT_FOR_EVAL 0 +ZEND_API bool zend_is_op_long_compatible(zval *op); ZEND_API bool zend_binary_op_produces_error(uint32_t opcode, zval *op1, zval *op2); ZEND_API bool zend_unary_op_produces_error(uint32_t opcode, zval *op); From c43412ecfd9e719a072fae99507fd3e8965d1452 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Thu, 27 May 2021 17:13:02 +0100 Subject: [PATCH 46/61] Revert "Revert test change from 32bit" Mark test as XFAIL as I don't understand why this doens't generate a warning on 64bits This reverts commit 75c008a20c19c15028e4e3d8b7366efd5ef42f5c. --- tests/lang/bug27354.phpt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/lang/bug27354.phpt b/tests/lang/bug27354.phpt index 34dd9e90d429a..05ea65c25f723 100644 --- a/tests/lang/bug27354.phpt +++ b/tests/lang/bug27354.phpt @@ -1,5 +1,7 @@ --TEST-- Bug #27354 (Modulus operator crashes PHP) +--XFAIL-- +This doesn't produce a warning on 64bits strangely --FILE-- ---EXPECT-- +--EXPECTF-- int(0) + +Deprecated: Implicit conversion from non-compatible float -9.223372036854776E+18 to int in %s on line %d int(0) int(0) int(0) From da449b63f2573c34c548009878d83645cba62e7a Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Thu, 27 May 2021 17:32:42 +0100 Subject: [PATCH 47/61] Use a lower float value --- tests/lang/bug27354.phpt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/lang/bug27354.phpt b/tests/lang/bug27354.phpt index 05ea65c25f723..092bf831f578e 100644 --- a/tests/lang/bug27354.phpt +++ b/tests/lang/bug27354.phpt @@ -1,18 +1,16 @@ --TEST-- Bug #27354 (Modulus operator crashes PHP) ---XFAIL-- -This doesn't produce a warning on 64bits strangely --FILE-- --EXPECTF-- int(0) -Deprecated: Implicit conversion from non-compatible float -9.223372036854776E+18 to int in %s on line %d +Deprecated: Implicit conversion from non-compatible float -9.223372036860776E+18 to int in %s on line %d int(0) int(0) int(0) From 843e7f11ae78a089b867e85526146e159966bf1d Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Fri, 28 May 2021 00:23:32 +0100 Subject: [PATCH 48/61] Hopefully fix Win test --- ext/standard/tests/file/ftruncate_variation3-win32.phpt | 2 +- ext/standard/tests/file/ftruncate_variation3.phpt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/standard/tests/file/ftruncate_variation3-win32.phpt b/ext/standard/tests/file/ftruncate_variation3-win32.phpt index 33d7a7d7cdd09..eeabda490099d 100644 --- a/ext/standard/tests/file/ftruncate_variation3-win32.phpt +++ b/ext/standard/tests/file/ftruncate_variation3-win32.phpt @@ -47,7 +47,7 @@ foreach($file_content_types as $file_content_type) { echo "-- Testing ftruncate(): truncate file to half of its current size --\n"; /* truncate it to half of its current size */ - $new_size = (int)filesize($filename)/2; + $new_size = (int)(filesize($filename)/2); var_dump( filesize($filename) ); // current filesize var_dump( ftell($file_handle) ); var_dump( ftruncate($file_handle, $new_size) ); // truncate it diff --git a/ext/standard/tests/file/ftruncate_variation3.phpt b/ext/standard/tests/file/ftruncate_variation3.phpt index 4aa939f346d07..61658e95b91ac 100644 --- a/ext/standard/tests/file/ftruncate_variation3.phpt +++ b/ext/standard/tests/file/ftruncate_variation3.phpt @@ -47,7 +47,7 @@ foreach($file_content_types as $file_content_type) { echo "-- Testing ftruncate(): truncate file to half of its current size --\n"; /* truncate it to half of its current size */ - $new_size = filesize($filename)/2; + $new_size = (int)(filesize($filename)/2); var_dump( filesize($filename) ); // current filesize var_dump( ftell($file_handle) ); var_dump( ftruncate($file_handle, $new_size) ); // truncate it From de37806a9560f53823d75ac435787dc640b7c90e Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sat, 29 May 2021 02:25:10 +0100 Subject: [PATCH 49/61] Move IS_ARRAY check to is_op_long_compatible Test tbd --- Zend/zend_compile.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index ef8acbe871dcd..e4966330fcd97 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -8158,8 +8158,9 @@ static bool zend_try_ct_eval_magic_const(zval *zv, zend_ast *ast) /* {{{ */ ZEND_API bool zend_is_op_long_compatible(zval *op) { - /* This is handled before */ - ZEND_ASSERT(Z_TYPE_P(op) != IS_ARRAY); + if (Z_TYPE_P(op) == IS_ARRAY) { + return false; + } if (Z_TYPE_P(op) == IS_DOUBLE && !zend_is_long_compatible(Z_DVAL_P(op), zend_dval_to_lval(Z_DVAL_P(op)))) { @@ -8253,7 +8254,7 @@ static inline bool zend_try_ct_eval_binary_op(zval *result, uint32_t opcode, zva ZEND_API bool zend_unary_op_produces_error(uint32_t opcode, zval *op) { if (opcode == ZEND_BW_NOT) { - return (Z_TYPE_P(op) <= IS_TRUE || Z_TYPE_P(op) == IS_ARRAY || !zend_is_op_long_compatible(op)); + return (Z_TYPE_P(op) <= IS_TRUE || !zend_is_op_long_compatible(op)); } return 0; From 95eae55559518fc52d0658226c41748b48e5ad81 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sat, 29 May 2021 02:26:25 +0100 Subject: [PATCH 50/61] Remove redundant parens --- Zend/zend_compile.c | 4 ++-- Zend/zend_operators.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index e4966330fcd97..ac97499e90bc5 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -8232,7 +8232,7 @@ ZEND_API bool zend_binary_op_produces_error(uint32_t opcode, zval *op1, zval *op /* Operation which cast float/float-strings to integers might produce incompatible float to int errors */ if (opcode == ZEND_SL || opcode == ZEND_SR || opcode == ZEND_BW_OR || opcode == ZEND_BW_AND || opcode == ZEND_BW_XOR || opcode == ZEND_MOD) { - return (!zend_is_op_long_compatible(op1) || !zend_is_op_long_compatible(op2)); + return !zend_is_op_long_compatible(op1) || !zend_is_op_long_compatible(op2); } return 0; @@ -8254,7 +8254,7 @@ static inline bool zend_try_ct_eval_binary_op(zval *result, uint32_t opcode, zva ZEND_API bool zend_unary_op_produces_error(uint32_t opcode, zval *op) { if (opcode == ZEND_BW_NOT) { - return (Z_TYPE_P(op) <= IS_TRUE || !zend_is_op_long_compatible(op)); + return Z_TYPE_P(op) <= IS_TRUE || !zend_is_op_long_compatible(op); } return 0; diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index 85a84408b8b5a..5a01dd0b75d11 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -135,7 +135,7 @@ static zend_always_inline zend_long zend_dval_to_lval_cap(double d) /* }}} */ static zend_always_inline bool zend_is_long_compatible(double d, zend_long l) { - return ((double)l == d); + return (double)l == d; } ZEND_API void zend_incompatible_double_to_long_error(double d); From 8befb026ddf14b6e182c95d9982aacc52eb2cc1e Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sat, 29 May 2021 02:27:34 +0100 Subject: [PATCH 51/61] Remove obsolete TODO comment --- Zend/zend_vm_def.h | 1 - Zend/zend_vm_execute.h | 3 --- 2 files changed, 4 deletions(-) diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index f0d53759b3358..a01f2c418aebd 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -9041,7 +9041,6 @@ ZEND_VM_COLD_CONST_HANDLER(190, ZEND_COUNT, CONST|TMPVAR|CV, UNUSED) zval retval; zend_call_method_with_0_params(zobj, NULL, NULL, "count", &retval); - // TODO Should this use zval_get_long_ex(&retval, /* is_strict */ false); count = zval_get_long(&retval); zval_ptr_dtor(&retval); break; diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 3e4e3dd35d598..70ebf54b4eeac 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -10541,7 +10541,6 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_CONST_ zval retval; zend_call_method_with_0_params(zobj, NULL, NULL, "count", &retval); - // TODO Should this use zval_get_long_ex(&retval, /* is_strict */ false); count = zval_get_long(&retval); zval_ptr_dtor(&retval); break; @@ -17796,7 +17795,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_TMPVAR_UNUSED_HANDL zval retval; zend_call_method_with_0_params(zobj, NULL, NULL, "count", &retval); - // TODO Should this use zval_get_long_ex(&retval, /* is_strict */ false); count = zval_get_long(&retval); zval_ptr_dtor(&retval); break; @@ -47559,7 +47557,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_CV_UNUSED_HANDLER(Z zval retval; zend_call_method_with_0_params(zobj, NULL, NULL, "count", &retval); - // TODO Should this use zval_get_long_ex(&retval, /* is_strict */ false); count = zval_get_long(&retval); zval_ptr_dtor(&retval); break; From da2d7cf29d5b0e6e8ff2f45553e183520ac6bba1 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sat, 29 May 2021 02:32:12 +0100 Subject: [PATCH 52/61] Cast to string instead of int in mysqli test --- ext/mysqli/tests/mysqli_stmt_bind_result_format.phpt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/mysqli/tests/mysqli_stmt_bind_result_format.phpt b/ext/mysqli/tests/mysqli_stmt_bind_result_format.phpt index 93e0b4313d8b4..a2dc488e577dc 100644 --- a/ext/mysqli/tests/mysqli_stmt_bind_result_format.phpt +++ b/ext/mysqli/tests/mysqli_stmt_bind_result_format.phpt @@ -227,7 +227,7 @@ memory_limit=83886080 $current_targets = mt_rand(-100000, 100000) / 10; do { $trend = (mt_rand(0, 3) > 1) ? (mt_rand(-10000, 10000) / 100) : 'NULL'; - } while (isset($values[(int)$trend])); + } while (isset($values[(string)$trend])); $sql = sprintf('INSERT INTO test(targetport, current_targets, maxreports, trend) VALUES (%d, %f, %s, %s)', $i, @@ -239,7 +239,7 @@ memory_limit=83886080 break 2; } if ($current_targets > 0 && $trend !== 'NULL') - $values[(int)$trend] = $i; + $values[(string)$trend] = $i; } krsort($values); From 3fe78018aa763a651c09c92a1b5c6c5bc1c8a2f4 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sat, 29 May 2021 02:38:07 +0100 Subject: [PATCH 53/61] Amend array tests --- .../tests/array/array_combine_variation4.phpt | 8 +- ext/standard/tests/array/array_fill.phpt | 136 +++++------------- .../array_intersect_assoc_variation5.phpt | 8 +- .../array_intersect_assoc_variation6.phpt | 8 +- .../array/array_intersect_variation5.phpt | 16 +-- .../array/array_intersect_variation6.phpt | 16 +-- .../tests/array/array_map_variation4.phpt | 8 +- .../tests/array/array_reverse_variation4.phpt | 20 +-- .../tests/array/array_unshift_variation4.phpt | 16 +-- .../tests/array/usort_variation3.phpt | 6 +- 10 files changed, 65 insertions(+), 177 deletions(-) diff --git a/ext/standard/tests/array/array_combine_variation4.phpt b/ext/standard/tests/array/array_combine_variation4.phpt index 511c114de2b3e..1ff6b64f175e5 100644 --- a/ext/standard/tests/array/array_combine_variation4.phpt +++ b/ext/standard/tests/array/array_combine_variation4.phpt @@ -52,7 +52,7 @@ $arrays = array ( // array with mixed keys /*11*/ array('hello' => 1, "fruit" => 2.2, - $fp => 'resource', 133 => "int", 444.432 => "float", + $fp => 'resource', 133 => "int", @$unset_var => "unset", $heredoc => "heredoc") ); @@ -81,8 +81,6 @@ echo "Done"; Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 444.432 to int in %s on line %d -- Iteration 1 -- array(0) { } @@ -144,7 +142,7 @@ array(2) { string(8) "resource" } -- Iteration 9 -- -array(7) { +array(6) { [1]=> int(1) ["2.2"]=> @@ -153,8 +151,6 @@ array(7) { string(8) "resource" ["int"]=> string(3) "int" - ["float"]=> - string(5) "float" ["unset"]=> string(5) "unset" ["heredoc"]=> diff --git a/ext/standard/tests/array/array_fill.phpt b/ext/standard/tests/array/array_fill.phpt index 5f82fc25f772b..cfc2126d49d67 100644 --- a/ext/standard/tests/array/array_fill.phpt +++ b/ext/standard/tests/array/array_fill.phpt @@ -2,7 +2,7 @@ basic array_fill test --FILE-- ---EXPECTF-- +--EXPECT-- =========================== bool(true) start: 0 num: 0 value: array(0) { @@ -81,9 +81,7 @@ start: 0 num: 1 value: array(1) { } =========================== bool(true) -start: 0 num: 2.5 value: -Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d -array(2) { +start: 0 num: 2 value: array(2) { [0]=> bool(true) [1]=> @@ -91,9 +89,7 @@ array(2) { } =========================== bool(false) -start: 0 num: 2.5 value: -Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d -array(2) { +start: 0 num: 2 value: array(2) { [0]=> bool(false) [1]=> @@ -101,9 +97,7 @@ array(2) { } =========================== NULL -start: 0 num: 2.5 value: -Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d -array(2) { +start: 0 num: 2 value: array(2) { [0]=> NULL [1]=> @@ -111,9 +105,7 @@ array(2) { } =========================== string(1) "d" -start: 0 num: 2.5 value: -Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d -array(2) { +start: 0 num: 2 value: array(2) { [0]=> string(1) "d" [1]=> @@ -121,9 +113,7 @@ array(2) { } =========================== string(1) "e" -start: 0 num: 2.5 value: -Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d -array(2) { +start: 0 num: 2 value: array(2) { [0]=> string(1) "e" [1]=> @@ -131,9 +121,7 @@ array(2) { } =========================== string(1) "f" -start: 0 num: 2.5 value: -Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d -array(2) { +start: 0 num: 2 value: array(2) { [0]=> string(1) "f" [1]=> @@ -201,9 +189,7 @@ start: 1 num: 1 value: array(1) { } =========================== bool(true) -start: 1 num: 2.5 value: -Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d -array(2) { +start: 1 num: 2 value: array(2) { [1]=> bool(true) [2]=> @@ -211,9 +197,7 @@ array(2) { } =========================== bool(false) -start: 1 num: 2.5 value: -Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d -array(2) { +start: 1 num: 2 value: array(2) { [1]=> bool(false) [2]=> @@ -221,9 +205,7 @@ array(2) { } =========================== NULL -start: 1 num: 2.5 value: -Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d -array(2) { +start: 1 num: 2 value: array(2) { [1]=> NULL [2]=> @@ -231,9 +213,7 @@ array(2) { } =========================== string(1) "d" -start: 1 num: 2.5 value: -Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d -array(2) { +start: 1 num: 2 value: array(2) { [1]=> string(1) "d" [2]=> @@ -241,9 +221,7 @@ array(2) { } =========================== string(1) "e" -start: 1 num: 2.5 value: -Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d -array(2) { +start: 1 num: 2 value: array(2) { [1]=> string(1) "e" [2]=> @@ -251,9 +229,7 @@ array(2) { } =========================== string(1) "f" -start: 1 num: 2.5 value: -Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d -array(2) { +start: 1 num: 2 value: array(2) { [1]=> string(1) "f" [2]=> @@ -261,95 +237,67 @@ array(2) { } =========================== bool(true) -start: 2.5 num: 0 value: -Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d -array(0) { +start: 2 num: 0 value: array(0) { } =========================== bool(false) -start: 2.5 num: 0 value: -Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d -array(0) { +start: 2 num: 0 value: array(0) { } =========================== NULL -start: 2.5 num: 0 value: -Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d -array(0) { +start: 2 num: 0 value: array(0) { } =========================== string(1) "d" -start: 2.5 num: 0 value: -Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d -array(0) { +start: 2 num: 0 value: array(0) { } =========================== string(1) "e" -start: 2.5 num: 0 value: -Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d -array(0) { +start: 2 num: 0 value: array(0) { } =========================== string(1) "f" -start: 2.5 num: 0 value: -Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d -array(0) { +start: 2 num: 0 value: array(0) { } =========================== bool(true) -start: 2.5 num: 1 value: -Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d -array(1) { +start: 2 num: 1 value: array(1) { [2]=> bool(true) } =========================== bool(false) -start: 2.5 num: 1 value: -Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d -array(1) { +start: 2 num: 1 value: array(1) { [2]=> bool(false) } =========================== NULL -start: 2.5 num: 1 value: -Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d -array(1) { +start: 2 num: 1 value: array(1) { [2]=> NULL } =========================== string(1) "d" -start: 2.5 num: 1 value: -Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d -array(1) { +start: 2 num: 1 value: array(1) { [2]=> string(1) "d" } =========================== string(1) "e" -start: 2.5 num: 1 value: -Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d -array(1) { +start: 2 num: 1 value: array(1) { [2]=> string(1) "e" } =========================== string(1) "f" -start: 2.5 num: 1 value: -Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d -array(1) { +start: 2 num: 1 value: array(1) { [2]=> string(1) "f" } =========================== bool(true) -start: 2.5 num: 2.5 value: -Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d -array(2) { +start: 2 num: 2 value: array(2) { [2]=> bool(true) [3]=> @@ -357,11 +305,7 @@ array(2) { } =========================== bool(false) -start: 2.5 num: 2.5 value: -Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d -array(2) { +start: 2 num: 2 value: array(2) { [2]=> bool(false) [3]=> @@ -369,11 +313,7 @@ array(2) { } =========================== NULL -start: 2.5 num: 2.5 value: -Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d -array(2) { +start: 2 num: 2 value: array(2) { [2]=> NULL [3]=> @@ -381,11 +321,7 @@ array(2) { } =========================== string(1) "d" -start: 2.5 num: 2.5 value: -Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d -array(2) { +start: 2 num: 2 value: array(2) { [2]=> string(1) "d" [3]=> @@ -393,11 +329,7 @@ array(2) { } =========================== string(1) "e" -start: 2.5 num: 2.5 value: -Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d -array(2) { +start: 2 num: 2 value: array(2) { [2]=> string(1) "e" [3]=> @@ -405,11 +337,7 @@ array(2) { } =========================== string(1) "f" -start: 2.5 num: 2.5 value: -Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d -array(2) { +start: 2 num: 2 value: array(2) { [2]=> string(1) "f" [3]=> diff --git a/ext/standard/tests/array/array_intersect_assoc_variation5.phpt b/ext/standard/tests/array/array_intersect_assoc_variation5.phpt index bceffb9f765e5..65ce1dae17d13 100644 --- a/ext/standard/tests/array/array_intersect_assoc_variation5.phpt +++ b/ext/standard/tests/array/array_intersect_assoc_variation5.phpt @@ -42,11 +42,11 @@ $arrays = array ( // array with mixed keys /*11*/ array('hello' => 1, "fruit" => 2.2, - 133 => "int", 444.432 => "float", + 133 => "int", @$unset_var => "unset", $heredoc => "heredoc") ); -// array to be passsed to $arr2 argument +// array to be passed to $arr2 argument $arr2 = array(0 => 0, 2 => "float", 4 => "f3", 33333333 => "f4", "\tHello" => 111, 2.2, 'color', "Hello world" => "string", "pen\n" => 33, 133 => "int"); @@ -67,10 +67,8 @@ foreach($arrays as $arr1) { echo "Done"; ?> ---EXPECTF-- +--EXPECT-- *** Testing array_intersect_assoc() : assoc array with diff keys to $arr1 argument *** - -Deprecated: Implicit conversion from non-compatible float 444.432 to int in %s on line %d -- Iteration 1 -- array(0) { } diff --git a/ext/standard/tests/array/array_intersect_assoc_variation6.phpt b/ext/standard/tests/array/array_intersect_assoc_variation6.phpt index e2b048ed741a3..f446c6870419d 100644 --- a/ext/standard/tests/array/array_intersect_assoc_variation6.phpt +++ b/ext/standard/tests/array/array_intersect_assoc_variation6.phpt @@ -42,11 +42,11 @@ $arrays = array ( // array with mixed keys /*11*/ array('hello' => 1, "fruit" => 2.2, - 133 => "int", 444.432 => "float", + 133 => "int", @$unset_var => "unset", $heredoc => "heredoc") ); -// array to be passsed to $arr1 argument +// array to be passed to $arr1 argument $arr1 = array(0 => 0, 2 => "float", 4 => "f3", 33333333 => "f4", "\tHello" => 111, 2.2, 'color', "Hello world" => "string", "pen\n" => 33, 133 => "int"); @@ -67,10 +67,8 @@ foreach($arrays as $arr2) { echo "Done"; ?> ---EXPECTF-- +--EXPECT-- *** Testing array_intersect_assoc() : assoc array with diff keys to $arr2 argument *** - -Deprecated: Implicit conversion from non-compatible float 444.432 to int in %s on line %d -- Iteration 1 -- array(0) { } diff --git a/ext/standard/tests/array/array_intersect_variation5.phpt b/ext/standard/tests/array/array_intersect_variation5.phpt index 92405c42dae2f..12edea88196e6 100644 --- a/ext/standard/tests/array/array_intersect_variation5.phpt +++ b/ext/standard/tests/array/array_intersect_variation5.phpt @@ -42,11 +42,11 @@ $arrays = array ( // array with mixed keys /*11*/ array('hello' => 1, "fruit" => 2.2, - 133 => "int", 444.432 => "float", + 133 => "int", @$unset_var => "unset", $heredoc => "heredoc") ); -// array to be passsed to $arr2 argument +// array to be passed to $arr2 argument $arr2 = array(1, "float", "f4", "hello", 2.2, 'color', "string", "pen\n", 11); // loop through each sub-array within $arrays to check the behavior of array_intersect() @@ -65,10 +65,8 @@ foreach($arrays as $arr1) { echo "Done"; ?> ---EXPECTF-- +--EXPECT-- *** Testing array_intersect() : assoc array with diff keys to $arr1 argument *** - -Deprecated: Implicit conversion from non-compatible float 444.432 to int in %s on line %d -- Iterator 1 -- array(0) { } @@ -146,20 +144,16 @@ array(1) { string(5) "hello" } -- Iterator 9 -- -array(3) { +array(2) { ["hello"]=> int(1) ["fruit"]=> float(2.2) - [444]=> - string(5) "float" } -array(3) { +array(2) { ["hello"]=> int(1) ["fruit"]=> float(2.2) - [444]=> - string(5) "float" } Done diff --git a/ext/standard/tests/array/array_intersect_variation6.phpt b/ext/standard/tests/array/array_intersect_variation6.phpt index 7f598cd0578d7..93ff4271d70a9 100644 --- a/ext/standard/tests/array/array_intersect_variation6.phpt +++ b/ext/standard/tests/array/array_intersect_variation6.phpt @@ -42,11 +42,11 @@ $arrays = array ( // array with mixed keys /*11*/ array('hello' => 1, "fruit" => 2.2, - 133 => "int", 444.432 => "float", + 133 => "int", @$unset_var => "unset", $heredoc => "heredoc") ); -// array to be passsed to $arr1 argument +// array to be passed to $arr1 argument $arr1 = array(1, "float", "f4", "hello", 2.2, 'color', "string", "pen\n", 11); // loop through each sub-array within $arrays to check the behavior of array_intersect() @@ -65,10 +65,8 @@ foreach($arrays as $arr2) { echo "Done"; ?> ---EXPECTF-- +--EXPECT-- *** Testing array_intersect() : assoc array with diff keys to $arr2 argument *** - -Deprecated: Implicit conversion from non-compatible float 444.432 to int in %s on line %d -- Iterator 1 -- array(0) { } @@ -146,19 +144,15 @@ array(1) { string(5) "hello" } -- Iterator 9 -- -array(3) { +array(2) { [0]=> int(1) - [1]=> - string(5) "float" [4]=> float(2.2) } -array(3) { +array(2) { [0]=> int(1) - [1]=> - string(5) "float" [4]=> float(2.2) } diff --git a/ext/standard/tests/array/array_map_variation4.phpt b/ext/standard/tests/array/array_map_variation4.phpt index a8f3ec51193de..4d6269b3617db 100644 --- a/ext/standard/tests/array/array_map_variation4.phpt +++ b/ext/standard/tests/array/array_map_variation4.phpt @@ -53,7 +53,7 @@ $arrays = array ( // array with mixed values /*11*/ array('hello' => 1, "fruit" => 2.2, - $fp => 'resource', 133 => "int", 444.432 => "float", + $fp => 'resource', 133 => "int", @$unset_var => "unset", $heredoc => "heredoc") ); @@ -73,8 +73,6 @@ echo "Done"; Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 444.432 to int in %s on line %d -- Iteration 1 -- array(0) { } @@ -137,7 +135,7 @@ array(2) { string(8) "resource" } -- Iteration 9 -- -array(7) { +array(6) { ["hello"]=> int(1) ["fruit"]=> @@ -146,8 +144,6 @@ array(7) { string(8) "resource" [133]=> string(3) "int" - [444]=> - string(5) "float" [""]=> string(5) "unset" ["Hello world"]=> diff --git a/ext/standard/tests/array/array_reverse_variation4.phpt b/ext/standard/tests/array/array_reverse_variation4.phpt index 84a626fbc394b..07454f5a1f261 100644 --- a/ext/standard/tests/array/array_reverse_variation4.phpt +++ b/ext/standard/tests/array/array_reverse_variation4.phpt @@ -48,7 +48,7 @@ $arrays = array ( array(@$unset_var => "hello", $fp => 'resource'), // array with mixed values -/*11*/ array('hello' => 1, "fruit" => 2.2, $fp => 'resource', 133 => "int", 444.432 => "float", @$unset_var => "unset", $heredoc => "heredoc") +/*11*/ array('hello' => 1, "fruit" => 2.2, $fp => 'resource', 133 => "int", @$unset_var => "unset", $heredoc => "heredoc") ); // loop through the various elements of $arrays to test array_reverse() @@ -77,8 +77,6 @@ echo "Done"; Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 444.432 to int in %s on line %d -- Iteration 1 -- - default argument - array(0) { @@ -275,16 +273,14 @@ array(2) { } -- Iteration 9 -- - default argument - -array(7) { +array(6) { ["Hello world"]=> string(7) "heredoc" [""]=> string(5) "unset" [0]=> - string(5) "float" - [1]=> string(3) "int" - [2]=> + [1]=> string(8) "resource" ["fruit"]=> float(2.2) @@ -292,13 +288,11 @@ array(7) { int(1) } - $preserve keys = true - -array(7) { +array(6) { ["Hello world"]=> string(7) "heredoc" [""]=> string(5) "unset" - [444]=> - string(5) "float" [133]=> string(3) "int" [5]=> @@ -309,16 +303,14 @@ array(7) { int(1) } - $preserve_keys = false - -array(7) { +array(6) { ["Hello world"]=> string(7) "heredoc" [""]=> string(5) "unset" [0]=> - string(5) "float" - [1]=> string(3) "int" - [2]=> + [1]=> string(8) "resource" ["fruit"]=> float(2.2) diff --git a/ext/standard/tests/array/array_unshift_variation4.phpt b/ext/standard/tests/array/array_unshift_variation4.phpt index 5c7d394d8ec5e..ed89e06311776 100644 --- a/ext/standard/tests/array/array_unshift_variation4.phpt +++ b/ext/standard/tests/array/array_unshift_variation4.phpt @@ -56,7 +56,7 @@ $arrays = array ( // array with mixed keys /*11*/ array('hello' => 1, "fruit" => 2.2, - $fp => 'resource', 133 => "int", 444.432 => "float", + $fp => 'resource', 133 => "int", @$unset_var => "unset", $heredoc => "heredoc") ); @@ -93,8 +93,6 @@ echo "Done"; Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 444.432 to int in %s on line %d -- Iteration 1 -- int(1) array(1) { @@ -290,8 +288,8 @@ array(5) { string(8) "resource" } -- Iteration 9 -- -int(8) -array(8) { +int(7) +array(7) { [0]=> int(10) ["hello"]=> @@ -302,15 +300,13 @@ array(8) { string(8) "resource" [2]=> string(3) "int" - [3]=> - string(5) "float" [""]=> string(5) "unset" ["Hello world"]=> string(7) "heredoc" } -int(10) -array(10) { +int(9) +array(9) { [0]=> int(10) [1]=> @@ -325,8 +321,6 @@ array(10) { string(8) "resource" [4]=> string(3) "int" - [5]=> - string(5) "float" [""]=> string(5) "unset" ["Hello world"]=> diff --git a/ext/standard/tests/array/usort_variation3.phpt b/ext/standard/tests/array/usort_variation3.phpt index 697479f0fcc7f..5478ca09abe28 100644 --- a/ext/standard/tests/array/usort_variation3.phpt +++ b/ext/standard/tests/array/usort_variation3.phpt @@ -37,7 +37,7 @@ EOT3; $array_arg = array( // numeric keys -2 => 9, - 8.9 => 8, + 8 => 8, 012 => 7, 0x34 => 6, @@ -69,10 +69,8 @@ var_dump( usort($array_arg, 'cmp_function') ); echo "\n-- Sorted array after usort() function call --\n"; var_dump($array_arg); ?> ---EXPECTF-- +--EXPECT-- *** Testing usort() : usage variation *** - -Deprecated: Implicit conversion from non-compatible float 8.9 to int in %s on line %d bool(true) -- Sorted array after usort() function call -- From e8c1c4533a2774b8efb0e2dd1fadbda4c0ed00e9 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sat, 29 May 2021 05:16:06 +0100 Subject: [PATCH 54/61] Revert printf changes (do not warn) --- ext/standard/formatted_print.c | 16 +- .../tests/strings/bug23894_32bit.phpt | 5 +- .../tests/strings/bug23894_64bit.phpt | 5 +- ext/standard/tests/strings/bug47842.phpt | 4 +- .../tests/strings/fprintf_variation_002.phpt | 164 +++---- .../strings/fprintf_variation_003_64bit.phpt | 10 +- .../strings/fprintf_variation_006_64bit.phpt | 10 +- .../strings/fprintf_variation_007_64bit.phpt | 10 +- .../strings/fprintf_variation_008_64bit.phpt | 10 +- ext/standard/tests/strings/printf_64bit.phpt | 457 +++++++----------- ext/standard/tests/strings/sprintf_f_2.phpt | 18 +- .../tests/strings/vprintf_variation15.phpt | 10 +- .../strings/vprintf_variation15_64bit.phpt | 10 +- 13 files changed, 280 insertions(+), 449 deletions(-) diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c index 2854f7f572c05..07241570ff3f7 100644 --- a/ext/standard/formatted_print.c +++ b/ext/standard/formatted_print.c @@ -10,7 +10,7 @@ | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ - | Author: Stig S�ther Bakken | + | Author: Stig Söther Bakken | +----------------------------------------------------------------------+ */ @@ -634,13 +634,13 @@ php_formatted_print(char *format, size_t format_len, zval *args, int argc, int n case 'd': php_sprintf_appendint(&result, &outpos, - zval_get_long_ex(tmp, /* is_strict */ true), + zval_get_long_ex(tmp, /* is_strict */ false), width, padding, alignment, always_sign); break; case 'u': php_sprintf_appenduint(&result, &outpos, - zval_get_long_ex(tmp, /* is_strict */ true), + zval_get_long_ex(tmp, /* is_strict */ false), width, padding, alignment); break; @@ -662,30 +662,30 @@ php_formatted_print(char *format, size_t format_len, zval *args, int argc, int n case 'c': php_sprintf_appendchar(&result, &outpos, - (char) zval_get_long_ex(tmp, /* is_strict */ true)); + (char) zval_get_long_ex(tmp, /* is_strict */ false)); break; case 'o': php_sprintf_append2n(&result, &outpos, - zval_get_long_ex(tmp, /* is_strict */ true), + zval_get_long_ex(tmp, /* is_strict */ false), width, padding, alignment, 3, hexchars, expprec); break; case 'x': php_sprintf_append2n(&result, &outpos, - zval_get_long_ex(tmp, /* is_strict */ true), + zval_get_long_ex(tmp, /* is_strict */ false), width, padding, alignment, 4, hexchars, expprec); break; case 'X': php_sprintf_append2n(&result, &outpos, - zval_get_long_ex(tmp, /* is_strict */ true), + zval_get_long_ex(tmp, /* is_strict */ false), width, padding, alignment, 4, HEXCHARS, expprec); break; case 'b': php_sprintf_append2n(&result, &outpos, - zval_get_long_ex(tmp, /* is_strict */ true), + zval_get_long_ex(tmp, /* is_strict */ false), width, padding, alignment, 1, hexchars, expprec); break; diff --git a/ext/standard/tests/strings/bug23894_32bit.phpt b/ext/standard/tests/strings/bug23894_32bit.phpt index 58b74722b9764..d2d33f8e67933 100644 --- a/ext/standard/tests/strings/bug23894_32bit.phpt +++ b/ext/standard/tests/strings/bug23894_32bit.phpt @@ -12,11 +12,8 @@ var_dump($test, bin2hex($test)); $test = sprintf("% 13u", $a); var_dump($test, bin2hex($test)); ?> ---EXPECTF-- -Deprecated: Implicit conversion from non-compatible float -12.3456 to int in %s on line %d +--EXPECT-- string(4) "-012" string(8) "2d303132" - -Deprecated: Implicit conversion from non-compatible float -12.3456 to int in %s on line %d string(13) " 4294967284" string(26) "20202034323934393637323834" diff --git a/ext/standard/tests/strings/bug23894_64bit.phpt b/ext/standard/tests/strings/bug23894_64bit.phpt index 9719d68e56a55..3ae5ea663271b 100644 --- a/ext/standard/tests/strings/bug23894_64bit.phpt +++ b/ext/standard/tests/strings/bug23894_64bit.phpt @@ -12,11 +12,8 @@ var_dump($test, bin2hex($test)); $test = sprintf("% 13u", $a); var_dump($test, bin2hex($test)); ?> ---EXPECTF-- -Deprecated: Implicit conversion from non-compatible float -12.3456 to int in %s on line %d +--EXPECT-- string(4) "-012" string(8) "2d303132" - -Deprecated: Implicit conversion from non-compatible float -12.3456 to int in %s on line %d string(20) "18446744073709551604" string(40) "3138343436373434303733373039353531363034" diff --git a/ext/standard/tests/strings/bug47842.phpt b/ext/standard/tests/strings/bug47842.phpt index 600ea2cc001a2..fe97308ea53a7 100644 --- a/ext/standard/tests/strings/bug47842.phpt +++ b/ext/standard/tests/strings/bug47842.phpt @@ -23,14 +23,12 @@ printf("printf 64-bit signed int '18446744073709551615' (2^64)-1 = %u\n", 184467 echo "Done\n"; ?> ---EXPECTF-- +--EXPECT-- -Test sscanf 32-bit signed int '2147483647' (2^31)-1 = 2147483647 sscanf 32-bit unsign int '4294967295' (2^32)-1 = 4294967295 sscanf 64-bit signed int '9223372036854775807' (2^63)-1 = 9223372036854775807 sscanf 64-bit unsign int '18446744073709551615' (2^64)-1 = 18446744073709551615 printf 64-bit signed int '9223372036854775807' (2^63)-1 = 9223372036854775807 - -Deprecated: Implicit conversion from non-compatible float 1.8446744073709552E+19 to int in %s on line %d printf 64-bit signed int '18446744073709551615' (2^64)-1 = 0 Done diff --git a/ext/standard/tests/strings/fprintf_variation_002.phpt b/ext/standard/tests/strings/fprintf_variation_002.phpt index 50a6e60dfcfe7..29eea7c416fc9 100644 --- a/ext/standard/tests/strings/fprintf_variation_002.phpt +++ b/ext/standard/tests/strings/fprintf_variation_002.phpt @@ -3,7 +3,7 @@ Test fprintf() function (variation - 2) --FILE-- ---EXPECTF-- -Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d - +--EXPECT-- *** Testing fprintf() with integers *** -- Iteration 1 -- -0 -1 --1 -2 --2 -23333333 --23333333 -1234 +"0" +"1" +"-1" +"2" +"-2" +"23333333" +"-23333333" +"1234" -- Iteration 2 -- -0 -1 --1 -2 --2 -23333333 --23333333 -1234 +"0" +"1" +"-1" +"2" +"-2" +"23333333" +"-23333333" +"1234" -- Iteration 3 -- -+0 -+1 --1 -+2 --2 -+23333333 --23333333 -+1234 +"+0" +"+1" +"-1" +"+2" +"-2" +"+23333333" +"-23333333" +"+1234" -- Iteration 4 -- - 0 - 1 - -1 - 2 - -2 -23333333 --23333333 - 1234 +" 0" +" 1" +" -1" +" 2" +" -2" +"23333333" +"-23333333" +" 1234" -- Iteration 5 -- -0 -1 --1 -2 --2 -23333333 --23333333 -1234 +"0 " +"1 " +"-1 " +"2 " +"-2 " +"23333333" +"-23333333" +"1234 " -- Iteration 6 -- -0000000 -0000001 --000001 -0000002 --000002 -23333333 --23333333 -0001234 +"0000000" +"0000001" +"-000001" +"0000002" +"-000002" +"23333333" +"-23333333" +"0001234" -- Iteration 7 -- -0 -1 --1 -2 --2 -23333333 --23333333 -1234 +"0 " +"1 " +"-1 " +"2 " +"-2 " +"23333333" +"-23333333" +"1234 " -- Iteration 8 -- -######0 -######1 -#####-1 -######2 -#####-2 -23333333 --23333333 -###1234 +"######0" +"######1" +"#####-1" +"######2" +"#####-2" +"23333333" +"-23333333" +"###1234" Done diff --git a/ext/standard/tests/strings/fprintf_variation_003_64bit.phpt b/ext/standard/tests/strings/fprintf_variation_003_64bit.phpt index bab9669fc395f..772704f47985f 100644 --- a/ext/standard/tests/strings/fprintf_variation_003_64bit.phpt +++ b/ext/standard/tests/strings/fprintf_variation_003_64bit.phpt @@ -7,7 +7,7 @@ if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); --FILE-- ---EXPECTF-- -Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d - +--EXPECT-- *** Testing fprintf() with binary *** 0 1 1111111111111111111111111111111111111111111111111111111111111111 -10 -1111111111111111111111111111111111111111111111111111111111111110 1011001000000100111010101 1111111111111111111111111111111111111110100110111111011000101011 10011010010 diff --git a/ext/standard/tests/strings/fprintf_variation_006_64bit.phpt b/ext/standard/tests/strings/fprintf_variation_006_64bit.phpt index d97477bc2d53d..6ebf7b8691f81 100644 --- a/ext/standard/tests/strings/fprintf_variation_006_64bit.phpt +++ b/ext/standard/tests/strings/fprintf_variation_006_64bit.phpt @@ -7,7 +7,7 @@ if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); --FILE-- ---EXPECTF-- -Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d - +--EXPECT-- *** Testing fprintf() for unsigned integers *** 0 1 18446744073709551615 -2 -18446744073709551614 23333333 18446744073686218283 1234 diff --git a/ext/standard/tests/strings/fprintf_variation_007_64bit.phpt b/ext/standard/tests/strings/fprintf_variation_007_64bit.phpt index 71ab3920a356b..64364d1d755dd 100644 --- a/ext/standard/tests/strings/fprintf_variation_007_64bit.phpt +++ b/ext/standard/tests/strings/fprintf_variation_007_64bit.phpt @@ -7,7 +7,7 @@ if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); --FILE-- ---EXPECTF-- -Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d - +--EXPECT-- *** Testing fprintf() for octals *** 0 1 1777777777777777777777 -2 -1777777777777777777776 131004725 1777777777777646773053 2322 diff --git a/ext/standard/tests/strings/fprintf_variation_008_64bit.phpt b/ext/standard/tests/strings/fprintf_variation_008_64bit.phpt index de6c713678e53..4fa8a881d44ce 100644 --- a/ext/standard/tests/strings/fprintf_variation_008_64bit.phpt +++ b/ext/standard/tests/strings/fprintf_variation_008_64bit.phpt @@ -8,7 +8,7 @@ if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); ---EXPECTF-- -Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d - +--EXPECT-- *** Testing fprintf() for hexadecimals *** 0 1 ffffffffffffffff -2 -fffffffffffffffe 16409d5 fffffffffe9bf62b 4d2 diff --git a/ext/standard/tests/strings/printf_64bit.phpt b/ext/standard/tests/strings/printf_64bit.phpt index 54ac251fb28a3..414c2844ae68b 100644 --- a/ext/standard/tests/strings/printf_64bit.phpt +++ b/ext/standard/tests/strings/printf_64bit.phpt @@ -2,9 +2,7 @@ Test printf() function (64bit) --SKIPIF-- 2147483647)) { - die("skip 64bit test only"); -} +if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); ?> --INI-- precision=14 @@ -13,15 +11,15 @@ precision=14 /* Various input arrays for different format types */ -$float_variation = array( "%f", "%-f", "%+f", "%7.2f", "%-7.2f", "%07.2f", "%-07.2f", "%'#7.2f" ); +$float_variation = array( "'%f'", "'%-f'", "'%+f'", "'%7.2f'", "'%-7.2f'", "'%07.2f'", "'%-07.2f'", "'%'#7.2f'" ); $float_numbers = array( 0, 1, -1, 0.32, -0.32, 3.4. -3.4, 2.54, -2.54, 1.2345678e99, -1.2345678e99 ); -$int_variation = array( "%d", "%-d", "%+d", "%7.2d", "%-7.2d", "%07.2d", "%-07.2d", "%'#7.2d" ); -$int_numbers = array( 0, 1, -1, 2.7, -2.7, 23333333, -23333333, "1234" ); +$int_variation = array( "'%d'", "'%-d'", "'%+d'", "'%7.2d'", "'%-7.2d'", "'%07.2d'", "'%-07.2d'", "'%'#7.2d'" ); +$int_numbers = array( 0, 1, -1, 23333333, -23333333, "1234" ); -$char_variation = array( 'a', "a", 67, -67, 99 ); +$char_variation = array( 'a', "a", 67, -150 /* j */, 99 ); -$string_variation = array( "%5s", "%-5s", "%05s", "%'#5s" ); +$string_variation = array( "'%5s'", "'%-5s'", "'%05s'", "'%'#5s'" ); $strings = array( NULL, "abc", 'aaa' ); /* Checking warning messages */ @@ -101,7 +99,7 @@ print_r($int_numbers); } -/* Chararter type variations */ +/* Character type variations */ echo "\n\n*** Output for char type ***\n"; echo "\n Input Characters variation array is:\n"; print_r($char_variation); @@ -159,9 +157,9 @@ foreach( $int_numbers as $hexa_num ) /* String type variations */ echo "\n\n*** Output for string type ***\n"; echo "\n Input Strings format variation array is:\n"; -print_r($string_variation); +var_dump($string_variation); echo "\n Input strings variation array is:\n"; -print_r($strings); +var_dump($strings); foreach( $string_variation as $string_var ) { @@ -259,100 +257,100 @@ Array Float Iteration 1 -0.000000 -1.000000 --1.000000 -0.320000 --0.320000 -3.400000 -2.540000 --2.540000 -1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000 --1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000 +'0.000000' +'1.000000' +'-1.000000' +'0.320000' +'-0.320000' +'3.400000' +'2.540000' +'-2.540000' +'1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000' +'-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000' Float Iteration 2 -0.000000 -1.000000 --1.000000 -0.320000 --0.320000 -3.400000 -2.540000 --2.540000 -1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000 --1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000 +'0.000000' +'1.000000' +'-1.000000' +'0.320000' +'-0.320000' +'3.400000' +'2.540000' +'-2.540000' +'1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000' +'-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000' Float Iteration 3 -+0.000000 -+1.000000 --1.000000 -+0.320000 --0.320000 -+3.400000 -+2.540000 --2.540000 -+1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000 --1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000 +'+0.000000' +'+1.000000' +'-1.000000' +'+0.320000' +'-0.320000' +'+3.400000' +'+2.540000' +'-2.540000' +'+1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000' +'-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000' Float Iteration 4 - 0.00 - 1.00 - -1.00 - 0.32 - -0.32 - 3.40 - 2.54 - -2.54 -1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00 --1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00 +' 0.00' +' 1.00' +' -1.00' +' 0.32' +' -0.32' +' 3.40' +' 2.54' +' -2.54' +'1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' +'-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' Float Iteration 5 -0.00 -1.00 --1.00 -0.32 --0.32 -3.40 -2.54 --2.54 -1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00 --1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00 +'0.00 ' +'1.00 ' +'-1.00 ' +'0.32 ' +'-0.32 ' +'3.40 ' +'2.54 ' +'-2.54 ' +'1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' +'-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' Float Iteration 6 -0000.00 -0001.00 --001.00 -0000.32 --000.32 -0003.40 -0002.54 --002.54 -1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00 --1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00 +'0000.00' +'0001.00' +'-001.00' +'0000.32' +'-000.32' +'0003.40' +'0002.54' +'-002.54' +'1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' +'-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' Float Iteration 7 -0.00000 -1.00000 --1.0000 -0.32000 --0.3200 -3.40000 -2.54000 --2.5400 -1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00 --1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00 +'0.00000' +'1.00000' +'-1.0000' +'0.32000' +'-0.3200' +'3.40000' +'2.54000' +'-2.5400' +'1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' +'-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' Float Iteration 8 -###0.00 -###1.00 -##-1.00 -###0.32 -##-0.32 -###3.40 -###2.54 -##-2.54 -1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00 --1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00 +'###0.00' +'###1.00' +'##-1.00' +'###0.32' +'##-0.32' +'###3.40' +'###2.54' +'##-2.54' +'1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' +'-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' *** Output for integer type *** @@ -362,125 +360,75 @@ Array [0] => 0 [1] => 1 [2] => -1 - [3] => 2.7 - [4] => -2.7 - [5] => 23333333 - [6] => -23333333 - [7] => 1234 + [3] => 23333333 + [4] => -23333333 + [5] => 1234 ) Integer Iteration 1 -0 -1 --1 - -Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d -2 - -Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d --2 -23333333 --23333333 -1234 +'0' +'1' +'-1' +'23333333' +'-23333333' +'1234' Integer Iteration 2 -0 -1 --1 - -Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d -2 - -Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d --2 -23333333 --23333333 -1234 +'0' +'1' +'-1' +'23333333' +'-23333333' +'1234' Integer Iteration 3 -+0 -+1 --1 - -Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d -+2 - -Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d --2 -+23333333 --23333333 -+1234 +'+0' +'+1' +'-1' +'+23333333' +'-23333333' +'+1234' Integer Iteration 4 - 0 - 1 - -1 - -Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d - 2 - -Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d - -2 -23333333 --23333333 - 1234 +' 0' +' 1' +' -1' +'23333333' +'-23333333' +' 1234' Integer Iteration 5 -0 -1 --1 - -Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d -2 - -Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d --2 -23333333 --23333333 -1234 +'0 ' +'1 ' +'-1 ' +'23333333' +'-23333333' +'1234 ' Integer Iteration 6 -0000000 -0000001 --000001 - -Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d -0000002 - -Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d --000002 -23333333 --23333333 -0001234 +'0000000' +'0000001' +'-000001' +'23333333' +'-23333333' +'0001234' Integer Iteration 7 -0 -1 --1 - -Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d -2 - -Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d --2 -23333333 --23333333 -1234 +'0 ' +'1 ' +'-1 ' +'23333333' +'-23333333' +'1234 ' Integer Iteration 8 -######0 -######1 -#####-1 - -Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d -######2 - -Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d -#####-2 -23333333 --23333333 -###1234 +'######0' +'######1' +'#####-1' +'23333333' +'-23333333' +'###1234' *** Output for binary type *** @@ -490,22 +438,14 @@ Array [0] => 0 [1] => 1 [2] => -1 - [3] => 2.7 - [4] => -2.7 - [5] => 23333333 - [6] => -23333333 - [7] => 1234 + [3] => 23333333 + [4] => -23333333 + [5] => 1234 ) 0 1 1111111111111111111111111111111111111111111111111111111111111111 - -Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d -10 - -Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d -1111111111111111111111111111111111111111111111111111111111111110 1011001000000100111010101 1111111111111111111111111111111111111110100110111111011000101011 10011010010 @@ -518,14 +458,14 @@ Array [0] => a [1] => a [2] => 67 - [3] => -67 + [3] => -150 [4] => 99 ) %0 %0 C -½ +j c *** Output for scientific type *** @@ -536,18 +476,14 @@ Array [0] => 0 [1] => 1 [2] => -1 - [3] => 2.7 - [4] => -2.7 - [5] => 23333333 - [6] => -23333333 - [7] => 1234 + [3] => 23333333 + [4] => -23333333 + [5] => 1234 ) 0.000000e+0 1.000000e+0 -1.000000e+0 -2.700000e+0 --2.700000e+0 2.333333e+7 -2.333333e+7 1.234000e+3 @@ -560,22 +496,14 @@ Array [0] => 0 [1] => 1 [2] => -1 - [3] => 2.7 - [4] => -2.7 - [5] => 23333333 - [6] => -23333333 - [7] => 1234 + [3] => 23333333 + [4] => -23333333 + [5] => 1234 ) 0 1 18446744073709551615 - -Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d -2 - -Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d -18446744073709551614 23333333 18446744073686218283 1234 @@ -588,22 +516,14 @@ Array [0] => 0 [1] => 1 [2] => -1 - [3] => 2.7 - [4] => -2.7 - [5] => 23333333 - [6] => -23333333 - [7] => 1234 + [3] => 23333333 + [4] => -23333333 + [5] => 1234 ) 0 1 1777777777777777777777 - -Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d -2 - -Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d -1777777777777777777776 131004725 1777777777777646773053 2322 @@ -616,22 +536,14 @@ Array [0] => 0 [1] => 1 [2] => -1 - [3] => 2.7 - [4] => -2.7 - [5] => 23333333 - [6] => -23333333 - [7] => 1234 + [3] => 23333333 + [4] => -23333333 + [5] => 1234 ) 0 1 ffffffffffffffff - -Deprecated: Implicit conversion from non-compatible float 2.7 to int in %s on line %d -2 - -Deprecated: Implicit conversion from non-compatible float -2.7 to int in %s on line %d -fffffffffffffffe 16409d5 fffffffffe9bf62b 4d2 @@ -639,34 +551,39 @@ fffffffffe9bf62b *** Output for string type *** Input Strings format variation array is: -Array -( - [0] => %5s - [1] => %-5s - [2] => %r%%r05s - [3] => %'#5s -) +array(4) { + [0]=> + string(5) "'%5s'" + [1]=> + string(6) "'%-5s'" + [2]=> + string(6) "'%05s'" + [3]=> + string(7) "'%'#5s'" +} Input strings variation array is: -Array -( - [0] => - [1] => abc - [2] => aaa -) +array(3) { + [0]=> + NULL + [1]=> + string(3) "abc" + [2]=> + string(3) "aaa" +} - - abc - aaa - -abc -aaa -00000 -00abc -00aaa -##### -##abc -##aaa +' ' +' abc' +' aaa' +' ' +'abc ' +'aaa ' +'00000' +'00abc' +'00aaa' +'#####' +'##abc' +'##aaa' *** Output for '%g' type *** diff --git a/ext/standard/tests/strings/sprintf_f_2.phpt b/ext/standard/tests/strings/sprintf_f_2.phpt index 18d81c2d0444a..69fc4b223657a 100644 --- a/ext/standard/tests/strings/sprintf_f_2.phpt +++ b/ext/standard/tests/strings/sprintf_f_2.phpt @@ -58,32 +58,16 @@ $number = 362525200; var_dump(sprintf("%.3e", $number)); // outputs 3.63e+8 ?> ---EXPECTF-- +--EXPECT-- string(7) "100.426" string(6) "100.43" - -Deprecated: Implicit conversion from non-compatible float 100.426 to int in %s on line %d string(3) "100" - -Deprecated: Implicit conversion from non-compatible float 100.9 to int in %s on line %d string(3) "100" - -Deprecated: Implicit conversion from non-compatible float 100.426 to int in %s on line %d string(3) "144" - -Deprecated: Implicit conversion from non-compatible float 100.9 to int in %s on line %d string(3) "144" - -Deprecated: Implicit conversion from non-compatible float 100.1 to int in %s on line %d string(34) "There are 100 monkeys in the world" string(28) "The 100.1 contains 0 monkeys" - -Deprecated: Implicit conversion from non-compatible float 100.1 to int in %s on line %d string(30) "The world contains 100 monkeys" - -Deprecated: Implicit conversion from non-compatible float 100.1 to int in %s on line %d - -Deprecated: Implicit conversion from non-compatible float 100.1 to int in %s on line %d string(76) "The world contains 100 monkeys. That's a nice world full of 100 monkeys." string(8) "[monkey]" diff --git a/ext/standard/tests/strings/vprintf_variation15.phpt b/ext/standard/tests/strings/vprintf_variation15.phpt index 6cb5c8aa69f79..9be443e39ba23 100644 --- a/ext/standard/tests/strings/vprintf_variation15.phpt +++ b/ext/standard/tests/strings/vprintf_variation15.phpt @@ -45,7 +45,7 @@ foreach($formats as $format) { } ?> ---EXPECTF-- +--EXPECT-- *** Testing vprintf() : unsigned formats and unsigned values *** -- Iteration 1 -- @@ -53,15 +53,11 @@ string(22) ""1234567" "342391" "0"" int(22) -- Iteration 2 -- -string(%d) " -Deprecated: Implicit conversion from non-compatible float 12345678900 to int in %s on line %d -"3755744308" "1234" "12345"" +string(27) ""3755744308" "1234" "12345"" int(27) -- Iteration 3 -- -string(%d) " -Deprecated: Implicit conversion from non-compatible float 101234567000 to int in %s on line %d - " 1234000" "2450319192" "120"" +string(32) "" 1234000" "2450319192" "120"" int(32) -- Iteration 4 -- diff --git a/ext/standard/tests/strings/vprintf_variation15_64bit.phpt b/ext/standard/tests/strings/vprintf_variation15_64bit.phpt index 78e88d87b293e..91a6b2bf104ca 100644 --- a/ext/standard/tests/strings/vprintf_variation15_64bit.phpt +++ b/ext/standard/tests/strings/vprintf_variation15_64bit.phpt @@ -17,7 +17,7 @@ echo "*** Testing vprintf() : unsigned formats and unsigned values ***\n"; $formats = [ '"%u" "%+u" "%-u"', '"%lu" "%4u" "%-4u"', - ' "%10.4u" "%-10.4u" "%.4u"', + '"%10.4u" "%-10.4u" "%.4u"', '"%\'#2u "%\'2u" "%\'$2u" "%\'_2u"', '"%3$u" "%4$u" "%1$u" "%2$u"', ]; @@ -45,7 +45,7 @@ foreach($formats as $format) { } ?> ---EXPECTF-- +--EXPECT-- *** Testing vprintf() : unsigned formats and unsigned values *** -- Iteration 1 -- @@ -57,10 +57,8 @@ string(28) ""12345678900" "1234" "12345"" int(28) -- Iteration 3 -- -string(%d) " -Deprecated: Implicit conversion from non-compatible float 1.0E+21 to int in %s on line %d - " 1234000" "3875820019684212736" "120"" -int(41) +string(40) "" 1234000" "3875820019684212736" "120"" +int(40) -- Iteration 4 -- string(17) ""#1 "0" "$0" "10"" From c536d4df40b01777d71edbb8e7c5562fe9ade669 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sat, 29 May 2021 08:46:09 +0100 Subject: [PATCH 55/61] Fix test --- ext/standard/tests/strings/vprintf_variation15.phpt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/standard/tests/strings/vprintf_variation15.phpt b/ext/standard/tests/strings/vprintf_variation15.phpt index 9be443e39ba23..db27c694ca7b5 100644 --- a/ext/standard/tests/strings/vprintf_variation15.phpt +++ b/ext/standard/tests/strings/vprintf_variation15.phpt @@ -17,7 +17,7 @@ echo "*** Testing vprintf() : unsigned formats and unsigned values ***\n"; $formats = [ '"%u" "%+u" "%-u"', '"%lu" "%4u" "%-4u"', - ' "%10.4u" "%-10.4u" "%.4u"', + '"%10.4u" "%-10.4u" "%.4u"', '"%\'#2u "%\'2u" "%\'$2u" "%\'_2u"', '"%3$u" "%4$u" "%1$u" "%2$u"', ]; @@ -57,8 +57,8 @@ string(27) ""3755744308" "1234" "12345"" int(27) -- Iteration 3 -- -string(32) "" 1234000" "2450319192" "120"" -int(32) +string(31) "" 1234000" "2450319192" "120"" +int(31) -- Iteration 4 -- string(17) ""#1 "0" "$0" "10"" From de5fe1de62a6733519fafbadbb12d2f7af470284 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sat, 29 May 2021 08:52:19 +0100 Subject: [PATCH 56/61] Drop TODO comment --- ext/standard/array.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ext/standard/array.c b/ext/standard/array.c index 31476f7dac01d..d545dc26edd18 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -6052,7 +6052,6 @@ PHP_FUNCTION(array_key_exists) RETVAL_BOOL(zend_hash_exists(ht, ZSTR_EMPTY_ALLOC())); break; case IS_DOUBLE: - /* TODO Should this warn or not? */ RETVAL_BOOL(zend_hash_index_exists(ht, zend_dval_to_lval_safe(Z_DVAL_P(key)))); break; case IS_FALSE: From d4e1f8e9cea758ed88590e77bb413f14efbe99a0 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Mon, 31 May 2021 01:13:12 +0100 Subject: [PATCH 57/61] Fixup after %0 specifier has been introduced for null bytes in run-test --- ext/standard/tests/array/array_flip_variation2.phpt | 5 +---- ext/standard/tests/array/uasort_variation3.phpt | 5 +---- ext/standard/tests/strings/chunk_split_variation9.phpt | 2 +- ext/standard/tests/strings/printf.phpt | 2 +- ext/standard/tests/strings/printf_64bit.phpt | 2 +- 5 files changed, 5 insertions(+), 11 deletions(-) diff --git a/ext/standard/tests/array/array_flip_variation2.phpt b/ext/standard/tests/array/array_flip_variation2.phpt index 890b4cd2ec396..9cf90905c15f9 100644 --- a/ext/standard/tests/array/array_flip_variation2.phpt +++ b/ext/standard/tests/array/array_flip_variation2.phpt @@ -28,7 +28,6 @@ $input = array( // numeric keys 1 => 'int_key', // expected: value will be replaced by 'bool_key3' -2 => 'negative_key', - 8.9 => 'float_key', 012 => 'octal_key', 0x34 => 'hex_key', @@ -65,15 +64,13 @@ echo "Done" ?> --EXPECTF-- *** Testing array_flip() : different keys for 'input' array argument *** -array(14) { +array(13) { ["bool_key4"]=> int(0) ["bool_key3"]=> int(1) ["negative_key"]=> int(-2) - ["float_key"]=> - int(8) ["octal_key"]=> int(10) ["hex_key"]=> diff --git a/ext/standard/tests/array/uasort_variation3.phpt b/ext/standard/tests/array/uasort_variation3.phpt index 16144c5cc277d..1b690e4dfd032 100644 --- a/ext/standard/tests/array/uasort_variation3.phpt +++ b/ext/standard/tests/array/uasort_variation3.phpt @@ -45,7 +45,6 @@ $array_arg = array( // numeric keys 1 => 10, // expecting: value will be replaced by 'TRUE' -2 => 9, - 8.9 => 8, 012 => 7, 0x34 => 6, @@ -86,7 +85,7 @@ echo "Done" *** Testing uasort() : Sorting array with all possible keys *** bool(true) -- Sorted array after uasort() function call -- -array(14) { +array(13) { ["multiline heredoc with 123 and speci@! ch@r.. check also"]=> @@ -105,8 +104,6 @@ check also"]=> int(25) [-2]=> int(9) - [8]=> - int(8) [10]=> int(7) [52]=> diff --git a/ext/standard/tests/strings/chunk_split_variation9.phpt b/ext/standard/tests/strings/chunk_split_variation9.phpt index c2d76676fd845..cc95e563346d2 100644 --- a/ext/standard/tests/strings/chunk_split_variation9.phpt +++ b/ext/standard/tests/strings/chunk_split_variation9.phpt @@ -11,7 +11,7 @@ echo "*** Testing chunk_split() : different strings for 'ending' ***\n"; //Initializing variables $str = "This is to test chunk_split() with various ending string"; -$chunklen = 6.5; +$chunklen = 6; //different values for 'ending' argument $values = array ( diff --git a/ext/standard/tests/strings/printf.phpt b/ext/standard/tests/strings/printf.phpt index e400d3118b1ed..ba21efe355d5d 100644 --- a/ext/standard/tests/strings/printf.phpt +++ b/ext/standard/tests/strings/printf.phpt @@ -557,7 +557,7 @@ array(4) { [1]=> string(6) "'%-5s'" [2]=> - string(6) "'%05s'" + string(6) "'%r%%r05s'" [3]=> string(7) "'%'#5s'" } diff --git a/ext/standard/tests/strings/printf_64bit.phpt b/ext/standard/tests/strings/printf_64bit.phpt index 414c2844ae68b..42addf035a2a4 100644 --- a/ext/standard/tests/strings/printf_64bit.phpt +++ b/ext/standard/tests/strings/printf_64bit.phpt @@ -557,7 +557,7 @@ array(4) { [1]=> string(6) "'%-5s'" [2]=> - string(6) "'%05s'" + string(6) "'%r%%r05s'" [3]=> string(7) "'%'#5s'" } From 473e14c67a8a57d3ee7d51f2eba301483d3c02dc Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Mon, 31 May 2021 11:56:37 +0100 Subject: [PATCH 58/61] Revert changes to formatted_print.c --- ext/standard/formatted_print.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c index 07241570ff3f7..0990b390d6b29 100644 --- a/ext/standard/formatted_print.c +++ b/ext/standard/formatted_print.c @@ -10,7 +10,7 @@ | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ - | Author: Stig Söther Bakken | + | Author: Stig S�ther Bakken | +----------------------------------------------------------------------+ */ @@ -634,14 +634,15 @@ php_formatted_print(char *format, size_t format_len, zval *args, int argc, int n case 'd': php_sprintf_appendint(&result, &outpos, - zval_get_long_ex(tmp, /* is_strict */ false), - width, padding, alignment, always_sign); + zval_get_long(tmp), + width, padding, alignment, + always_sign); break; case 'u': php_sprintf_appenduint(&result, &outpos, - zval_get_long_ex(tmp, /* is_strict */ false), - width, padding, alignment); + zval_get_long(tmp), + width, padding, alignment); break; case 'e': @@ -662,31 +663,35 @@ php_formatted_print(char *format, size_t format_len, zval *args, int argc, int n case 'c': php_sprintf_appendchar(&result, &outpos, - (char) zval_get_long_ex(tmp, /* is_strict */ false)); + (char) zval_get_long(tmp)); break; case 'o': php_sprintf_append2n(&result, &outpos, - zval_get_long_ex(tmp, /* is_strict */ false), - width, padding, alignment, 3, hexchars, expprec); + zval_get_long(tmp), + width, padding, alignment, 3, + hexchars, expprec); break; case 'x': php_sprintf_append2n(&result, &outpos, - zval_get_long_ex(tmp, /* is_strict */ false), - width, padding, alignment, 4, hexchars, expprec); + zval_get_long(tmp), + width, padding, alignment, 4, + hexchars, expprec); break; case 'X': php_sprintf_append2n(&result, &outpos, - zval_get_long_ex(tmp, /* is_strict */ false), - width, padding, alignment, 4, HEXCHARS, expprec); + zval_get_long(tmp), + width, padding, alignment, 4, + HEXCHARS, expprec); break; case 'b': php_sprintf_append2n(&result, &outpos, - zval_get_long_ex(tmp, /* is_strict */ false), - width, padding, alignment, 1, hexchars, expprec); + zval_get_long(tmp), + width, padding, alignment, 1, + hexchars, expprec); break; case '%': From 3f030bfe38173356f12ae984437bec91ae4a6377 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Mon, 31 May 2021 11:57:09 +0100 Subject: [PATCH 59/61] Drop useless test --- .../strings/chunk_split_variation10.phpt | 110 ------------------ 1 file changed, 110 deletions(-) delete mode 100644 ext/standard/tests/strings/chunk_split_variation10.phpt diff --git a/ext/standard/tests/strings/chunk_split_variation10.phpt b/ext/standard/tests/strings/chunk_split_variation10.phpt deleted file mode 100644 index 935cfa11b35b6..0000000000000 --- a/ext/standard/tests/strings/chunk_split_variation10.phpt +++ /dev/null @@ -1,110 +0,0 @@ ---TEST-- -Test chunk_split() function : usage variations - different single quoted strings for 'ending' argument ---FILE-- - ---EXPECTF-- -*** Testing chunk_split() : different single quoted strings as 'ending' *** --- Iteration 0 -- - -Deprecated: Implicit conversion from non-compatible float 9.2 to int in %s on line %d -string(73) "This is to test chunk_split() with various 'single quoted' ending string." --- Iteration 1 -- - -Deprecated: Implicit conversion from non-compatible float 9.2 to int in %s on line %d -string(82) "This is t o test ch unk_split () with v arious 's ingle quo ted' endi ng string . " --- Iteration 2 -- - -Deprecated: Implicit conversion from non-compatible float 9.2 to int in %s on line %d -string(82) "This is tao test chaunk_splita() with vaarious 'saingle quoated' endiang stringa.a" --- Iteration 3 -- - -Deprecated: Implicit conversion from non-compatible float 9.2 to int in %s on line %d -string(127) "This is tENDINGo test chENDINGunk_splitENDING() with vENDINGarious 'sENDINGingle quoENDINGted' endiENDINGng stringENDING.ENDING" --- Iteration 4 -- - -Deprecated: Implicit conversion from non-compatible float 9.2 to int in %s on line %d -string(118) "This is t@#$%^o test ch@#$%^unk_split@#$%^() with v@#$%^arious 's@#$%^ingle quo@#$%^ted' endi@#$%^ng string@#$%^.@#$%^" --- Iteration 5 -- - -Deprecated: Implicit conversion from non-compatible float 9.2 to int in %s on line %d -string(91) "This is t\to test ch\tunk_split\t() with v\tarious 's\tingle quo\tted' endi\tng string\t.\t" --- Iteration 6 -- - -Deprecated: Implicit conversion from non-compatible float 9.2 to int in %s on line %d -string(91) "This is t\no test ch\nunk_split\n() with v\narious 's\ningle quo\nted' endi\nng string\n.\n" --- Iteration 7 -- - -Deprecated: Implicit conversion from non-compatible float 9.2 to int in %s on line %d -string(91) "This is t\ro test ch\runk_split\r() with v\rarious 's\ringle quo\rted' endi\rng string\r.\r" --- Iteration 8 -- - -Deprecated: Implicit conversion from non-compatible float 9.2 to int in %s on line %d -string(109) "This is t\r\no test ch\r\nunk_split\r\n() with v\r\narious 's\r\ningle quo\r\nted' endi\r\nng string\r\n.\r\n" --- Iteration 9 -- - -Deprecated: Implicit conversion from non-compatible float 9.2 to int in %s on line %d -string(91) "This is t\0o test ch\0unk_split\0() with v\0arious 's\0ingle quo\0ted' endi\0ng string\0.\0" --- Iteration 10 -- - -Deprecated: Implicit conversion from non-compatible float 9.2 to int in %s on line %d -string(100) "This is t123o test ch123unk_split123() with v123arious 's123ingle quo123ted' endi123ng string123.123" --- Iteration 11 -- - -Deprecated: Implicit conversion from non-compatible float 9.2 to int in %s on line %d -string(118) "This is t(MSG)o test ch(MSG)unk_split(MSG)() with v(MSG)arious 's(MSG)ingle quo(MSG)ted' endi(MSG)ng string(MSG).(MSG)" --- Iteration 12 -- - -Deprecated: Implicit conversion from non-compatible float 9.2 to int in %s on line %d -string(226) "This is t) ending string (o test ch) ending string (unk_split) ending string (() with v) ending string (arious 's) ending string (ingle quo) ending string (ted' endi) ending string (ng string) ending string (.) ending string (" --- Iteration 13 -- - -Deprecated: Implicit conversion from non-compatible float 9.2 to int in %s on line %d -string(217) "This is t) numbers 1234 (o test ch) numbers 1234 (unk_split) numbers 1234 (() with v) numbers 1234 (arious 's) numbers 1234 (ingle quo) numbers 1234 (ted' endi) numbers 1234 (ng string) numbers 1234 (.) numbers 1234 (" --- Iteration 14 -- - -Deprecated: Implicit conversion from non-compatible float 9.2 to int in %s on line %d -string(226) "This is t) speci@! ch@r$ (o test ch) speci@! ch@r$ (unk_split) speci@! ch@r$ (() with v) speci@! ch@r$ (arious 's) speci@! ch@r$ (ingle quo) speci@! ch@r$ (ted' endi) speci@! ch@r$ (ng string) speci@! ch@r$ (.) speci@! ch@r$ (" -Done From ac925c48b71a81b35448486627c5ee3246aec14d Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Mon, 31 May 2021 12:09:47 +0100 Subject: [PATCH 60/61] Drop printf test changes --- .../tests/strings/fprintf_variation_002.phpt | 130 +++--- .../tests/strings/fprintf_variation_003.phpt | 4 +- .../strings/fprintf_variation_003_64bit.phpt | 4 +- .../tests/strings/fprintf_variation_006.phpt | 4 +- .../strings/fprintf_variation_006_64bit.phpt | 4 +- .../tests/strings/fprintf_variation_007.phpt | 4 +- .../strings/fprintf_variation_007_64bit.phpt | 4 +- .../tests/strings/fprintf_variation_008.phpt | 4 +- .../strings/fprintf_variation_008_64bit.phpt | 4 +- ext/standard/tests/strings/printf.phpt | 411 ++++++++++-------- ext/standard/tests/strings/printf_64bit.phpt | 409 +++++++++-------- ext/standard/tests/strings/sprintf_f_2.phpt | 77 +++- .../tests/strings/vprintf_variation12.phpt | 85 ++-- .../strings/vprintf_variation12_64bit.phpt | 86 ++-- .../tests/strings/vprintf_variation14.phpt | 85 ++-- .../strings/vprintf_variation14_64bit.phpt | 86 ++-- .../tests/strings/vprintf_variation15.phpt | 45 +- .../strings/vprintf_variation15_64bit.phpt | 45 +- .../tests/strings/vprintf_variation16.phpt | 72 +-- .../strings/vprintf_variation16_64bit.phpt | 73 ++-- .../tests/strings/vprintf_variation4.phpt | 75 ++-- .../strings/vprintf_variation4_64bit.phpt | 103 +++++ 22 files changed, 1069 insertions(+), 745 deletions(-) create mode 100644 ext/standard/tests/strings/vprintf_variation4_64bit.phpt diff --git a/ext/standard/tests/strings/fprintf_variation_002.phpt b/ext/standard/tests/strings/fprintf_variation_002.phpt index 29eea7c416fc9..f0f21b46302ea 100644 --- a/ext/standard/tests/strings/fprintf_variation_002.phpt +++ b/ext/standard/tests/strings/fprintf_variation_002.phpt @@ -3,7 +3,7 @@ Test fprintf() function (variation - 2) --FILE-- 2147483647) { + die("skip 32bit test only"); +} ?> --FILE-- --EXPECTF-- *** Output for zero argument *** -printf() expects at least 1 argument, 0 given +printf() expects at least %d argument, %d given *** Output for insufficient number of arguments *** Error found: 5 arguments are required, 3 given @@ -257,100 +259,100 @@ Array Float Iteration 1 -'0.000000' -'1.000000' -'-1.000000' -'0.320000' -'-0.320000' -'3.400000' -'2.540000' -'-2.540000' -'1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000' -'-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000' +0.000000 +1.000000 +-1.000000 +0.320000 +-0.320000 +3.400000 +2.540000 +-2.540000 +1234567%d.000000 +-1234567%d.000000 Float Iteration 2 -'0.000000' -'1.000000' -'-1.000000' -'0.320000' -'-0.320000' -'3.400000' -'2.540000' -'-2.540000' -'1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000' -'-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000' +0.000000 +1.000000 +-1.000000 +0.320000 +-0.320000 +3.400000 +2.540000 +-2.540000 +1234567%d.000000 +-1234567%d.000000 Float Iteration 3 -'+0.000000' -'+1.000000' -'-1.000000' -'+0.320000' -'-0.320000' -'+3.400000' -'+2.540000' -'-2.540000' -'+1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000' -'-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000' ++0.000000 ++1.000000 +-1.000000 ++0.320000 +-0.320000 ++3.400000 ++2.540000 +-2.540000 ++1234567%d.000000 +-1234567%d.000000 Float Iteration 4 -' 0.00' -' 1.00' -' -1.00' -' 0.32' -' -0.32' -' 3.40' -' 2.54' -' -2.54' -'1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' -'-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' + 0.00 + 1.00 + -1.00 + 0.32 + -0.32 + 3.40 + 2.54 + -2.54 +1234567%d.00 +-1234567%d.00 Float Iteration 5 -'0.00 ' -'1.00 ' -'-1.00 ' -'0.32 ' -'-0.32 ' -'3.40 ' -'2.54 ' -'-2.54 ' -'1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' -'-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' +0.00 +1.00 +-1.00 +0.32 +-0.32 +3.40 +2.54 +-2.54 +1234567%d.00 +-1234567%d.00 Float Iteration 6 -'0000.00' -'0001.00' -'-001.00' -'0000.32' -'-000.32' -'0003.40' -'0002.54' -'-002.54' -'1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' -'-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' +0000.00 +0001.00 +-001.00 +0000.32 +-000.32 +0003.40 +0002.54 +-002.54 +1234567%d.00 +-1234567%d.00 Float Iteration 7 -'0.00000' -'1.00000' -'-1.0000' -'0.32000' -'-0.3200' -'3.40000' -'2.54000' -'-2.5400' -'1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' -'-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' +0.00000 +1.00000 +-1.0000 +0.32000 +-0.3200 +3.40000 +2.54000 +-2.5400 +1234567%d.00 +-1234567%d.00 Float Iteration 8 -'###0.00' -'###1.00' -'##-1.00' -'###0.32' -'##-0.32' -'###3.40' -'###2.54' -'##-2.54' -'1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' -'-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' +###0.00 +###1.00 +##-1.00 +###0.32 +##-0.32 +###3.40 +###2.54 +##-2.54 +1234567%d.00 +-1234567%d.00 *** Output for integer type *** @@ -360,75 +362,93 @@ Array [0] => 0 [1] => 1 [2] => -1 - [3] => 23333333 - [4] => -23333333 - [5] => 1234 + [3] => 2.7 + [4] => -2.7 + [5] => 23333333 + [6] => -23333333 + [7] => 1234 ) Integer Iteration 1 -'0' -'1' -'-1' -'23333333' -'-23333333' -'1234' +0 +1 +-1 +2 +-2 +23333333 +-23333333 +1234 Integer Iteration 2 -'0' -'1' -'-1' -'23333333' -'-23333333' -'1234' +0 +1 +-1 +2 +-2 +23333333 +-23333333 +1234 Integer Iteration 3 -'+0' -'+1' -'-1' -'+23333333' -'-23333333' -'+1234' ++0 ++1 +-1 ++2 +-2 ++23333333 +-23333333 ++1234 Integer Iteration 4 -' 0' -' 1' -' -1' -'23333333' -'-23333333' -' 1234' + 0 + 1 + -1 + 2 + -2 +23333333 +-23333333 + 1234 Integer Iteration 5 -'0 ' -'1 ' -'-1 ' -'23333333' -'-23333333' -'1234 ' +0 +1 +-1 +2 +-2 +23333333 +-23333333 +1234 Integer Iteration 6 -'0000000' -'0000001' -'-000001' -'23333333' -'-23333333' -'0001234' +0000000 +0000001 +-000001 +0000002 +-000002 +23333333 +-23333333 +0001234 Integer Iteration 7 -'0 ' -'1 ' -'-1 ' -'23333333' -'-23333333' -'1234 ' +0 +1 +-1 +2 +-2 +23333333 +-23333333 +1234 Integer Iteration 8 -'######0' -'######1' -'#####-1' -'23333333' -'-23333333' -'###1234' +######0 +######1 +#####-1 +######2 +#####-2 +23333333 +-23333333 +###1234 *** Output for binary type *** @@ -438,14 +458,18 @@ Array [0] => 0 [1] => 1 [2] => -1 - [3] => 23333333 - [4] => -23333333 - [5] => 1234 + [3] => 2.7 + [4] => -2.7 + [5] => 23333333 + [6] => -23333333 + [7] => 1234 ) 0 1 11111111111111111111111111111111 +10 +11111111111111111111111111111110 1011001000000100111010101 11111110100110111111011000101011 10011010010 @@ -458,14 +482,14 @@ Array [0] => a [1] => a [2] => 67 - [3] => -150 + [3] => -67 [4] => 99 ) %0 %0 C -j +½ c *** Output for scientific type *** @@ -476,14 +500,18 @@ Array [0] => 0 [1] => 1 [2] => -1 - [3] => 23333333 - [4] => -23333333 - [5] => 1234 + [3] => 2.7 + [4] => -2.7 + [5] => 23333333 + [6] => -23333333 + [7] => 1234 ) 0.000000e+0 1.000000e+0 -1.000000e+0 +2.700000e+0 +-2.700000e+0 2.333333e+7 -2.333333e+7 1.234000e+3 @@ -496,14 +524,18 @@ Array [0] => 0 [1] => 1 [2] => -1 - [3] => 23333333 - [4] => -23333333 - [5] => 1234 + [3] => 2.7 + [4] => -2.7 + [5] => 23333333 + [6] => -23333333 + [7] => 1234 ) 0 1 4294967295 +2 +4294967294 23333333 4271633963 1234 @@ -516,14 +548,18 @@ Array [0] => 0 [1] => 1 [2] => -1 - [3] => 23333333 - [4] => -23333333 - [5] => 1234 + [3] => 2.7 + [4] => -2.7 + [5] => 23333333 + [6] => -23333333 + [7] => 1234 ) 0 1 37777777777 +2 +37777777776 131004725 37646773053 2322 @@ -536,14 +572,18 @@ Array [0] => 0 [1] => 1 [2] => -1 - [3] => 23333333 - [4] => -23333333 - [5] => 1234 + [3] => 2.7 + [4] => -2.7 + [5] => 23333333 + [6] => -23333333 + [7] => 1234 ) 0 1 ffffffff +2 +fffffffe 16409d5 fe9bf62b 4d2 @@ -551,39 +591,34 @@ fe9bf62b *** Output for string type *** Input Strings format variation array is: -array(4) { - [0]=> - string(5) "'%5s'" - [1]=> - string(6) "'%-5s'" - [2]=> - string(6) "'%r%%r05s'" - [3]=> - string(7) "'%'#5s'" -} +Array +( + [0] => %5s + [1] => %-5s + [2] => %r%%r05s + [3] => %'#5s +) Input strings variation array is: -array(3) { - [0]=> - NULL - [1]=> - string(3) "abc" - [2]=> - string(3) "aaa" -} +Array +( + [0] => + [1] => abc + [2] => aaa +) -' ' -' abc' -' aaa' -' ' -'abc ' -'aaa ' -'00000' -'00abc' -'00aaa' -'#####' -'##abc' -'##aaa' + + abc + aaa + +abc +aaa +00000 +00abc +00aaa +##### +##abc +##aaa *** Output for '%g' type *** diff --git a/ext/standard/tests/strings/printf_64bit.phpt b/ext/standard/tests/strings/printf_64bit.phpt index 42addf035a2a4..083b7b2979db2 100644 --- a/ext/standard/tests/strings/printf_64bit.phpt +++ b/ext/standard/tests/strings/printf_64bit.phpt @@ -2,7 +2,9 @@ Test printf() function (64bit) --SKIPIF-- 2147483647)) { + die("skip 64bit test only"); +} ?> --INI-- precision=14 @@ -11,15 +13,15 @@ precision=14 /* Various input arrays for different format types */ -$float_variation = array( "'%f'", "'%-f'", "'%+f'", "'%7.2f'", "'%-7.2f'", "'%07.2f'", "'%-07.2f'", "'%'#7.2f'" ); +$float_variation = array( "%f", "%-f", "%+f", "%7.2f", "%-7.2f", "%07.2f", "%-07.2f", "%'#7.2f" ); $float_numbers = array( 0, 1, -1, 0.32, -0.32, 3.4. -3.4, 2.54, -2.54, 1.2345678e99, -1.2345678e99 ); -$int_variation = array( "'%d'", "'%-d'", "'%+d'", "'%7.2d'", "'%-7.2d'", "'%07.2d'", "'%-07.2d'", "'%'#7.2d'" ); -$int_numbers = array( 0, 1, -1, 23333333, -23333333, "1234" ); +$int_variation = array( "%d", "%-d", "%+d", "%7.2d", "%-7.2d", "%07.2d", "%-07.2d", "%'#7.2d" ); +$int_numbers = array( 0, 1, -1, 2.7, -2.7, 23333333, -23333333, "1234" ); -$char_variation = array( 'a', "a", 67, -150 /* j */, 99 ); +$char_variation = array( 'a', "a", 67, -67, 99 ); -$string_variation = array( "'%5s'", "'%-5s'", "'%05s'", "'%'#5s'" ); +$string_variation = array( "%5s", "%-5s", "%05s", "%'#5s" ); $strings = array( NULL, "abc", 'aaa' ); /* Checking warning messages */ @@ -99,7 +101,7 @@ print_r($int_numbers); } -/* Character type variations */ +/* Chararter type variations */ echo "\n\n*** Output for char type ***\n"; echo "\n Input Characters variation array is:\n"; print_r($char_variation); @@ -157,9 +159,9 @@ foreach( $int_numbers as $hexa_num ) /* String type variations */ echo "\n\n*** Output for string type ***\n"; echo "\n Input Strings format variation array is:\n"; -var_dump($string_variation); +print_r($string_variation); echo "\n Input strings variation array is:\n"; -var_dump($strings); +print_r($strings); foreach( $string_variation as $string_var ) { @@ -257,100 +259,100 @@ Array Float Iteration 1 -'0.000000' -'1.000000' -'-1.000000' -'0.320000' -'-0.320000' -'3.400000' -'2.540000' -'-2.540000' -'1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000' -'-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000' +0.000000 +1.000000 +-1.000000 +0.320000 +-0.320000 +3.400000 +2.540000 +-2.540000 +1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000 +-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000 Float Iteration 2 -'0.000000' -'1.000000' -'-1.000000' -'0.320000' -'-0.320000' -'3.400000' -'2.540000' -'-2.540000' -'1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000' -'-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000' +0.000000 +1.000000 +-1.000000 +0.320000 +-0.320000 +3.400000 +2.540000 +-2.540000 +1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000 +-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000 Float Iteration 3 -'+0.000000' -'+1.000000' -'-1.000000' -'+0.320000' -'-0.320000' -'+3.400000' -'+2.540000' -'-2.540000' -'+1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000' -'-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000' ++0.000000 ++1.000000 +-1.000000 ++0.320000 +-0.320000 ++3.400000 ++2.540000 +-2.540000 ++1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000 +-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.000000 Float Iteration 4 -' 0.00' -' 1.00' -' -1.00' -' 0.32' -' -0.32' -' 3.40' -' 2.54' -' -2.54' -'1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' -'-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' + 0.00 + 1.00 + -1.00 + 0.32 + -0.32 + 3.40 + 2.54 + -2.54 +1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00 +-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00 Float Iteration 5 -'0.00 ' -'1.00 ' -'-1.00 ' -'0.32 ' -'-0.32 ' -'3.40 ' -'2.54 ' -'-2.54 ' -'1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' -'-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' +0.00 +1.00 +-1.00 +0.32 +-0.32 +3.40 +2.54 +-2.54 +1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00 +-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00 Float Iteration 6 -'0000.00' -'0001.00' -'-001.00' -'0000.32' -'-000.32' -'0003.40' -'0002.54' -'-002.54' -'1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' -'-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' +0000.00 +0001.00 +-001.00 +0000.32 +-000.32 +0003.40 +0002.54 +-002.54 +1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00 +-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00 Float Iteration 7 -'0.00000' -'1.00000' -'-1.0000' -'0.32000' -'-0.3200' -'3.40000' -'2.54000' -'-2.5400' -'1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' -'-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' +0.00000 +1.00000 +-1.0000 +0.32000 +-0.3200 +3.40000 +2.54000 +-2.5400 +1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00 +-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00 Float Iteration 8 -'###0.00' -'###1.00' -'##-1.00' -'###0.32' -'##-0.32' -'###3.40' -'###2.54' -'##-2.54' -'1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' -'-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00' +###0.00 +###1.00 +##-1.00 +###0.32 +##-0.32 +###3.40 +###2.54 +##-2.54 +1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00 +-1234567799999999974395005011934353453808157274826416694779123657996479008398428960266851879135215616.00 *** Output for integer type *** @@ -360,75 +362,93 @@ Array [0] => 0 [1] => 1 [2] => -1 - [3] => 23333333 - [4] => -23333333 - [5] => 1234 + [3] => 2.7 + [4] => -2.7 + [5] => 23333333 + [6] => -23333333 + [7] => 1234 ) Integer Iteration 1 -'0' -'1' -'-1' -'23333333' -'-23333333' -'1234' +0 +1 +-1 +2 +-2 +23333333 +-23333333 +1234 Integer Iteration 2 -'0' -'1' -'-1' -'23333333' -'-23333333' -'1234' +0 +1 +-1 +2 +-2 +23333333 +-23333333 +1234 Integer Iteration 3 -'+0' -'+1' -'-1' -'+23333333' -'-23333333' -'+1234' ++0 ++1 +-1 ++2 +-2 ++23333333 +-23333333 ++1234 Integer Iteration 4 -' 0' -' 1' -' -1' -'23333333' -'-23333333' -' 1234' + 0 + 1 + -1 + 2 + -2 +23333333 +-23333333 + 1234 Integer Iteration 5 -'0 ' -'1 ' -'-1 ' -'23333333' -'-23333333' -'1234 ' +0 +1 +-1 +2 +-2 +23333333 +-23333333 +1234 Integer Iteration 6 -'0000000' -'0000001' -'-000001' -'23333333' -'-23333333' -'0001234' +0000000 +0000001 +-000001 +0000002 +-000002 +23333333 +-23333333 +0001234 Integer Iteration 7 -'0 ' -'1 ' -'-1 ' -'23333333' -'-23333333' -'1234 ' +0 +1 +-1 +2 +-2 +23333333 +-23333333 +1234 Integer Iteration 8 -'######0' -'######1' -'#####-1' -'23333333' -'-23333333' -'###1234' +######0 +######1 +#####-1 +######2 +#####-2 +23333333 +-23333333 +###1234 *** Output for binary type *** @@ -438,14 +458,18 @@ Array [0] => 0 [1] => 1 [2] => -1 - [3] => 23333333 - [4] => -23333333 - [5] => 1234 + [3] => 2.7 + [4] => -2.7 + [5] => 23333333 + [6] => -23333333 + [7] => 1234 ) 0 1 1111111111111111111111111111111111111111111111111111111111111111 +10 +1111111111111111111111111111111111111111111111111111111111111110 1011001000000100111010101 1111111111111111111111111111111111111110100110111111011000101011 10011010010 @@ -458,14 +482,14 @@ Array [0] => a [1] => a [2] => 67 - [3] => -150 + [3] => -67 [4] => 99 ) %0 %0 C -j +½ c *** Output for scientific type *** @@ -476,14 +500,18 @@ Array [0] => 0 [1] => 1 [2] => -1 - [3] => 23333333 - [4] => -23333333 - [5] => 1234 + [3] => 2.7 + [4] => -2.7 + [5] => 23333333 + [6] => -23333333 + [7] => 1234 ) 0.000000e+0 1.000000e+0 -1.000000e+0 +2.700000e+0 +-2.700000e+0 2.333333e+7 -2.333333e+7 1.234000e+3 @@ -496,14 +524,18 @@ Array [0] => 0 [1] => 1 [2] => -1 - [3] => 23333333 - [4] => -23333333 - [5] => 1234 + [3] => 2.7 + [4] => -2.7 + [5] => 23333333 + [6] => -23333333 + [7] => 1234 ) 0 1 18446744073709551615 +2 +18446744073709551614 23333333 18446744073686218283 1234 @@ -516,14 +548,18 @@ Array [0] => 0 [1] => 1 [2] => -1 - [3] => 23333333 - [4] => -23333333 - [5] => 1234 + [3] => 2.7 + [4] => -2.7 + [5] => 23333333 + [6] => -23333333 + [7] => 1234 ) 0 1 1777777777777777777777 +2 +1777777777777777777776 131004725 1777777777777646773053 2322 @@ -536,14 +572,18 @@ Array [0] => 0 [1] => 1 [2] => -1 - [3] => 23333333 - [4] => -23333333 - [5] => 1234 + [3] => 2.7 + [4] => -2.7 + [5] => 23333333 + [6] => -23333333 + [7] => 1234 ) 0 1 ffffffffffffffff +2 +fffffffffffffffe 16409d5 fffffffffe9bf62b 4d2 @@ -551,39 +591,34 @@ fffffffffe9bf62b *** Output for string type *** Input Strings format variation array is: -array(4) { - [0]=> - string(5) "'%5s'" - [1]=> - string(6) "'%-5s'" - [2]=> - string(6) "'%r%%r05s'" - [3]=> - string(7) "'%'#5s'" -} +Array +( + [0] => %5s + [1] => %-5s + [2] => %r%%r05s + [3] => %'#5s +) Input strings variation array is: -array(3) { - [0]=> - NULL - [1]=> - string(3) "abc" - [2]=> - string(3) "aaa" -} +Array +( + [0] => + [1] => abc + [2] => aaa +) -' ' -' abc' -' aaa' -' ' -'abc ' -'aaa ' -'00000' -'00abc' -'00aaa' -'#####' -'##abc' -'##aaa' + + abc + aaa + +abc +aaa +00000 +00abc +00aaa +##### +##abc +##aaa *** Output for '%g' type *** diff --git a/ext/standard/tests/strings/sprintf_f_2.phpt b/ext/standard/tests/strings/sprintf_f_2.phpt index 69fc4b223657a..9ee0aae17fb26 100644 --- a/ext/standard/tests/strings/sprintf_f_2.phpt +++ b/ext/standard/tests/strings/sprintf_f_2.phpt @@ -33,6 +33,28 @@ $format = 'The %2$s contains %1$d monkeys. That\'s a nice %2$s full of %1$d monkeys.'; var_dump(sprintf($format, $num, $location)); +/* example#5: various examples */ +$n = 43951789; +$u = -43951789; +$c = 65; // ASCII 65 is 'A' + +// notice the double %%, this prints a literal '%' character +var_dump(sprintf("%%b = '%b'", $n)); // binary representation +var_dump(sprintf("%%c = '%c'", $c)); // print the ascii character, same as chr() function +var_dump(sprintf("%%d = '%d'", $n)); // standard integer representation +var_dump(sprintf("%%e = '%e'", $n)); // scientific notation +var_dump(sprintf("%%u = '%u'", $n)); // unsigned integer representation of a positive integer +var_dump(sprintf("%%u = '%u'", $u)); // unsigned integer representation of a negative integer +var_dump(sprintf("%%f = '%f'", $n)); // floating point representation +var_dump(sprintf("%%o = '%o'", $n)); // octal representation +var_dump(sprintf("%%s = '%s'", $n)); // string representation +var_dump(sprintf("%%x = '%x'", $n)); // hexadecimal representation (lower-case) +var_dump(sprintf("%%X = '%X'", $n)); // hexadecimal representation (upper-case) + +var_dump(sprintf("%%+d = '%+d'", $n)); // sign specifier on a positive integer +var_dump(sprintf("%%+d = '%+d'", $u)); // sign specifier on a negative integer + + /* example#6: string specifiers */ $s = 'monkey'; $t = 'many monkeys'; @@ -58,24 +80,37 @@ $number = 362525200; var_dump(sprintf("%.3e", $number)); // outputs 3.63e+8 ?> ---EXPECT-- -string(7) "100.426" -string(6) "100.43" -string(3) "100" -string(3) "100" -string(3) "144" -string(3) "144" -string(34) "There are 100 monkeys in the world" -string(28) "The 100.1 contains 0 monkeys" -string(30) "The world contains 100 monkeys" -string(76) "The world contains 100 monkeys. - That's a nice world full of 100 monkeys." -string(8) "[monkey]" -string(12) "[ monkey]" -string(12) "[monkey ]" -string(12) "[0000monkey]" -string(12) "[####monkey]" -string(12) "[many monke]" -string(10) "2006-12-18" -string(6) "123.10" -string(8) "3.625e+8" +--EXPECTREGEX-- +string\(7\) \"100\.426\" +string\(6\) \"100\.43\" +string\(3\) \"100\" +string\(3\) \"100\" +string\(3\) \"144\" +string\(3\) \"144\" +string\(34\) \"There are 100 monkeys in the world\" +string\(28\) \"The 100\.1 contains 0 monkeys\" +string\(30\) \"The world contains 100 monkeys\" +string\(76\) \"The world contains 100 monkeys. + That's a nice world full of 100 monkeys\.\" +string\(33\) \"%b = '10100111101010011010101101'\" +string\(8\) \"%c = 'A'\" +string\(15\) \"%d = '43951789'\" +string\(18\) \"%e = '4\.395179e\+7'\" +string\(15\) \"%u = '43951789'\" +(string\(17\) \"%u = '4251015507'\"|string\(27\) \"%u = '18446744073665599827'\") +string\(22\) \"%f = '43951789\.000000'\" +string\(16\) \"%o = '247523255'\" +string\(15\) \"%s = '43951789'\" +string\(14\) \"%x = '29ea6ad'\" +string\(14\) \"%X = '29EA6AD'\" +string\(17\) \"%\+d = '\+43951789'\" +string\(17\) \"%\+d = '-43951789'\" +string\(8\) \"\[monkey\]\" +string\(12\) \"\[ monkey\]\" +string\(12\) \"\[monkey \]\" +string\(12\) \"\[0000monkey\]\" +string\(12\) \"\[####monkey\]\" +string\(12\) \"\[many monke\]\" +string\(10\) \"2006-12-18\" +string\(6\) \"123\.10\" +string\(8\) \"3\.625e\+8\" diff --git a/ext/standard/tests/strings/vprintf_variation12.phpt b/ext/standard/tests/strings/vprintf_variation12.phpt index 9c49a3d690a76..cac53da18f4d8 100644 --- a/ext/standard/tests/strings/vprintf_variation12.phpt +++ b/ext/standard/tests/strings/vprintf_variation12.phpt @@ -15,15 +15,23 @@ echo "*** Testing vprintf() : octal formats and non-octal values ***\n"; // defining array of octal formats $formats = - '"%o" "%+o" "%-o" - "%lo" "%4o" "%-4o" - "%10.4o" "%-10.4o" "%.4o" - "%\'#2o" "%\'2o" "%\'$2o" "%\'_2o" - "%3$o" "%4$o" "%1$o" "%2$o"'; + '%o %+o %-o + %lo %4o %-4o + %10.4o %-10.4o %.4o + %\'#2o %\'2o %\'$2o %\'_2o + %3$o %4$o %1$o %2$o'; // Arrays of non octal values for the format defined in $format. // Each sub array contains non octal values which correspond to each format in $format $args_array = array( + + // array of float values + array(2.2, .2, 10.2, + 123456.234, -1234.6789, +1234.6789, + 2e10, +2e12, 22e+12, + 12345.780, 12.000000011111, -12.00000111111, -123456.234, + 3.33, +4.44, 1.11,-2.22 ), + // array of int values array(2, -2, +2, 123456, -12346789, +12346789, @@ -58,12 +66,11 @@ $args_array = array( // and with non-octal values from the above $args_array array $counter = 1; foreach($args_array as $args) { - echo "\n-- Iteration $counter --\n"; - ob_start(); - $bytes = vprintf($formats, $args); - var_dump(ob_get_clean()); - var_dump($bytes); - $counter++; + echo "\n-- Iteration $counter --\n"; + $result = vprintf($formats, $args); + echo "\n"; + var_dump($result); + $counter++; } ?> @@ -71,33 +78,41 @@ foreach($args_array as $args) { *** Testing vprintf() : octal formats and non-octal values *** -- Iteration 1 -- -string(180) ""2" "37777777776" "2" - "361100" "37720715133" "57062645" - " " " " "" - "57060664" "4475347" "37721631371" "37720717336" - "2" "361100" "2" "37777777776"" -int(180) +2 0 12 + 361100 37777775456 2322 + + 30071 14 37777777764 37777416700 + 12 361100 2 0 +int(112) -- Iteration 2 -- -string(122) ""0" "0" "0" - "173" "37777777605" "173 " - " " " " "" - "2322" "0" "$0" "_0" - "0" "173" "0" "0"" -int(122) +2 37777777776 2 + 361100 37720715133 57062645 + + 57060664 4475347 37721631371 37720717336 + 2 361100 2 37777777776 +int(142) -- Iteration 3 -- -string(109) ""1" "1" "1" - "1" " 1" "1 " - " " " " "" - "#1" "1" "$1" "_1" - "1" "1" "1" "1"" -int(109) +0 0 0 + 173 37777777605 173 + + 2322 0 $0 _0 + 0 173 0 0 +int(84) -- Iteration 4 -- -string(109) ""1" "1" "0" - "1" " 0" "1 " - " " " " "" - "#0" "1" "$1" "_0" - "0" "1" "1" "1"" -int(109) +1 1 1 + 1 1 1 + + #1 1 $1 _1 + 1 1 1 1 +int(71) + +-- Iteration 5 -- +1 1 0 + 1 0 1 + + #0 1 $1 _0 + 0 1 1 1 +int(71) diff --git a/ext/standard/tests/strings/vprintf_variation12_64bit.phpt b/ext/standard/tests/strings/vprintf_variation12_64bit.phpt index f9e11f30b2f5f..e3eee1268124e 100644 --- a/ext/standard/tests/strings/vprintf_variation12_64bit.phpt +++ b/ext/standard/tests/strings/vprintf_variation12_64bit.phpt @@ -15,16 +15,23 @@ echo "*** Testing vprintf() : octal formats and non-octal values ***\n"; // defining array of octal formats $formats = - '"%o" "%+o" "%-o" - "%lo" "%4o" "%-4o" - "%10.4o" "%-10.4o" "%.4o" - "%\'#2o" "%\'2o" "%\'$2o" "%\'_2o" - "%3$o" "%4$o" "%1$o" "%2$o"'; + '%o %+o %-o + %lo %4o %-4o + %10.4o %-10.4o %.4o + %\'#2o %\'2o %\'$2o %\'_2o + %3$o %4$o %1$o %2$o'; // Arrays of non octal values for the format defined in $format. // Each sub array contains non octal values which correspond to each format in $format $args_array = array( + // array of float values + array(2.2, .2, 10.2, + 123456.234, -1234.6789, +1234.6789, + 2e10, +2e12, 22e+12, + 12345.780, 12.000000011111, -12.00000111111, -123456.234, + 3.33, +4.44, 1.11,-2.22 ), + // array of int values array(2, -2, +2, 123456, -12346789, +12346789, @@ -59,46 +66,53 @@ $args_array = array( // and with non-octal values from the above $args_array array $counter = 1; foreach($args_array as $args) { - echo "\n-- Iteration $counter --\n"; - ob_start(); - $bytes = vprintf($formats, $args); - var_dump(ob_get_clean()); - var_dump($bytes); - $counter++; + echo "\n-- Iteration $counter --\n"; + $result = vprintf($formats, $args); + echo "\n"; + var_dump($result); + $counter++; } ?> ---EXPECTF-- +--EXPECT-- *** Testing vprintf() : octal formats and non-octal values *** -- Iteration 1 -- -string(235) ""2" "1777777777777777777776" "2" - "361100" "1777777777777720715133" "57062645" - " " " " "" - "57060664" "4475347" "1777777777777721631371" "1777777777777720717336" - "2" "361100" "2" "1777777777777777777776"" -int(235) +2 0 12 + 361100 1777777777777777775456 2322 + + 30071 14 1777777777777777777764 1777777777777777416700 + 12 361100 2 0 +int(149) -- Iteration 2 -- -string(133) ""0" "0" "0" - "173" "1777777777777777777605" "173 " - " " " " "" - "2322" "0" "$0" "_0" - "0" "173" "0" "0"" -int(133) +2 1777777777777777777776 2 + 361100 1777777777777720715133 57062645 + + 57060664 4475347 1777777777777721631371 1777777777777720717336 + 2 361100 2 1777777777777777777776 +int(201) -- Iteration 3 -- -string(109) ""1" "1" "1" - "1" " 1" "1 " - " " " " "" - "#1" "1" "$1" "_1" - "1" "1" "1" "1"" -int(109) +0 0 0 + 173 1777777777777777777605 173 + + 2322 0 $0 _0 + 0 173 0 0 +int(99) -- Iteration 4 -- -string(109) ""1" "1" "0" - "1" " 0" "1 " - " " " " "" - "#0" "1" "$1" "_0" - "0" "1" "1" "1"" -int(109) +1 1 1 + 1 1 1 + + #1 1 $1 _1 + 1 1 1 1 +int(75) + +-- Iteration 5 -- +1 1 0 + 1 0 1 + + #0 1 $1 _0 + 0 1 1 1 +int(75) diff --git a/ext/standard/tests/strings/vprintf_variation14.phpt b/ext/standard/tests/strings/vprintf_variation14.phpt index 4035cbc645b8e..ce65e8726d871 100644 --- a/ext/standard/tests/strings/vprintf_variation14.phpt +++ b/ext/standard/tests/strings/vprintf_variation14.phpt @@ -15,15 +15,23 @@ echo "*** Testing vprintf() : hexa formats and non-hexa values ***\n"; // defining array of different hexa formats $formats = - '"%x" "%+x" "%-x" - "%lx" "%4x" "%-4x" - "%10.4x" "%-10.4x" "%.4x" - "%\'#2x" "%\'2x" "%\'$2x" "%\'_2x" - "%3$x" "%4$x" "%1$x" "%2$x"'; + '%x %+x %-x + %lx x %4x %-4x + %10.4x %-10.4x %.4x + %\'#2x %\'2x %\'$2x %\'_2x + %3$x %4$x %1$x %2$x'; // Arrays of non hexa values for the format defined in $format. // Each sub array contains non hexa values which correspond to each format in $format $args_array = array( + + // array of float values + array(2.2, .2, 10.2, + 123456.234, -1234.6789, +1234.6789, + 2e10, +2e12, 22e+12, + 12345.780, 12.000000011111, -12.00000111111, -123456.234, + 3.33, +4.44, 1.11,-2.22 ), + // array of int values array(2, -2, +2, 123456, -12346789, +12346789, @@ -59,12 +67,11 @@ $args_array = array( $counter = 1; foreach($args_array as $args) { - echo "\n-- Iteration $counter --\n"; - ob_start(); - $bytes = vprintf($formats, $args); - var_dump(ob_get_clean()); - var_dump($bytes); - $counter++; + echo "\n-- Iteration $counter --\n"; + $result = vprintf($formats, $args); + echo "\n"; + var_dump($result); + $counter++; } ?> @@ -72,33 +79,41 @@ foreach($args_array as $args) { *** Testing vprintf() : hexa formats and non-hexa values *** -- Iteration 1 -- -string(158) ""2" "fffffffe" "2" - "1e240" "ff439a5b" "bc65a5" - " " " " "" - "bc61b4" "127ae7" "ff4732f9" "ff439ede" - "2" "1e240" "2" "fffffffe"" -int(158) +2 0 a + 1e240 x fffffb2e 4d2 + + 3039 c fffffff4 fffe1dc0 + a 1e240 2 0 +int(99) -- Iteration 2 -- -string(116) ""0" "0" "0" - "7b" "ffffff85" "7b " - " " " " "" - "4d2" "0" "$0" "_0" - "0" "7b" "0" "0"" -int(116) +2 fffffffe 2 + 1e240 x ff439a5b bc65a5 + + bc61b4 127ae7 ff4732f9 ff439ede + 2 1e240 2 fffffffe +int(122) -- Iteration 3 -- -string(109) ""1" "1" "1" - "1" " 1" "1 " - " " " " "" - "#1" "1" "$1" "_1" - "1" "1" "1" "1"" -int(109) +0 0 0 + 7b x ffffff85 7b + + 4d2 0 $0 _0 + 0 7b 0 0 +int(80) -- Iteration 4 -- -string(109) ""1" "1" "0" - "1" " 0" "1 " - " " " " "" - "#0" "1" "$1" "_0" - "0" "1" "1" "1"" -int(109) +1 1 1 + 1 x 1 1 + + #1 1 $1 _1 + 1 1 1 1 +int(73) + +-- Iteration 5 -- +1 1 0 + 1 x 0 1 + + #0 1 $1 _0 + 0 1 1 1 +int(73) diff --git a/ext/standard/tests/strings/vprintf_variation14_64bit.phpt b/ext/standard/tests/strings/vprintf_variation14_64bit.phpt index bda2f03fee92d..91ef18a9fb3b6 100644 --- a/ext/standard/tests/strings/vprintf_variation14_64bit.phpt +++ b/ext/standard/tests/strings/vprintf_variation14_64bit.phpt @@ -15,16 +15,23 @@ echo "*** Testing vprintf() : hexa formats and non-hexa values ***\n"; // defining array of different hexa formats $formats = - '"%x" "%+x" "%-x" - "%lx" "%4x" "%-4x" - "%10.4x" "%-10.4x" "%.4x" - "%\'#2x" "%\'2x" "%\'$2x" "%\'_2x" - "%3$x" "%4$x" "%1$x" "%2$x"'; + '%x %+x %-x + %lx %4x %-4x + %10.4x %-10.4x %.4x + %\'#2x %\'2x %\'$2x %\'_2x + %3$x %4$x %1$x %2$x'; // Arrays of non hexa values for the format defined in $format. // Each sub array contains non hexa values which correspond to each format in $format $args_array = array( + // array of float values + array(2.2, .2, 10.2, + 123456.234, -1234.6789, +1234.6789, + 2e10, +2e12, 22e+12, + 12345.780, 12.000000011111, -12.00000111111, -123456.234, + 3.33, +4.44, 1.11,-2.22 ), + // array of int values array(2, -2, +2, 123456, -12346789, +12346789, @@ -60,46 +67,53 @@ $args_array = array( $counter = 1; foreach($args_array as $args) { - echo "\n-- Iteration $counter --\n"; - ob_start(); - $bytes = vprintf($formats, $args); - var_dump(ob_get_clean()); - var_dump($bytes); - $counter++; + echo "\n-- Iteration $counter --\n"; + $result = vprintf($formats, $args); + echo "\n"; + var_dump($result); + $counter++; } ?> ---EXPECTF-- +--EXPECT-- *** Testing vprintf() : hexa formats and non-hexa values *** -- Iteration 1 -- -string(198) ""2" "fffffffffffffffe" "2" - "1e240" "ffffffffff439a5b" "bc65a5" - " " " " "" - "bc61b4" "127ae7" "ffffffffff4732f9" "ffffffffff439ede" - "2" "1e240" "2" "fffffffffffffffe"" -int(198) +2 0 a + 1e240 fffffffffffffb2e 4d2 + + 3039 c fffffffffffffff4 fffffffffffe1dc0 + a 1e240 2 0 +int(125) -- Iteration 2 -- -string(124) ""0" "0" "0" - "7b" "ffffffffffffff85" "7b " - " " " " "" - "4d2" "0" "$0" "_0" - "0" "7b" "0" "0"" -int(124) +2 fffffffffffffffe 2 + 1e240 ffffffffff439a5b bc65a5 + + bc61b4 127ae7 ffffffffff4732f9 ffffffffff439ede + 2 1e240 2 fffffffffffffffe +int(164) -- Iteration 3 -- -string(109) ""1" "1" "1" - "1" " 1" "1 " - " " " " "" - "#1" "1" "$1" "_1" - "1" "1" "1" "1"" -int(109) +0 0 0 + 7b ffffffffffffff85 7b + + 4d2 0 $0 _0 + 0 7b 0 0 +int(90) -- Iteration 4 -- -string(109) ""1" "1" "0" - "1" " 0" "1 " - " " " " "" - "#0" "1" "$1" "_0" - "0" "1" "1" "1"" -int(109) +1 1 1 + 1 1 1 + + #1 1 $1 _1 + 1 1 1 1 +int(75) + +-- Iteration 5 -- +1 1 0 + 1 0 1 + + #0 1 $1 _0 + 0 1 1 1 +int(75) diff --git a/ext/standard/tests/strings/vprintf_variation15.phpt b/ext/standard/tests/strings/vprintf_variation15.phpt index db27c694ca7b5..c8ae74f2aa75e 100644 --- a/ext/standard/tests/strings/vprintf_variation15.phpt +++ b/ext/standard/tests/strings/vprintf_variation15.phpt @@ -14,13 +14,13 @@ if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); echo "*** Testing vprintf() : unsigned formats and unsigned values ***\n"; // defining array of unsigned formats -$formats = [ - '"%u" "%+u" "%-u"', - '"%lu" "%4u" "%-4u"', - '"%10.4u" "%-10.4u" "%.4u"', - '"%\'#2u "%\'2u" "%\'$2u" "%\'_2u"', - '"%3$u" "%4$u" "%1$u" "%2$u"', -]; +$formats = array( + '%u %+u %-u', + '%lu %4u %-4u', + '%10.4u %-10.4u %.4u', + '%\'#2u %\'2u %\'$2u %\'_2u', + '%3$u %4$u %1$u %2$u' +); // Arrays of unsigned values for the format defined in $format. // Each sub array contains unsigned values which correspond to each format string in $format @@ -36,12 +36,11 @@ $args_array = array( // and with signed and other types of values from the above $args_array array $counter = 1; foreach($formats as $format) { - echo "\n-- Iteration $counter --\n"; - ob_start(); - $bytes = vprintf($format, $args_array[$counter-1]); - var_dump(ob_get_clean()); - var_dump($bytes); - $counter++; + echo "\n-- Iteration $counter --\n"; + $result = vprintf($format, $args_array[$counter-1]); + echo "\n"; + var_dump($result); + $counter++; } ?> @@ -49,21 +48,21 @@ foreach($formats as $format) { *** Testing vprintf() : unsigned formats and unsigned values *** -- Iteration 1 -- -string(22) ""1234567" "342391" "0"" -int(22) +1234567 342391 0 +int(16) -- Iteration 2 -- -string(27) ""3755744308" "1234" "12345"" -int(27) +3755744308 1234 12345 +int(21) -- Iteration 3 -- -string(31) "" 1234000" "2450319192" "120"" -int(31) + 1234000 2450319192 120 +int(25) -- Iteration 4 -- -string(17) ""#1 "0" "$0" "10"" -int(17) +#1 0 $0 10 +int(10) -- Iteration 5 -- -string(15) ""1" "2" "3" "4"" -int(15) +1 2 3 4 +int(7) diff --git a/ext/standard/tests/strings/vprintf_variation15_64bit.phpt b/ext/standard/tests/strings/vprintf_variation15_64bit.phpt index 91a6b2bf104ca..2729e8f54af74 100644 --- a/ext/standard/tests/strings/vprintf_variation15_64bit.phpt +++ b/ext/standard/tests/strings/vprintf_variation15_64bit.phpt @@ -14,13 +14,13 @@ if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); echo "*** Testing vprintf() : unsigned formats and unsigned values ***\n"; // defining array of unsigned formats -$formats = [ - '"%u" "%+u" "%-u"', - '"%lu" "%4u" "%-4u"', - '"%10.4u" "%-10.4u" "%.4u"', - '"%\'#2u "%\'2u" "%\'$2u" "%\'_2u"', - '"%3$u" "%4$u" "%1$u" "%2$u"', -]; +$formats = array( + '%u %+u %-u', + '%lu %4u %-4u', + '%10.4u %-10.4u %.4u', + '%\'#2u %\'2u %\'$2u %\'_2u', + '%3$u %4$u %1$u %2$u' +); // Arrays of unsigned values for the format defined in $format. // Each sub array contains unsigned values which correspond to each format string in $format @@ -36,12 +36,11 @@ $args_array = array( // and with signed and other types of values from the above $args_array array $counter = 1; foreach($formats as $format) { - echo "\n-- Iteration $counter --\n"; - ob_start(); - $bytes = vprintf($format, $args_array[$counter-1]); - var_dump(ob_get_clean()); - var_dump($bytes); - $counter++; + echo "\n-- Iteration $counter --\n"; + $result = vprintf($format, $args_array[$counter-1]); + echo "\n"; + var_dump($result); + $counter++; } ?> @@ -49,21 +48,21 @@ foreach($formats as $format) { *** Testing vprintf() : unsigned formats and unsigned values *** -- Iteration 1 -- -string(22) ""1234567" "342391" "0"" -int(22) +1234567 342391 0 +int(16) -- Iteration 2 -- -string(28) ""12345678900" "1234" "12345"" -int(28) +12345678900 1234 12345 +int(22) -- Iteration 3 -- -string(40) "" 1234000" "3875820019684212736" "120"" -int(40) + 1234000 3875820019684212736 120 +int(34) -- Iteration 4 -- -string(17) ""#1 "0" "$0" "10"" -int(17) +#1 0 $0 10 +int(10) -- Iteration 5 -- -string(15) ""1" "2" "3" "4"" -int(15) +1 2 3 4 +int(7) diff --git a/ext/standard/tests/strings/vprintf_variation16.phpt b/ext/standard/tests/strings/vprintf_variation16.phpt index 31288d03ca679..70ecdab99e071 100644 --- a/ext/standard/tests/strings/vprintf_variation16.phpt +++ b/ext/standard/tests/strings/vprintf_variation16.phpt @@ -15,16 +15,23 @@ echo "*** Testing vprintf() : unsigned formats and signed & other types of value // defining array of unsigned formats $formats = - '"%u" "%+u" "%-u" - "%lu" "%4u" "%-4u" - "%10.4u" "%-10.4u" "%.4u" - "%\'#2u "%\'2u" "%\'$2u" "%\'_2u" - "%3$u" "%4$u" "%1$u" "%2$u"'; + '%u %+u %-u + %lu %4u %-4u + %10.4u %-10.4u %.4u + %\'#2u %\'2u %\'$2u %\'_2u + %3$u %4$u %1$u %2$u'; // Arrays of signed and other type of values for the format defined in $format. // Each sub array contains signed values which correspond to each format in $format $args_array = array( + // array of float values + array(+2.2, +.2, +10.2, + +123456.234, +123456.234, +1234.6789, + +2e10, +2e12, +22e+12, + +12345.780, +12.000000011111, -12.00000111111, -123456.234, + +3.33, +4.44, +1.11,-2.22 ), + // array of strings array(" ", ' ', 'hello', '123hello', '-123hello', '+123hello', @@ -52,37 +59,44 @@ $args_array = array( // and with signed and other types of values from the above $args_array array $counter = 1; foreach($args_array as $args) { - echo "\n-- Iteration $counter --\n"; - ob_start(); - $bytes = vprintf($formats, $args); - var_dump(ob_get_clean()); - var_dump($bytes); - $counter++; + echo "\n-- Iteration $counter --\n"; + $result = vprintf($formats, $args); + echo "\n"; + var_dump($result); + $counter++; } ?> --EXPECT-- *** Testing vprintf() : unsigned formats and signed & other types of values *** -- Iteration 1 -- -string(121) ""0" "0" "0" - "123" "4294967173" "123 " - " 0" "0 " "0" - "1234 "0" "$0" "_0" - "0" "123" "0" "0"" -int(121) +2 0 10 + 123456 123456 1234 + 2820130816 2840207360 1177509888 + 12345 12 4294967284 4294843840 + 10 123456 2 0 +int(115) -- Iteration 2 -- -string(109) ""1" "1" "1" - "1" " 1" "1 " - " 1" "1 " "1" - "#1 "1" "$1" "_1" - "1" "1" "1" "1"" -int(109) +0 0 0 + 123 4294967173 123 + 0 0 0 + 1234 0 $0 _0 + 0 123 0 0 +int(84) -- Iteration 3 -- -string(109) ""1" "1" "0" - "1" " 0" "1 " - " 1" "1 " "0" - "#0 "1" "$1" "_0" - "0" "1" "1" "1"" -int(109) +1 1 1 + 1 1 1 + 1 1 1 + #1 1 $1 _1 + 1 1 1 1 +int(72) + +-- Iteration 4 -- +1 1 0 + 1 0 1 + 1 1 0 + #0 1 $1 _0 + 0 1 1 1 +int(72) diff --git a/ext/standard/tests/strings/vprintf_variation16_64bit.phpt b/ext/standard/tests/strings/vprintf_variation16_64bit.phpt index ffa4f9213b17b..9ea63998bfe03 100644 --- a/ext/standard/tests/strings/vprintf_variation16_64bit.phpt +++ b/ext/standard/tests/strings/vprintf_variation16_64bit.phpt @@ -15,15 +15,23 @@ echo "*** Testing vprintf() : unsigned formats and signed & other types of value // defining array of unsigned formats $formats = - '"%u" "%+u" "%-u" - "%lu" "%4u" "%-4u" - "%10.4u" "%-10.4u" "%.4u" - "%\'#2u "%\'2u" "%\'$2u" "%\'_2u" - "%3$u" "%4$u" "%1$u" "%2$u"'; + '%u %+u %-u + %lu %4u %-4u + %10.4u %-10.4u %.4u + %\'#2u %\'2u %\'$2u %\'_2u + %3$u %4$u %1$u %2$u'; // Arrays of signed and other type of values for the format defined in $format. // Each sub array contains signed values which correspond to each format in $format $args_array = array( + + // array of float values + array(+2.2, +.2, +10.2, + +123456.234, +123456.234, +1234.6789, + +2e10, +2e12, +22e+12, + +12345.780, +12.000000011111, -12.00000111111, -123456.234, + +3.33, +4.44, +1.11,-2.22 ), + // array of strings array(" ", ' ', 'hello', '123hello', '-123hello', '+123hello', @@ -51,12 +59,11 @@ $args_array = array( // and with signed and other types of values from the above $args_array array $counter = 1; foreach($args_array as $args) { - echo "\n-- Iteration $counter --\n"; - ob_start(); - $bytes = vprintf($formats, $args); - var_dump(ob_get_clean()); - var_dump($bytes); - $counter++; + echo "\n-- Iteration $counter --\n"; + $result = vprintf($formats, $args); + echo "\n"; + var_dump($result); + $counter++; } ?> @@ -64,25 +71,33 @@ foreach($args_array as $args) { *** Testing vprintf() : unsigned formats and signed & other types of values *** -- Iteration 1 -- -string(131) ""0" "0" "0" - "123" "18446744073709551493" "123 " - " 0" "0 " "0" - "1234 "0" "$0" "_0" - "0" "123" "0" "0"" -int(131) +2 0 10 + 123456 123456 1234 + 20000000000 2000000000000 22000000000000 + 12345 12 18446744073709551604 18446744073709428160 + 10 123456 2 0 +int(147) -- Iteration 2 -- -string(109) ""1" "1" "1" - "1" " 1" "1 " - " 1" "1 " "1" - "#1 "1" "$1" "_1" - "1" "1" "1" "1"" -int(109) +0 0 0 + 123 18446744073709551493 123 + 0 0 0 + 1234 0 $0 _0 + 0 123 0 0 +int(98) -- Iteration 3 -- -string(109) ""1" "1" "0" - "1" " 0" "1 " - " 1" "1 " "0" - "#0 "1" "$1" "_0" - "0" "1" "1" "1"" -int(109) +1 1 1 + 1 1 1 + 1 1 1 + #1 1 $1 _1 + 1 1 1 1 +int(76) + +-- Iteration 4 -- +1 1 0 + 1 0 1 + 1 1 0 + #0 1 $1 _0 + 0 1 1 1 +int(76) diff --git a/ext/standard/tests/strings/vprintf_variation4.phpt b/ext/standard/tests/strings/vprintf_variation4.phpt index be5b4d2a2a0c0..63018a9db8a86 100644 --- a/ext/standard/tests/strings/vprintf_variation4.phpt +++ b/ext/standard/tests/strings/vprintf_variation4.phpt @@ -2,7 +2,7 @@ Test vprintf() function : usage variations - int formats with non-integer values --SKIPIF-- --FILE-- @@ -64,25 +71,33 @@ foreach($args_array as $args) { *** Testing vprintf() : int formats and non-integer values *** -- Iteration 1 -- -string(129) ""0" "+0" "0" - "123" "-123" "123 " - " 0" "0 " "123456" "0000" - "1234" "0" "$0" "_0" - "0" "123" "0" "0"" -int(129) +2 +0 10 + 123456 -1234 1234 + -1474836480 200000 4000 22000000 + 12345 12 -12 -123456 + 10 123456 2 0 +int(109) -- Iteration 2 -- -string(118) ""1" "+1" "1" - "1" " 1" "1 " - " 1" "1 " "1" "0001" - "#1" "1" "$1" "_1" - "1" "1" "1" "1"" -int(118) +0 +0 0 + 123 -123 123 + 0 0 123456 0000 + 1234 0 $0 _0 + 0 123 0 0 +int(89) -- Iteration 3 -- -string(118) ""1" "+1" "0" - "1" " 0" "1 " - " 1" "0 " "1" "0000" - "#0" "1" "$1" "_0" - "0" "1" "1" "1"" -int(118) +1 +1 1 + 1 1 1 + 1 1 1 0001 + #1 1 $1 _1 + 1 1 1 1 +int(78) + +-- Iteration 4 -- +1 +1 0 + 1 0 1 + 1 0 1 0000 + #0 1 $1 _0 + 0 1 1 1 +int(78) diff --git a/ext/standard/tests/strings/vprintf_variation4_64bit.phpt b/ext/standard/tests/strings/vprintf_variation4_64bit.phpt new file mode 100644 index 0000000000000..5631a9adb72f1 --- /dev/null +++ b/ext/standard/tests/strings/vprintf_variation4_64bit.phpt @@ -0,0 +1,103 @@ +--TEST-- +Test vprintf() function : usage variations - int formats with non-integer values +--SKIPIF-- + +--FILE-- +"12twelve"), + array("3"), array("4"), array("1"), array("2") ), + + // array of boolean data + array( true, TRUE, false, + TRUE, FALSE, 1, + true, false, TRUE, FALSE, + 0, 1, 1, 0, + 1, TRUE, 0, FALSE), + +); + +// looping to test vprintf() with different int formats from the above $format array +// and with non-int values from the above $args_array array +$counter = 1; +foreach($args_array as $args) { + echo "\n-- Iteration $counter --\n"; + $result = vprintf($formats, $args); + echo "\n"; + var_dump($result); + $counter++; +} + +?> +--EXPECT-- +*** Testing vprintf() : int formats and non-integer values *** + +-- Iteration 1 -- +2 +0 10 + 123456 -1234 1234 + 20000000000 200000 4000 22000000 + 12345 12 -12 -123456 + 10 123456 2 0 +int(113) + +-- Iteration 2 -- +0 +0 0 + 123 -123 123 + 0 0 123456 0000 + 1234 0 $0 _0 + 0 123 0 0 +int(93) + +-- Iteration 3 -- +1 +1 1 + 1 1 1 + 1 1 1 0001 + #1 1 $1 _1 + 1 1 1 1 +int(82) + +-- Iteration 4 -- +1 +1 0 + 1 0 1 + 1 0 1 0000 + #0 1 $1 _0 + 0 1 1 1 +int(82) From 09a8044f2e99720a4541c6f5c0bb1106ce7c490a Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Mon, 31 May 2021 12:19:01 +0100 Subject: [PATCH 61/61] Fix copy/paste mistake from 32bit to 64bit tests in math tests --- ext/standard/tests/math/decbin_variation1_64bit.phpt | 8 ++++---- ext/standard/tests/math/dechex_variation1_64bit.phpt | 8 ++++---- ext/standard/tests/math/decoct_variation1_64bit.phpt | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ext/standard/tests/math/decbin_variation1_64bit.phpt b/ext/standard/tests/math/decbin_variation1_64bit.phpt index 1ba3a6387130b..0d4e18307eab1 100644 --- a/ext/standard/tests/math/decbin_variation1_64bit.phpt +++ b/ext/standard/tests/math/decbin_variation1_64bit.phpt @@ -16,8 +16,8 @@ $inputs = [ 1, 12345, -2345, - 4294967295, // largest decimal - 4294967296, + 18446744073709551615, // largest decimal + 18446744073709551616, // float data /* 7*/ 12.3456789000e10, @@ -61,10 +61,10 @@ string(14) "11000000111001" string(64) "1111111111111111111111111111111111111111111111111111011011010111" -- Iteration 5 -- -string(32) "11111111111111111111111111111111" +decbin(): Argument #1 ($num) must be of type int, float given -- Iteration 6 -- -string(33) "100000000000000000000000000000000" +decbin(): Argument #1 ($num) must be of type int, float given -- Iteration 7 -- string(37) "1110010111110100110010001101000001000" diff --git a/ext/standard/tests/math/dechex_variation1_64bit.phpt b/ext/standard/tests/math/dechex_variation1_64bit.phpt index ed04b43e3e04c..bd597b2f996a6 100644 --- a/ext/standard/tests/math/dechex_variation1_64bit.phpt +++ b/ext/standard/tests/math/dechex_variation1_64bit.phpt @@ -16,8 +16,8 @@ $inputs = [ 1, 12345, -2345, - 4294967295, // largest decimal - 4294967296, + 18446744073709551615, // largest decimal + 18446744073709551616, // float data /* 7*/ 12.3456789000e10, @@ -61,10 +61,10 @@ string(4) "3039" string(16) "fffffffffffff6d7" -- Iteration 5 -- -string(8) "ffffffff" +dechex(): Argument #1 ($num) must be of type int, float given -- Iteration 6 -- -string(9) "100000000" +dechex(): Argument #1 ($num) must be of type int, float given -- Iteration 7 -- string(10) "1cbe991a08" diff --git a/ext/standard/tests/math/decoct_variation1_64bit.phpt b/ext/standard/tests/math/decoct_variation1_64bit.phpt index b6d3a4a391d4d..cc4b69f07560f 100644 --- a/ext/standard/tests/math/decoct_variation1_64bit.phpt +++ b/ext/standard/tests/math/decoct_variation1_64bit.phpt @@ -16,8 +16,8 @@ $inputs = [ 1, 12345, -2345, - 4294967295, // largest decimal - 4294967296, + 18446744073709551615, // largest decimal + 18446744073709551616, // float data /* 7*/ 12.3456789000e10, @@ -61,10 +61,10 @@ string(5) "30071" string(22) "1777777777777777773327" -- Iteration 5 -- -string(11) "37777777777" +decoct(): Argument #1 ($num) must be of type int, float given -- Iteration 6 -- -string(11) "40000000000" +decoct(): Argument #1 ($num) must be of type int, float given -- Iteration 7 -- string(13) "1627646215010"