diff --git a/Zend/Optimizer/pass1.c b/Zend/Optimizer/pass1.c index 851d77c7df4e5..62354215d5aad 100644 --- a/Zend/Optimizer/pass1.c +++ b/Zend/Optimizer/pass1.c @@ -119,12 +119,12 @@ 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) { - /* 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)); + zval *op2 = &ZEND_OP2_LITERAL(opline); + if (Z_TYPE_P(op2) != IS_LONG) { + if (!zend_is_op_long_compatible(op2)) { + break; } + convert_to_long(op2); } } else if (opline->extended_value == ZEND_CONCAT) { if (Z_TYPE(ZEND_OP2_LITERAL(opline)) != IS_STRING) { diff --git a/Zend/Optimizer/sccp.c b/Zend/Optimizer/sccp.c index 66688b3424505..f85f7c6ae39ec 100644 --- a/Zend/Optimizer/sccp.c +++ b/Zend/Optimizer/sccp.c @@ -425,9 +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: - *result = zend_hash_index_find(Z_ARR_P(op1), zend_dval_to_lval(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), lval); return SUCCESS; + } case IS_STRING: *result = zend_symtable_find(Z_ARR_P(op1), Z_STR_P(op2)); return SUCCESS; @@ -508,9 +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: - zend_hash_index_del(Z_ARR_P(result), zend_dval_to_lval(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), lval); break; + } case IS_STRING: zend_symtable_del(Z_ARR_P(result), Z_STR_P(key)); break; @@ -548,11 +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)); + if (!zend_is_long_compatible(Z_DVAL_P(key), lval)) { + return FAILURE; + } SEPARATE_ARRAY(result); 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/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: diff --git a/Zend/tests/array_offset.phpt b/Zend/tests/array_offset.phpt index 6126db9748fd6..09a10c7429e42 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 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 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/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/bug72347.phpt b/Zend/tests/bug72347.phpt index b86457207df5e..6867aea921d94 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 from non-compatible float 1.5 to int 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..ea148c9ecf4ae 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 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 f89987109df5b..3ca72e8daf39d 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 from non-compatible float -1.1 to int in %s on line %d bool(false) + +Deprecated: Implicit conversion from non-compatible float -10.5 to int in %s on line %d bool(true) + +Deprecated: Implicit conversion from non-compatible float -4.1 to int in %s on line %d bool(true) + +Deprecated: Implicit conversion from non-compatible float -0.8 to int in %s on line %d bool(false) + +Deprecated: Implicit conversion from non-compatible float -0.1 to int in %s on line %d bool(false) + +Deprecated: Implicit conversion from non-compatible float 0.2 to int in %s on line %d bool(false) + +Deprecated: Implicit conversion from non-compatible float 0.9 to int in %s on line %d bool(false) + +Deprecated: Implicit conversion from non-compatible float 3.141592653589793 to int in %s on line %d bool(false) + +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/explicit_casts_should_not_warn.phpt b/Zend/tests/float_to_int/explicit_casts_should_not_warn.phpt new file mode 100644 index 0000000000000..71c68e57574bf --- /dev/null +++ b/Zend/tests/float_to_int/explicit_casts_should_not_warn.phpt @@ -0,0 +1,38 @@ +--TEST-- +Explicit (int) cast must not warn +--SKIPIF-- + +--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/explicit_casts_should_not_warn_32bit.phpt b/Zend/tests/float_to_int/explicit_casts_should_not_warn_32bit.phpt new file mode 100644 index 0000000000000..fee011df06ea8 --- /dev/null +++ b/Zend/tests/float_to_int/explicit_casts_should_not_warn_32bit.phpt @@ -0,0 +1,38 @@ +--TEST-- +Explicit (int) cast must not warn 32bit variation +--SKIPIF-- + +--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/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) 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/union_int_string_type_arg.phpt b/Zend/tests/float_to_int/union_int_string_type_arg.phpt new file mode 100644 index 0000000000000..4fcabceea4cb1 --- /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 from non-compatible float 1.5 to int in %s on line %d +int(1) +string(3) "NAN" +string(8) "1.0E+121" +string(3) "INF" 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..e1c86e5f44ccb --- /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) +bool(true) + +Deprecated: Implicit conversion from non-compatible float 1.0E+121 to int 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" + ["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 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 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 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..e298783fb86e5 --- /dev/null +++ b/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_strings.phpt @@ -0,0 +1,109 @@ +--TEST-- +Implicit float to int conversions when float too large should warn, string offset variant +--SKIPIF-- + +--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" +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_strings_32bit.phpt b/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_strings_32bit.phpt new file mode 100644 index 0000000000000..b2f83883830cc --- /dev/null +++ b/Zend/tests/float_to_int/warning_float_does_not_fit_zend_long_strings_32bit.phpt @@ -0,0 +1,109 @@ +--TEST-- +Implicit float to int conversions when float too large should warn, string offset variant, 32bit variant +--SKIPIF-- + +--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/float_to_int/warnings_float_literals.phpt b/Zend/tests/float_to_int/warnings_float_literals.phpt new file mode 100644 index 0000000000000..8d9658cb75d5c --- /dev/null +++ b/Zend/tests/float_to_int/warnings_float_literals.phpt @@ -0,0 +1,140 @@ +--TEST-- +Implicit float to int conversions should warn for literals +--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)); + +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-- +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 +int(1) +Offset access: +Arrays: + +Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d +string(1) "b" + +Deprecated: Implicit conversion from non-compatible float 2.5 to int 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 from non-compatible float 1.5 to int in %s on line %d +int(1) + +Deprecated: Implicit conversion from non-compatible float 60.5 to int in %s on line %d +string(1) "<" +Function returns: + +Deprecated: Implicit conversion from non-compatible float 3.5 to int in %s on line %d +int(3) +Typed property assignment: + +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_literals_assignment_ops.phpt b/Zend/tests/float_to_int/warnings_float_literals_assignment_ops.phpt new file mode 100644 index 0000000000000..17d7cca8d0e43 --- /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 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(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 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 new file mode 100644 index 0000000000000..ea9fabb769c39 --- /dev/null +++ b/Zend/tests/float_to_int/warnings_float_vars.phpt @@ -0,0 +1,168 @@ +--TEST-- +Implicit float to int conversions should warn for variables +--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)); + +$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 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(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 +int(1) +Offset access: +Arrays: + +Deprecated: Implicit conversion from non-compatible float 1.5 to int in %s on line %d +string(1) "b" + +Deprecated: Implicit conversion from non-compatible float 2.5 to int 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 from non-compatible float 1.5 to int in %s on line %d +int(1) + +Deprecated: Implicit conversion from non-compatible float 60.5 to int in %s on line %d +string(1) "<" +Function returns: + +Deprecated: Implicit conversion from non-compatible float 3.5 to int in %s on line %d +int(3) +Typed property assignment: + +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_string_float_literals.phpt b/Zend/tests/float_to_int/warnings_string_float_literals.phpt new file mode 100644 index 0000000000000..ceb8ec7d04331 --- /dev/null +++ b/Zend/tests/float_to_int/warnings_string_float_literals.phpt @@ -0,0 +1,98 @@ +--TEST-- +Implicit string float to int conversions should warn for literals +--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')); + +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-- +Bitwise ops: + +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d +int(3) + +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d +int(1) + +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d +int(2) + +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d +int(8) + +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d +int(0) + +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d +int(6) + +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d +int(1) +Modulo: + +Deprecated: Implicit conversion from non-compatible float-string "6.5" to int in %s on line %d +int(0) + +Deprecated: Implicit conversion from non-compatible float-string "2.5" to int in %s on line %d +int(1) +Function calls: + +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d +int(1) + +Deprecated: Implicit conversion from non-compatible float-string "60.5" to int in %s on line %d +string(1) "<" +Function returns: + +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 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 new file mode 100644 index 0000000000000..57ea66d134bf3 --- /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 from non-compatible float-string "1.5" to int in %s on line %d +int(3) + +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d +int(1) + +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d +int(2) + +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d +int(6) + +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d +int(1) +Modulo: + +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 new file mode 100644 index 0000000000000..b60a9e9cb0db4 --- /dev/null +++ b/Zend/tests/float_to_int/warnings_string_float_vars.phpt @@ -0,0 +1,124 @@ +--TEST-- +Implicit float string to int conversions should warn for variables +--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)); + +$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 from non-compatible float-string "1.5" to int in %s on line %d +int(3) + +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d +int(1) + +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d +int(2) + +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d +int(8) + +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d +int(0) + +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d +int(8) + +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d +int(0) + +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d +int(6) + +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d +int(1) +Modulo: + +Deprecated: Implicit conversion from non-compatible float-string "6.5" to int in %s on line %d +int(0) + +Deprecated: Implicit conversion from non-compatible float-string "2.5" to int in %s on line %d +int(1) +Function calls: + +Deprecated: Implicit conversion from non-compatible float-string "1.5" to int in %s on line %d +int(1) + +Deprecated: Implicit conversion from non-compatible float-string "60.5" to int in %s on line %d +string(1) "<" +Function returns: + +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 from non-compatible float-string "1.5" to int in %s on line %d +int(1) diff --git a/Zend/tests/isset_array.phpt b/Zend/tests/isset_array.phpt index c7c1876410d71..70ad03084a611 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 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 5f7b72771f593..252f913586288 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 from non-compatible float -1.1 to int in %s on line %d bool(true) + +Deprecated: Implicit conversion from non-compatible float -10.5 to int in %s on line %d bool(false) + +Deprecated: Implicit conversion from non-compatible float -0.8 to int in %s on line %d bool(true) + +Deprecated: Implicit conversion from non-compatible float -0.1 to int in %s on line %d bool(true) + +Deprecated: Implicit conversion from non-compatible float 0.2 to int in %s on line %d bool(true) + +Deprecated: Implicit conversion from non-compatible float 0.9 to int in %s on line %d bool(true) + +Deprecated: Implicit conversion from non-compatible float 3.141592653589793 to int in %s on line %d bool(true) + +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 6b213d60f41d8..71f4c0759960b 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 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 2d7f85a8b4b1c..d45a3734c99be 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 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 bd6baa1651635..fc646704f4f50 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 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 94e23ec60376a..9ba94895b31d3 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 from non-compatible float 3.5 to int 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 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/tests/type_declarations/scalar_basic.phpt b/Zend/tests/type_declarations/scalar_basic.phpt index 908f1a18b248e..22e8dedc1aa47 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 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.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 e49b9f5b2ad36..10e0390ce88ff 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 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/zend_API.c b/Zend/zend_API.c index 1e062534ce0f6..ca4ca0caffbd7 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -503,7 +503,18 @@ 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)); + zend_long lval = zend_dval_to_lval(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; + } + } + *dest = lval; } } else if (EXPECTED(Z_TYPE_P(arg) == IS_STRING)) { double d; @@ -511,14 +522,27 @@ 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; } if (UNEXPECTED(!ZEND_DOUBLE_FITS_LONG(d))) { return 0; - } else { - *dest = zend_dval_to_lval(d); } + + lval = zend_dval_to_lval(d); + /* 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; + } + } + *dest = lval; } else { return 0; } @@ -1971,7 +1995,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..ac97499e90bc5 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -8156,6 +8156,28 @@ static bool zend_try_ct_eval_magic_const(zval *zv, zend_ast *ast) /* {{{ */ } /* }}} */ +ZEND_API bool zend_is_op_long_compatible(zval *op) +{ + 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)))) { + 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)) { @@ -8207,6 +8229,12 @@ 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) { + return !zend_is_op_long_compatible(op1) || !zend_is_op_long_compatible(op2); + } + return 0; } /* }}} */ @@ -8226,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; + return Z_TYPE_P(op) <= IS_TRUE || !zend_is_op_long_compatible(op); } return 0; @@ -8353,10 +8381,17 @@ 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(Z_DVAL_P(key)), value); + case IS_DOUBLE: { + zend_long lval = zend_dval_to_lval(Z_DVAL_P(key)); + /* Incompatible float will generate an error, leave this to run-time */ + if (!zend_is_long_compatible(Z_DVAL_P(key), lval)) { + zval_ptr_dtor_nogc(value); + zval_ptr_dtor(result); + return 0; + } + 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; 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); diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 1b0dd4f232afa..1bf857151caca 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -775,16 +775,18 @@ static bool zend_verify_weak_scalar_type_hint_no_sideeffect(uint32_t type_mask, double dval; bool bval; - if ((type_mask & MAY_BE_LONG) && zend_parse_arg_long_weak(arg, &lval, 0)) { + /* 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 typed properties) */ + if ((type_mask & MAY_BE_LONG) && zend_parse_arg_long_weak(arg, &lval, (uint32_t)-1)) { return 1; } - if ((type_mask & MAY_BE_DOUBLE) && zend_parse_arg_double_weak(arg, &dval, 0)) { + if ((type_mask & MAY_BE_DOUBLE) && zend_parse_arg_double_weak(arg, &dval, (uint32_t)-1)) { return 1; } if ((type_mask & MAY_BE_STRING) && can_convert_to_string(arg)) { return 1; } - if ((type_mask & MAY_BE_BOOL) == MAY_BE_BOOL && zend_parse_arg_bool_weak(arg, &bval, 0)) { + if ((type_mask & MAY_BE_BOOL) == MAY_BE_BOOL && zend_parse_arg_bool_weak(arg, &bval, (uint32_t)-1)) { return 1; } return 0; @@ -1470,7 +1472,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, /* is_strict */ false); } else { offset = Z_LVAL_P(dim); } @@ -2133,7 +2135,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 +2454,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_strict */ false); } else { offset = Z_LVAL_P(dim); } @@ -2543,7 +2545,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) { @@ -2597,7 +2599,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_strict */ true); goto str_offset; } return 0; @@ -2636,7 +2638,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_strict */ true); goto str_offset; } return 1; @@ -2667,7 +2669,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..dafa225351c41 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -303,8 +303,17 @@ 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: - return zend_dval_to_lval(Z_DVAL_P(op)); + case IS_DOUBLE: { + double dval = Z_DVAL_P(op); + zend_long lval = zend_dval_to_lval(dval); + if (!zend_is_long_compatible(dval, lval)) { + zend_incompatible_double_to_long_error(dval); + if (UNEXPECTED(EG(exception))) { + *failed = 1; + } + } + return lval; + } case IS_STRING: { zend_uchar type; @@ -333,7 +342,14 @@ 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); + lval = zend_dval_to_lval_cap(dval); + if (!zend_is_long_compatible(dval, lval)) { + zend_incompatible_string_to_long_error(Z_STR_P(op)); + if (UNEXPECTED(EG(exception))) { + *failed = 1; + } + } + return lval; } } case IS_OBJECT: @@ -792,7 +808,16 @@ ZEND_API void ZEND_FASTCALL convert_to_object(zval *op) /* {{{ */ } /* }}} */ -ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op) /* {{{ */ +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_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)); +} + +ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op, bool is_strict) /* {{{ */ { try_again: switch (Z_TYPE_P(op)) { @@ -806,8 +831,16 @@ ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op) /* {{{ */ return Z_RES_HANDLE_P(op); case IS_LONG: return Z_LVAL_P(op); - case IS_DOUBLE: - return zend_dval_to_lval(Z_DVAL_P(op)); + case IS_DOUBLE: { + double dval = Z_DVAL_P(op); + zend_long lval = zend_dval_to_lval(dval); + if (UNEXPECTED(is_strict)) { + if (!zend_is_long_compatible(dval, lval)) { + zend_incompatible_double_to_long_error(dval); + } + } + return lval; + } case IS_STRING: { zend_uchar type; @@ -823,7 +856,14 @@ 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 */ + lval = zend_dval_to_lval_cap(dval); + if (UNEXPECTED(is_strict)) { + if (!zend_is_long_compatible(dval, lval)) { + zend_incompatible_string_to_long_error(Z_STR_P(op)); + } + } + return lval; } } case IS_ARRAY: @@ -1455,9 +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: - ZVAL_LONG(result, ~zend_dval_to_lval(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; diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index 3fe8b0e384ea4..5a01dd0b75d11 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,22 @@ 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; +} + +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) +{ + zend_long l = zend_dval_to_lval(d); + if (!zend_is_long_compatible(d, l)) { + zend_incompatible_double_to_long_error(d); + } + return l; +} + #define ZEND_IS_DIGIT(c) ((c) >= '0' && (c) <= '9') #define ZEND_IS_XDIGIT(c) (((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f')) @@ -267,13 +284,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_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); + 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_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 23186d939333e..a01f2c418aebd 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; @@ -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(); @@ -9613,7 +9613,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_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 bf12fd20dc781..70ebf54b4eeac 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -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; @@ -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_strict */ true); } ht = Z_ARRVAL_P(container); ZEND_HASH_INDEX_FIND(ht, offset, value, fetch_dim_r_index_undef); @@ -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; @@ -16101,7 +16101,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_strict */ true); } ht = Z_ARRVAL_P(container); ZEND_HASH_INDEX_FIND(ht, offset, value, fetch_dim_r_index_undef); @@ -16153,7 +16153,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_strict */ true); } ht = Z_ARRVAL_P(container); ZEND_HASH_INDEX_FIND(ht, offset, value, fetch_dim_r_index_undef); @@ -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; @@ -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(); @@ -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(); @@ -42563,7 +42563,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_strict */ true); } ht = Z_ARRVAL_P(container); ZEND_HASH_INDEX_FIND(ht, offset, value, fetch_dim_r_index_undef); @@ -42615,7 +42615,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_strict */ true); } ht = Z_ARRVAL_P(container); ZEND_HASH_INDEX_FIND(ht, offset, value, fetch_dim_r_index_undef); @@ -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/calendar/tests/bug80185.phpt b/ext/calendar/tests/bug80185.phpt index dfc843270ec82..b239468109e7b 100644 --- a/ext/calendar/tests/bug80185.phpt +++ b/ext/calendar/tests/bug80185.phpt @@ -9,14 +9,14 @@ if (PHP_INT_SIZE != 8) die("skip for 64bit platforms only"); --FILE-- getMessage(), PHP_EOL; } ?> ---EXPECT-- +--EXPECTF-- int(2170713600) int(9223372036854720000) 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/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/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/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/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/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 64298b0d66288..bbd33268778e6 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 from non-compatible float 10.5 to int in %s on line %d bool(true) --float -10.5-- + +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 --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 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..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[$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[$trend] = $i; + $values[(string)$trend] = $i; } krsort($values); diff --git a/ext/opcache/jit/zend_jit_helpers.c b/ext/opcache/jit/zend_jit_helpers.c index 99e48fd793198..e7f98665fba7a 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)); @@ -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_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); + offset = zval_get_long_func(dim, /* is_strict */ false); } else { offset = Z_LVAL_P(dim); } @@ -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; } } 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; 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 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/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/session/tests/session_encode_error2.phpt b/ext/session/tests/session_encode_error2.phpt index a2d3d0ca309a6..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,124 +75,11 @@ bool(true) -- Iteration 5 -- bool(true) - -Warning: session_encode(): Skipping numeric key 10 in %s on line %d -bool(false) -bool(true) - --- Iteration 6 -- -bool(true) - -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) - -Warning: session_encode(): Skipping numeric key 0 in %s on line %d -bool(false) -bool(true) - --- Iteration 9 -- -bool(true) - -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-- 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/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/spl/tests/iterator_to_array_nonscalar_keys.phpt b/ext/spl/tests/iterator_to_array_nonscalar_keys.phpt index 1920b31639b1e..cb9917368e664 100644 --- a/ext/spl/tests/iterator_to_array_nonscalar_keys.phpt +++ b/ext/spl/tests/iterator_to_array_nonscalar_keys.phpt @@ -19,5 +19,6 @@ try { } ?> ---EXPECT-- +--EXPECTF-- +Deprecated: Implicit conversion from non-compatible float 2.5 to int in %s on line %d Illegal offset type diff --git a/ext/standard/array.c b/ext/standard/array.c index a04125db870df..d545dc26edd18 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -6052,7 +6052,7 @@ 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)))); + 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/array/array_column_basic.phpt b/ext/standard/tests/array/array_column_basic.phpt index 42e457617750b..ec26ef3d5fd1e 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 from non-compatible float 0.123 to int in %s on line %d array(3) { ["aaa"]=> string(3) "111" @@ -256,6 +258,8 @@ array(3) { [2]=> string(3) "ccc" } + +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_combine_variation4.phpt b/ext/standard/tests/array/array_combine_variation4.phpt index ae4d54a626ac0..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") ); @@ -142,7 +142,7 @@ array(2) { string(8) "resource" } -- Iteration 9 -- -array(7) { +array(6) { [1]=> int(1) ["2.2"]=> @@ -151,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 901b03b8b579b..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-- bool(true) [1]=> @@ -89,7 +89,7 @@ start: 0 num: 2.5 value: array(2) { } =========================== bool(false) -start: 0 num: 2.5 value: array(2) { +start: 0 num: 2 value: array(2) { [0]=> bool(false) [1]=> @@ -97,7 +97,7 @@ start: 0 num: 2.5 value: array(2) { } =========================== NULL -start: 0 num: 2.5 value: array(2) { +start: 0 num: 2 value: array(2) { [0]=> NULL [1]=> @@ -105,7 +105,7 @@ start: 0 num: 2.5 value: array(2) { } =========================== string(1) "d" -start: 0 num: 2.5 value: array(2) { +start: 0 num: 2 value: array(2) { [0]=> string(1) "d" [1]=> @@ -113,7 +113,7 @@ start: 0 num: 2.5 value: array(2) { } =========================== string(1) "e" -start: 0 num: 2.5 value: array(2) { +start: 0 num: 2 value: array(2) { [0]=> string(1) "e" [1]=> @@ -121,7 +121,7 @@ start: 0 num: 2.5 value: array(2) { } =========================== string(1) "f" -start: 0 num: 2.5 value: array(2) { +start: 0 num: 2 value: array(2) { [0]=> string(1) "f" [1]=> @@ -189,7 +189,7 @@ start: 1 num: 1 value: array(1) { } =========================== bool(true) -start: 1 num: 2.5 value: array(2) { +start: 1 num: 2 value: array(2) { [1]=> bool(true) [2]=> @@ -197,7 +197,7 @@ start: 1 num: 2.5 value: array(2) { } =========================== bool(false) -start: 1 num: 2.5 value: array(2) { +start: 1 num: 2 value: array(2) { [1]=> bool(false) [2]=> @@ -205,7 +205,7 @@ start: 1 num: 2.5 value: array(2) { } =========================== NULL -start: 1 num: 2.5 value: array(2) { +start: 1 num: 2 value: array(2) { [1]=> NULL [2]=> @@ -213,7 +213,7 @@ start: 1 num: 2.5 value: array(2) { } =========================== string(1) "d" -start: 1 num: 2.5 value: array(2) { +start: 1 num: 2 value: array(2) { [1]=> string(1) "d" [2]=> @@ -221,7 +221,7 @@ start: 1 num: 2.5 value: array(2) { } =========================== string(1) "e" -start: 1 num: 2.5 value: array(2) { +start: 1 num: 2 value: array(2) { [1]=> string(1) "e" [2]=> @@ -229,7 +229,7 @@ start: 1 num: 2.5 value: array(2) { } =========================== string(1) "f" -start: 1 num: 2.5 value: array(2) { +start: 1 num: 2 value: array(2) { [1]=> string(1) "f" [2]=> @@ -237,67 +237,67 @@ start: 1 num: 2.5 value: array(2) { } =========================== bool(true) -start: 2.5 num: 0 value: array(0) { +start: 2 num: 0 value: array(0) { } =========================== bool(false) -start: 2.5 num: 0 value: array(0) { +start: 2 num: 0 value: array(0) { } =========================== NULL -start: 2.5 num: 0 value: array(0) { +start: 2 num: 0 value: array(0) { } =========================== string(1) "d" -start: 2.5 num: 0 value: array(0) { +start: 2 num: 0 value: array(0) { } =========================== string(1) "e" -start: 2.5 num: 0 value: array(0) { +start: 2 num: 0 value: array(0) { } =========================== string(1) "f" -start: 2.5 num: 0 value: array(0) { +start: 2 num: 0 value: array(0) { } =========================== bool(true) -start: 2.5 num: 1 value: array(1) { +start: 2 num: 1 value: array(1) { [2]=> bool(true) } =========================== bool(false) -start: 2.5 num: 1 value: array(1) { +start: 2 num: 1 value: array(1) { [2]=> bool(false) } =========================== NULL -start: 2.5 num: 1 value: array(1) { +start: 2 num: 1 value: array(1) { [2]=> NULL } =========================== string(1) "d" -start: 2.5 num: 1 value: array(1) { +start: 2 num: 1 value: array(1) { [2]=> string(1) "d" } =========================== string(1) "e" -start: 2.5 num: 1 value: array(1) { +start: 2 num: 1 value: array(1) { [2]=> string(1) "e" } =========================== string(1) "f" -start: 2.5 num: 1 value: array(1) { +start: 2 num: 1 value: array(1) { [2]=> string(1) "f" } =========================== bool(true) -start: 2.5 num: 2.5 value: array(2) { +start: 2 num: 2 value: array(2) { [2]=> bool(true) [3]=> @@ -305,7 +305,7 @@ start: 2.5 num: 2.5 value: array(2) { } =========================== bool(false) -start: 2.5 num: 2.5 value: array(2) { +start: 2 num: 2 value: array(2) { [2]=> bool(false) [3]=> @@ -313,7 +313,7 @@ start: 2.5 num: 2.5 value: array(2) { } =========================== NULL -start: 2.5 num: 2.5 value: array(2) { +start: 2 num: 2 value: array(2) { [2]=> NULL [3]=> @@ -321,7 +321,7 @@ start: 2.5 num: 2.5 value: array(2) { } =========================== string(1) "d" -start: 2.5 num: 2.5 value: array(2) { +start: 2 num: 2 value: array(2) { [2]=> string(1) "d" [3]=> @@ -329,7 +329,7 @@ start: 2.5 num: 2.5 value: array(2) { } =========================== string(1) "e" -start: 2.5 num: 2.5 value: array(2) { +start: 2 num: 2 value: array(2) { [2]=> string(1) "e" [3]=> @@ -337,7 +337,7 @@ start: 2.5 num: 2.5 value: array(2) { } =========================== string(1) "f" -start: 2.5 num: 2.5 value: array(2) { +start: 2 num: 2 value: array(2) { [2]=> string(1) "f" [3]=> 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/array_intersect_assoc_variation5.phpt b/ext/standard/tests/array/array_intersect_assoc_variation5.phpt index ad0c29b6b5dae..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"); diff --git a/ext/standard/tests/array/array_intersect_assoc_variation6.phpt b/ext/standard/tests/array/array_intersect_assoc_variation6.phpt index 57c3843d1fb18..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"); diff --git a/ext/standard/tests/array/array_intersect_variation5.phpt b/ext/standard/tests/array/array_intersect_variation5.phpt index 04eb9b43c37e4..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() @@ -144,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 b35a6ce0766df..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() @@ -144,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_key_exists_variation3.phpt b/ext/standard/tests/array/array_key_exists_variation3.phpt index aba298db47e95..ec39804f03939 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 from non-compatible float 1.23456789E-10 to int in %s on line %d bool(true) Cast float to int: bool(true) -- Iteration 1 -- Pass float as $key: + +Deprecated: Implicit conversion from non-compatible float 1.00000000000001 to int in %s on line %d bool(true) Cast float to int: bool(true) -- Iteration 1 -- Pass float as $key: + +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_keys_variation_002.phpt b/ext/standard/tests/array/array_keys_variation_002.phpt index 8378cfbf0d3b4..1765c2173a972 100644 --- a/ext/standard/tests/array/array_keys_variation_002.phpt +++ b/ext/standard/tests/array/array_keys_variation_002.phpt @@ -1,24 +1,8 @@ --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 @@ -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/array/array_map_variation4.phpt b/ext/standard/tests/array/array_map_variation4.phpt index ea495cbcd8758..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") ); @@ -135,7 +135,7 @@ array(2) { string(8) "resource" } -- Iteration 9 -- -array(7) { +array(6) { ["hello"]=> int(1) ["fruit"]=> @@ -144,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 9a4fcbffbb41e..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() @@ -273,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) @@ -290,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]=> @@ -307,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 4a5c53c472cb5..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") ); @@ -288,8 +288,8 @@ array(5) { string(8) "resource" } -- Iteration 9 -- -int(8) -array(8) { +int(7) +array(7) { [0]=> int(10) ["hello"]=> @@ -300,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]=> @@ -323,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/bug68553.phpt b/ext/standard/tests/array/bug68553.phpt index 1d8f7f1b0b4e5..a21e6b1d6894f 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 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/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/array/usort_variation3.phpt b/ext/standard/tests/array/usort_variation3.phpt index dc37ac21f2ce7..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, 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/file/ftruncate_variation3-win32.phpt b/ext/standard/tests/file/ftruncate_variation3-win32.phpt index 60e31fefe1332..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 = 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 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/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..6ab7c98c7ccc0 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 from non-compatible float 3950.5 to int in %s on line %d string(12) "111101101110" + +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" string(4) "1010" + +Deprecated: Implicit conversion from non-compatible float-string "3950.5" to int in %s on line %d string(12) "111101101110" + +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/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 15bb864398224..0d4e18307eab1 100644 --- a/ext/standard/tests/math/decbin_variation1_64bit.phpt +++ b/ext/standard/tests/math/decbin_variation1_64bit.phpt @@ -10,21 +10,7 @@ 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,7 +43,7 @@ foreach($inputs as $i => $input) { echo $exception->getMessage() . "\n"; } } -fclose($fp); + ?> --EXPECT-- *** Testing decbin() : usage variations *** @@ -97,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" +string(37) "1110010111110100110010001101000001000" -- Iteration 8 -- -string(64) "1111111111111111111111111111111111111111111111111111111111110110" +string(1) "1" -- Iteration 9 -- -string(37) "1110010111110100110010001101000001000" +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/dechex_basic.phpt b/ext/standard/tests/math/dechex_basic.phpt index 4fde95ebe7cdf..ce06b77a767d7 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 from non-compatible float 3950.5 to int in %s on line %d string(3) "f6e" + +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" string(1) "a" + +Deprecated: Implicit conversion from non-compatible float-string "3950.5" to int in %s on line %d string(3) "f6e" + +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/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 8435d2bc30bad..bd597b2f996a6 100644 --- a/ext/standard/tests/math/dechex_variation1_64bit.phpt +++ b/ext/standard/tests/math/dechex_variation1_64bit.phpt @@ -10,21 +10,7 @@ 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); ?> --EXPECT-- @@ -98,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" +string(10) "1cbe991a08" -- Iteration 8 -- -string(16) "fffffffffffffff6" +string(1) "1" -- Iteration 9 -- -string(10) "1cbe991a08" +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/decoct_basic.phpt b/ext/standard/tests/math/decoct_basic.phpt index 2bf63662f410b..f0fc2356a4786 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 from non-compatible float 3950.5 to int in %s on line %d string(4) "7556" + +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" string(2) "12" + +Deprecated: Implicit conversion from non-compatible float-string "3950.5" to int in %s on line %d string(4) "7556" + +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/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 73650f5983557..cc4b69f07560f 100644 --- a/ext/standard/tests/math/decoct_variation1_64bit.phpt +++ b/ext/standard/tests/math/decoct_variation1_64bit.phpt @@ -10,21 +10,7 @@ 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,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" +string(13) "1627646215010" -- Iteration 8 -- -string(22) "1777777777777777777766" +string(1) "1" -- Iteration 9 -- -string(13) "1627646215010" +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/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/mt_srand_basic.phpt b/ext/standard/tests/math/mt_srand_basic.phpt index 71abbcb0aae0a..bba17124c61e2 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 from non-compatible float 500.1 to int in %s on line %d NULL NULL NULL 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/standard/tests/math/round_basic.phpt b/ext/standard/tests/math/round_basic.phpt index 44aacf2eecdc7..a1e531b736349 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 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) + +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) @@ -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 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) + +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) @@ -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 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) + +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) @@ -80,9 +92,13 @@ round: 12300 ...with precision 8-> float(12300) ...with precision 3-> float(12300) ...with precision 4-> float(12300) + +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) + +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) @@ -92,9 +108,13 @@ round: -4567 ...with precision 8-> float(-4567) ...with precision 3-> float(-4567) ...with precision 4-> float(-4567) + +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) + +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) @@ -104,9 +124,13 @@ round: 2311527 ...with precision 8-> float(2311527) ...with precision 3-> float(2311527) ...with precision 4-> float(2311527) + +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) + +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) @@ -116,9 +140,13 @@ round: 14680063 ...with precision 8-> float(14680063) ...with precision 3-> float(14680063) ...with precision 4-> float(14680063) + +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) + +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) @@ -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 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) + +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) @@ -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 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) + +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) diff --git a/ext/standard/tests/math/srand_basic.phpt b/ext/standard/tests/math/srand_basic.phpt index ce9a4e3f97ad9..2594305c7531d 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 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 f0d68cca90432..d1eee05cb0fa9 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 from non-compatible float 0.5 to int in %s on line %d 0 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..d2d33f8e67933 --- /dev/null +++ b/ext/standard/tests/strings/bug23894_32bit.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #23894 (sprintf() decimal specifiers problem) 32bit version +--SKIPIF-- + +--FILE-- + +--EXPECT-- +string(4) "-012" +string(8) "2d303132" +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..3ae5ea663271b --- /dev/null +++ b/ext/standard/tests/strings/bug23894_64bit.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #23894 (sprintf() decimal specifiers problem) 64bit version +--SKIPIF-- + +--FILE-- + +--EXPECT-- +string(4) "-012" +string(8) "2d303132" +string(20) "18446744073709551604" +string(40) "3138343436373434303733373039353531363034" diff --git a/ext/standard/tests/strings/bug47842.phpt b/ext/standard/tests/strings/bug47842.phpt index 4ac9da6d830cd..fe97308ea53a7 100644 --- a/ext/standard/tests/strings/bug47842.phpt +++ b/ext/standard/tests/strings/bug47842.phpt @@ -23,8 +23,8 @@ printf("printf 64-bit signed int '18446744073709551615' (2^64)-1 = %u\n", 184467 echo "Done\n"; ?> ---EXPECTF-- -%aTest +--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 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-- ---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 from non-compatible float 10.5 to int in %s on line %d string(2) "0a" -- Iteration 6 -- + +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 deleted file mode 100644 index d40d713f1d5ed..0000000000000 --- a/ext/standard/tests/strings/chunk_split_variation10.phpt +++ /dev/null @@ -1,80 +0,0 @@ ---TEST-- -Test chunk_split() function : usage variations - different single quoted strings for 'ending' argument ---FILE-- - ---EXPECT-- -*** Testing chunk_split() : different single quoted strings as 'ending' *** --- Iteration 0 -- -string(73) "This is to test chunk_split() with various 'single quoted' ending string." --- Iteration 1 -- -string(82) "This is t o test ch unk_split () with v arious 's ingle quo ted' endi ng string . " --- Iteration 2 -- -string(82) "This is tao test chaunk_splita() with vaarious 'saingle quoated' endiang stringa.a" --- Iteration 3 -- -string(127) "This is tENDINGo test chENDINGunk_splitENDING() with vENDINGarious 'sENDINGingle quoENDINGted' endiENDINGng stringENDING.ENDING" --- Iteration 4 -- -string(118) "This is t@#$%^o test ch@#$%^unk_split@#$%^() with v@#$%^arious 's@#$%^ingle quo@#$%^ted' endi@#$%^ng string@#$%^.@#$%^" --- Iteration 5 -- -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 -- -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 -- -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 -- -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 -- -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 -- -string(100) "This is t123o test ch123unk_split123() with v123arious 's123ingle quo123ted' endi123ng string123.123" --- Iteration 11 -- -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 -- -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 -- -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 -- -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/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/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'" 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) diff --git a/tests/lang/bug27354.phpt b/tests/lang/bug27354.phpt index c6ce9804fd240..092bf831f578e 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.223372036860776E+18 to int in %s on line %d +int(0) +int(0) +int(0) diff --git a/tests/lang/operators/bitwiseNot_basiclong_64bit.phpt b/tests/lang/operators/bitwiseNot_basiclong_64bit.phpt index 72db6d5728862..45faf43b93f06 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 from non-compatible float 9.223372036854776E+18 to int in %s on line %d int(9223372036854775807) --- testing: -9223372036854775807 --- int(9223372036854775806)