From dc3962a42965b63bd58c1fca57f37aef3d67beae Mon Sep 17 00:00:00 2001 From: Andrea Faulds Date: Wed, 24 Jun 2020 15:05:58 +0200 Subject: [PATCH 01/14] Permit trailing whitespace in numeric strings --- .../trailling_whitespaces.phpt | 59 +++++++++++++++++++ Zend/tests/string_to_number_comparison.phpt | 6 +- Zend/zend_operators.c | 15 +++-- .../tests/general_functions/is_numeric.phpt | 9 ++- .../lang/operators/operator_equals_basic.phpt | 8 +-- tests/lang/operators/operator_gt_basic.phpt | 4 +- tests/lang/operators/operator_lt_basic.phpt | 4 +- .../operators/operator_notequals_basic.phpt | 8 +-- .../operators/operator_spaceship_basic.phpt | 4 +- 9 files changed, 93 insertions(+), 24 deletions(-) create mode 100644 Zend/tests/numeric_strings/trailling_whitespaces.phpt diff --git a/Zend/tests/numeric_strings/trailling_whitespaces.phpt b/Zend/tests/numeric_strings/trailling_whitespaces.phpt new file mode 100644 index 0000000000000..431a3f669112d --- /dev/null +++ b/Zend/tests/numeric_strings/trailling_whitespaces.phpt @@ -0,0 +1,59 @@ +--TEST-- +Acceptance of whitespace in numeric strings +--FILE-- + +--EXPECT-- +OK! diff --git a/Zend/tests/string_to_number_comparison.phpt b/Zend/tests/string_to_number_comparison.phpt index a64b1c4ff2cba..86ba8a7a8b765 100644 --- a/Zend/tests/string_to_number_comparison.phpt +++ b/Zend/tests/string_to_number_comparison.phpt @@ -49,12 +49,12 @@ compare_eq(-INF, "-1e1000"); echo "\n"; $float = 1.75; - + echo "precision=14:\n"; ini_set('precision', 14); compare_3way($float, "1.75abc"); compare_3way((string) $float, "1.75abc"); - + echo "precision=0:\n"; ini_set('precision', 0); compare_3way($float, "1.75abc"); @@ -73,7 +73,7 @@ compare_3way((string) $float, "1.75abc"); "0" == "0e214987142012": true 42 == " 42": true -42 == "42 ": false +42 == "42 ": true 42 == "42abc": false 42 == "abc42": false 0 == "abc42": false diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index a468962491568..f0c17ea0d3d08 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -3052,11 +3052,18 @@ ZEND_API zend_uchar ZEND_FASTCALL _is_numeric_string_ex(const char *str, size_t } if (ptr != str + length) { - if (!allow_errors) { - return 0; + const char *endptr = ptr; + while (*endptr == ' ' || *endptr == '\t' || *endptr == '\n' || *endptr == '\r' || *endptr == '\v' || *endptr == '\f') { + endptr++; + length--; } - if (allow_errors == -1) { - zend_error(E_NOTICE, "A non well formed numeric value encountered"); + if (ptr != str + length) { + if (!allow_errors) { + return 0; + } + if (allow_errors == -1) { + zend_error(E_NOTICE, "A non well formed numeric value encountered"); + } if (EG(exception)) { return 0; } diff --git a/ext/standard/tests/general_functions/is_numeric.phpt b/ext/standard/tests/general_functions/is_numeric.phpt index bf09a8134830a..a4f7b79f79b9f 100644 --- a/ext/standard/tests/general_functions/is_numeric.phpt +++ b/ext/standard/tests/general_functions/is_numeric.phpt @@ -68,12 +68,14 @@ $numerics = array( "-1", "1e2", " 1", + "1 ", "2974394749328742328432", "-1e-2", '1', '-1', '1e2', ' 1', + '1 ', '2974394749328742328432', '-1e-2', "0123", @@ -114,7 +116,6 @@ $not_numerics = array( array(), array("string"), "", - "1 ", "- 1", "1.2.4", "1e7.6", @@ -302,6 +303,10 @@ bool(true) bool(true) -- Iteration 76 -- bool(true) +-- Iteration 77 -- +bool(true) +-- Iteration 78 -- +bool(true) *** Testing is_numeric() on non numeric types *** -- Iteration 1 -- @@ -360,6 +365,4 @@ bool(false) bool(false) -- Iteration 28 -- bool(false) --- Iteration 29 -- -bool(false) Done diff --git a/tests/lang/operators/operator_equals_basic.phpt b/tests/lang/operators/operator_equals_basic.phpt index 3f179a0a4c284..63ab1ac68d626 100644 --- a/tests/lang/operators/operator_equals_basic.phpt +++ b/tests/lang/operators/operator_equals_basic.phpt @@ -8,10 +8,10 @@ $valid_false = array(0, "", 0.0, array(), NULL); $int1 = 679; $int2 = -67835; -$valid_int1 = array("679", " 679", 679.0, 6.79E2, "+679", +679); -$valid_int2 = array("-67835", " -67835", -67835.000, -6.7835E4); -$invalid_int1 = array("679abc", "679 ", "6 7 9", "6y79", 678); -$invalid_int2 = array("-67835abc", "-67835 ", "- 67835", "-67,835", "-67 835", "-678y35", -76834); +$valid_int1 = array("679", " 679", "679 ", 679.0, 6.79E2, "+679", +679); +$valid_int2 = array("-67835", " -67835", "-67835 ", -67835.000, -6.7835E4); +$invalid_int1 = array("679abc", "6 7 9", "6y79", 678); +$invalid_int2 = array("-67835abc", "- 67835", "-67,835", "-67 835", "-678y35", -76834); $float1 = 57385.45835; $float2 = -67345.76567; diff --git a/tests/lang/operators/operator_gt_basic.phpt b/tests/lang/operators/operator_gt_basic.phpt index 70b8fbcdd987c..bb13bd959948a 100644 --- a/tests/lang/operators/operator_gt_basic.phpt +++ b/tests/lang/operators/operator_gt_basic.phpt @@ -8,9 +8,9 @@ $valid_false = array(0, "", 0.0, array(), NULL); $int1 = 679; $int2 = -67835; $valid_int1 = array("678", "678abc", " 678", "678 ", 678.0, 6.789E2, "+678", +678); -$valid_int2 = array("-67836", " -67836", -67835.0001, -6.78351E4); +$valid_int2 = array("-67836", " -67836", -67835.0001, -6.78351E4, "-67836 "); $invalid_int1 = array(679, "679"); -$invalid_int2 = array(-67835, "-67835", "-67836abc", "-67836 "); +$invalid_int2 = array(-67835, "-67835", "-67836abc"); $float1 = 57385.45835; $float2 = -67345.76567; diff --git a/tests/lang/operators/operator_lt_basic.phpt b/tests/lang/operators/operator_lt_basic.phpt index 98685506c7ebe..e3fedddf831cc 100644 --- a/tests/lang/operators/operator_lt_basic.phpt +++ b/tests/lang/operators/operator_lt_basic.phpt @@ -8,9 +8,9 @@ $valid_false = array(0, "", 0.0, array(), NULL); $int1 = 677; $int2 = -67837; $valid_int1 = array("678", "678abc", " 678", "678 ", 678.0, 6.789E2, "+678", +678); -$valid_int2 = array("-67836", " -67836", -67835.0001, -6.78351E4); +$valid_int2 = array("-67836", " -67836", -67835.0001, -6.78351E4, "-67836 "); $invalid_int1 = array(676, "676"); -$invalid_int2 = array(-67837, "-67837", "-67836abc", "-67836 "); +$invalid_int2 = array(-67837, "-67837", "-67836abc"); $float1 = 57385.45835; $float2 = -67345.76567; diff --git a/tests/lang/operators/operator_notequals_basic.phpt b/tests/lang/operators/operator_notequals_basic.phpt index b254e6e90ce5f..156c60d6da8b0 100644 --- a/tests/lang/operators/operator_notequals_basic.phpt +++ b/tests/lang/operators/operator_notequals_basic.phpt @@ -8,10 +8,10 @@ $valid_false = array(0, "", 0.0, array(), NULL); $int1 = 679; $int2 = -67835; -$valid_int1 = array("679abc", "679 ", "6 7 9", "6y79", 678); -$valid_int2 = array("-67835abc", "-67835 ", "- 67835", "-67,835", "-67 835", "-678y35", -76834); -$invalid_int1 = array("679", " 679", 679.0, 6.79E2, "+679", +679); -$invalid_int2 = array("-67835", " -67835", -67835.000, -6.7835E4); +$valid_int1 = array("679abc", "6 7 9", "6y79", 678); +$valid_int2 = array("-67835abc", "- 67835", "-67,835", "-67 835", "-678y35", -76834); +$invalid_int1 = array("679", " 679", "679 ", 679.0, 6.79E2, "+679", +679); +$invalid_int2 = array("-67835", " -67835", "-67835 ", -67835.000, -6.7835E4); $float1 = 57385.45835; $float2 = -67345.76567; diff --git a/tests/lang/operators/operator_spaceship_basic.phpt b/tests/lang/operators/operator_spaceship_basic.phpt index 1014c46191f12..f74201bc5f8e3 100644 --- a/tests/lang/operators/operator_spaceship_basic.phpt +++ b/tests/lang/operators/operator_spaceship_basic.phpt @@ -8,9 +8,9 @@ $valid_false = array(0, "", 0.0, array(), NULL); $int1 = 679; $int2 = -67835; $valid_int1 = array("678", "678abc", " 678", "678 ", 678.0, 6.789E2, "+678", +678); -$valid_int2 = array("-67836", " -67836", -67835.0001, -6.78351E4); +$valid_int2 = array("-67836", " -67836", "-67836 ", -67835.0001, -6.78351E4); $invalid_int1 = array(679, "679"); -$invalid_int2 = array(-67835, "-67835", "-67836abc", "-67836 "); +$invalid_int2 = array(-67835, "-67835", "-67836abc"); $float1 = 57385.45835; $float2 = -67345.76567; From a1f8b2e99bc5f7781fd753ed0d4598a7fb6a8f35 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Wed, 1 Jul 2020 14:39:41 +0200 Subject: [PATCH 02/14] Remove -1 allow_error mode All "numeric" strings which emitted a notice now emit the usual warning. --- Zend/tests/add_006.phpt | 8 +- Zend/tests/bug72057.phpt | 19 -- Zend/tests/int_conversion_exponents.phpt | 16 +- .../non_well_formed_param_exception.phpt | 22 -- Zend/tests/numeric_strings/array_offset.phpt | 86 ++++++ ...plicit_cast_leading_numeric_must_work.phpt | 16 ++ ..._string_must_generate_warning_assign.phpt} | 86 +++--- ...umeric_strings_must_generate_warning.phpt} | 86 +++--- .../{ => numeric_strings}/neg_num_string.phpt | 0 Zend/tests/numeric_strings/string_offset.phpt | 78 ++++++ Zend/tests/offset_string.phpt | 2 +- Zend/tests/self_and.phpt | 4 +- Zend/tests/self_mod.phpt | 4 +- Zend/tests/self_or.phpt | 4 +- Zend/tests/self_xor.phpt | 4 +- Zend/tests/shift_001.phpt | 4 +- Zend/tests/shift_002.phpt | 4 +- .../tests/type_declarations/scalar_basic.phpt | 6 +- .../scalar_return_basic.phpt | 6 +- .../scalar_return_basic_64bit.phpt | 6 +- .../union_types/type_checking_weak.phpt | 10 +- Zend/zend_API.c | 6 +- Zend/zend_execute.c | 38 +-- Zend/zend_operators.c | 45 ++- Zend/zend_operators.h | 8 +- ext/opcache/jit/zend_jit_helpers.c | 8 +- ext/opcache/tests/jit/fetch_dim_r_003.phpt | 4 +- ext/opcache/tests/jit/fetch_dim_r_004.phpt | 4 +- .../tests/general_functions/floatval.phpt | 20 +- .../floatval_variation1.phpt | 20 +- tests/lang/operators/add_variationStr.phpt | 264 +++++++++--------- .../bitwiseShiftLeft_variationStr.phpt | 120 ++++---- .../bitwiseShiftLeft_variationStr_64bit.phpt | 120 ++++---- .../bitwiseShiftRight_variationStr.phpt | 118 ++++---- tests/lang/operators/divide_variationStr.phpt | 264 +++++++++--------- .../lang/operators/modulus_variationStr.phpt | 214 +++++++------- .../lang/operators/multiply_variationStr.phpt | 216 +++++++------- tests/lang/operators/negate_variationStr.phpt | 24 +- .../lang/operators/subtract_variationStr.phpt | 232 +++++++-------- 39 files changed, 1153 insertions(+), 1043 deletions(-) delete mode 100644 Zend/tests/bug72057.phpt delete mode 100644 Zend/tests/non_well_formed_param_exception.phpt create mode 100644 Zend/tests/numeric_strings/array_offset.phpt create mode 100644 Zend/tests/numeric_strings/explicit_cast_leading_numeric_must_work.phpt rename Zend/tests/{numeric_string_errors_assign.phpt => numeric_strings/invalid_numeric_string_must_generate_warning_assign.phpt} (65%) rename Zend/tests/{numeric_string_errors.phpt => numeric_strings/invalid_numeric_strings_must_generate_warning.phpt} (60%) rename Zend/tests/{ => numeric_strings}/neg_num_string.phpt (100%) create mode 100644 Zend/tests/numeric_strings/string_offset.phpt diff --git a/Zend/tests/add_006.phpt b/Zend/tests/add_006.phpt index 2e7f76b4eef06..dac971093e028 100644 --- a/Zend/tests/add_006.phpt +++ b/Zend/tests/add_006.phpt @@ -41,16 +41,16 @@ echo "Done\n"; Warning: A non-numeric value encountered in %s on line %d int(75636) -Notice: A non well formed numeric value encountered in %s on line %d -int(951858) +Warning: A non-numeric value encountered in %s on line %d +int(75636) int(48550510) float(75661.68) Warning: A non-numeric value encountered in %s on line %d int(75636) -Notice: A non well formed numeric value encountered in %s on line %d -int(951858) +Warning: A non-numeric value encountered in %s on line %d +int(75636) int(48550510) float(75661.68) Done diff --git a/Zend/tests/bug72057.phpt b/Zend/tests/bug72057.phpt deleted file mode 100644 index a518d829480bd..0000000000000 --- a/Zend/tests/bug72057.phpt +++ /dev/null @@ -1,19 +0,0 @@ ---TEST-- -Bug #72057 (PHP hangs when user error handler throws exception after Notice from type coercion) ---FILE-- - ---EXPECTF-- -Exception: A non well formed numeric value encountered in %s:%d -Stack trace: -#0 [internal function]: {closure}(%s) -#1 %s(%d): wordwrap('foo', '123foo', '') -#2 {main} diff --git a/Zend/tests/numeric_strings/array_offset.phpt b/Zend/tests/numeric_strings/array_offset.phpt new file mode 100644 index 0000000000000..6522faea244cd --- /dev/null +++ b/Zend/tests/numeric_strings/array_offset.phpt @@ -0,0 +1,86 @@ +--TEST-- +Using different sorts of numerical strings as an array offset +--FILE-- + +--EXPECTF-- +int(7) + +Notice: Undefined array key "7.5" in %s on line 6 +NULL + +Notice: Undefined array key " 7" in %s on line 7 +NULL + +Notice: Undefined array key " 7.5" in %s on line 8 +NULL + +Notice: Undefined array key " 7 " in %s on line 9 +NULL + +Notice: Undefined array key " 7.5 " in %s on line 10 +NULL + +Notice: Undefined array key "7 " in %s on line 11 +NULL + +Notice: Undefined array key "7.5 " in %s on line 12 +NULL + +Notice: Undefined array key "7str" in %s on line 13 +NULL + +Notice: Undefined array key "7.5str" in %s on line 14 +NULL + +Notice: Undefined array key " 7str" in %s on line 15 +NULL + +Notice: Undefined array key " 7.5str" in %s on line 16 +NULL + +Notice: Undefined array key " 7 str" in %s on line 17 +NULL + +Notice: Undefined array key " 7.5 str" in %s on line 18 +NULL + +Notice: Undefined array key "7 str" in %s on line 19 +NULL + +Notice: Undefined array key "7.5 str" in %s on line 20 +NULL + +Notice: Undefined array key "0xA" in %s on line 21 +NULL + +Notice: Undefined array key "0b10" in %s on line 22 +NULL + +Notice: Undefined array key "07" in %s on line 23 +NULL +Done diff --git a/Zend/tests/numeric_strings/explicit_cast_leading_numeric_must_work.phpt b/Zend/tests/numeric_strings/explicit_cast_leading_numeric_must_work.phpt new file mode 100644 index 0000000000000..8c906e8f817b3 --- /dev/null +++ b/Zend/tests/numeric_strings/explicit_cast_leading_numeric_must_work.phpt @@ -0,0 +1,16 @@ +--TEST-- +Explicit cast of leading numeric strings should still work without warning +--FILE-- + +--EXPECT-- +int(2) +float(2) +int(2) +float(2.5) diff --git a/Zend/tests/numeric_string_errors_assign.phpt b/Zend/tests/numeric_strings/invalid_numeric_string_must_generate_warning_assign.phpt similarity index 65% rename from Zend/tests/numeric_string_errors_assign.phpt rename to Zend/tests/numeric_strings/invalid_numeric_string_must_generate_warning_assign.phpt index 69be0c114dd84..b2c92cea3dcaf 100644 --- a/Zend/tests/numeric_string_errors_assign.phpt +++ b/Zend/tests/numeric_strings/invalid_numeric_string_must_generate_warning_assign.phpt @@ -1,5 +1,5 @@ --TEST-- -Invalid numeric string E_WARNINGs and E_NOTICEs, combined assignment operations +Invalid numeric string E_WARNINGs, combined assignment operations --FILE-- getMessage() . \PHP_EOL; +} try { $a = foxcache("minim"); $a %= "veniam,"; var_dump($a); } catch (DivisionByZeroError $e) { + echo $e->getMessage() . \PHP_EOL; } echo "---", PHP_EOL; $a = foxcache("41 minim"); @@ -107,10 +112,10 @@ $a ^= "reprehenderit"; var_dump($a); ?> --EXPECTF-- -Notice: A non well formed numeric value encountered in %s on line %d +Warning: A non-numeric value encountered in %s on line %d -Notice: A non well formed numeric value encountered in %s on line %d -int(5) +Warning: A non-numeric value encountered in %s on line %d +int(0) Warning: A non-numeric value encountered in %s on line %d @@ -118,10 +123,10 @@ Warning: A non-numeric value encountered in %s on line %d int(0) --- -Notice: A non well formed numeric value encountered in %s on line %d +Warning: A non-numeric value encountered in %s on line %d -Notice: A non well formed numeric value encountered in %s on line %d -int(-2) +Warning: A non-numeric value encountered in %s on line %d +int(0) Warning: A non-numeric value encountered in %s on line %d @@ -129,10 +134,10 @@ Warning: A non-numeric value encountered in %s on line %d int(0) --- -Notice: A non well formed numeric value encountered in %s on line %d +Warning: A non-numeric value encountered in %s on line %d -Notice: A non well formed numeric value encountered in %s on line %d -int(143) +Warning: A non-numeric value encountered in %s on line %d +int(0) Warning: A non-numeric value encountered in %s on line %d @@ -140,10 +145,12 @@ Warning: A non-numeric value encountered in %s on line %d int(0) --- -Notice: A non well formed numeric value encountered in %s on line %d +Warning: A non-numeric value encountered in %s on line %d -Notice: A non well formed numeric value encountered in %s on line %d -float(0.8947368421052632) +Warning: A non-numeric value encountered in %s on line %d + +Warning: Division by zero in %s on line %d +float(NAN) Warning: A non-numeric value encountered in %s on line %d @@ -153,10 +160,10 @@ Warning: Division by zero in %s on line %d float(NAN) --- -Notice: A non well formed numeric value encountered in %s on line %d +Warning: A non-numeric value encountered in %s on line %d -Notice: A non well formed numeric value encountered in %s on line %d -float(3.0910586430935376E+39) +Warning: A non-numeric value encountered in %s on line %d +int(1) Warning: A non-numeric value encountered in %s on line %d @@ -164,20 +171,21 @@ Warning: A non-numeric value encountered in %s on line %d int(1) --- -Notice: A non well formed numeric value encountered in %s on line %d +Warning: A non-numeric value encountered in %s on line %d -Notice: A non well formed numeric value encountered in %s on line %d -int(31) +Warning: A non-numeric value encountered in %s on line %d +Modulo by zero Warning: A non-numeric value encountered in %s on line %d Warning: A non-numeric value encountered in %s on line %d +Modulo by zero --- -Notice: A non well formed numeric value encountered in %s on line %d +Warning: A non-numeric value encountered in %s on line %d -Notice: A non well formed numeric value encountered in %s on line %d -int(%d) +Warning: A non-numeric value encountered in %s on line %d +int(0) Warning: A non-numeric value encountered in %s on line %d @@ -185,9 +193,9 @@ Warning: A non-numeric value encountered in %s on line %d int(0) --- -Notice: A non well formed numeric value encountered in %s on line %d +Warning: A non-numeric value encountered in %s on line %d -Notice: A non well formed numeric value encountered in %s on line %d +Warning: A non-numeric value encountered in %s on line %d int(0) Warning: A non-numeric value encountered in %s on line %d @@ -196,11 +204,11 @@ Warning: A non-numeric value encountered in %s on line %d int(0) --- -Notice: A non well formed numeric value encountered in %s on line %d -int(63) +Warning: A non-numeric value encountered in %s on line %d +int(61) -Notice: A non well formed numeric value encountered in %s on line %d -int(71) +Warning: A non-numeric value encountered in %s on line %d +int(67) Warning: A non-numeric value encountered in %s on line %d int(73) @@ -209,11 +217,11 @@ Warning: A non-numeric value encountered in %s on line %d int(79) --- -Notice: A non well formed numeric value encountered in %s on line %d -int(81) +Warning: A non-numeric value encountered in %s on line %d +int(0) -Notice: A non well formed numeric value encountered in %s on line %d -int(97) +Warning: A non-numeric value encountered in %s on line %d +int(0) Warning: A non-numeric value encountered in %s on line %d int(0) @@ -222,11 +230,11 @@ Warning: A non-numeric value encountered in %s on line %d int(0) --- -Notice: A non well formed numeric value encountered in %s on line %d -int(28) +Warning: A non-numeric value encountered in %s on line %d +int(113) -Notice: A non well formed numeric value encountered in %s on line %d -int(252) +Warning: A non-numeric value encountered in %s on line %d +int(127) Warning: A non-numeric value encountered in %s on line %d int(137) diff --git a/Zend/tests/numeric_string_errors.phpt b/Zend/tests/numeric_strings/invalid_numeric_strings_must_generate_warning.phpt similarity index 60% rename from Zend/tests/numeric_string_errors.phpt rename to Zend/tests/numeric_strings/invalid_numeric_strings_must_generate_warning.phpt index 83c948981b8bd..c6a5364e59f52 100644 --- a/Zend/tests/numeric_string_errors.phpt +++ b/Zend/tests/numeric_strings/invalid_numeric_strings_must_generate_warning.phpt @@ -1,5 +1,5 @@ --TEST-- -Invalid numeric string E_WARNINGs and E_NOTICEs +Invalid numeric string E_WARNINGs --FILE-- --EXPECTF-- -Notice: A non well formed numeric value encountered in %s on line %d +Warning: A non-numeric value encountered in %s on line %d -Notice: A non well formed numeric value encountered in %s on line %d -int(5) +Warning: A non-numeric value encountered in %s on line %d +int(0) Warning: A non-numeric value encountered in %s on line %d @@ -63,10 +66,10 @@ Warning: A non-numeric value encountered in %s on line %d int(0) --- -Notice: A non well formed numeric value encountered in %s on line %d +Warning: A non-numeric value encountered in %s on line %d -Notice: A non well formed numeric value encountered in %s on line %d -int(-2) +Warning: A non-numeric value encountered in %s on line %d +int(0) Warning: A non-numeric value encountered in %s on line %d @@ -74,10 +77,10 @@ Warning: A non-numeric value encountered in %s on line %d int(0) --- -Notice: A non well formed numeric value encountered in %s on line %d +Warning: A non-numeric value encountered in %s on line %d -Notice: A non well formed numeric value encountered in %s on line %d -int(143) +Warning: A non-numeric value encountered in %s on line %d +int(0) Warning: A non-numeric value encountered in %s on line %d @@ -85,10 +88,12 @@ Warning: A non-numeric value encountered in %s on line %d int(0) --- -Notice: A non well formed numeric value encountered in %s on line %d +Warning: A non-numeric value encountered in %s on line %d + +Warning: A non-numeric value encountered in %s on line %d -Notice: A non well formed numeric value encountered in %s on line %d -float(0.8947368421052632) +Warning: Division by zero in %s on line %d +float(NAN) Warning: A non-numeric value encountered in %s on line %d @@ -98,10 +103,10 @@ Warning: Division by zero in %s on line %d float(NAN) --- -Notice: A non well formed numeric value encountered in %s on line %d +Warning: A non-numeric value encountered in %s on line %d -Notice: A non well formed numeric value encountered in %s on line %d -float(3.0910586430935376E+39) +Warning: A non-numeric value encountered in %s on line %d +int(1) Warning: A non-numeric value encountered in %s on line %d @@ -109,20 +114,19 @@ Warning: A non-numeric value encountered in %s on line %d int(1) --- -Notice: A non well formed numeric value encountered in %s on line %d +Warning: A non-numeric value encountered in %s on line %d -Notice: A non well formed numeric value encountered in %s on line %d -int(31) +Warning: A non-numeric value encountered in %s on line %d Warning: A non-numeric value encountered in %s on line %d Warning: A non-numeric value encountered in %s on line %d --- -Notice: A non well formed numeric value encountered in %s on line %d +Warning: A non-numeric value encountered in %s on line %d -Notice: A non well formed numeric value encountered in %s on line %d -int(%d) +Warning: A non-numeric value encountered in %s on line %d +int(0) Warning: A non-numeric value encountered in %s on line %d @@ -130,9 +134,9 @@ Warning: A non-numeric value encountered in %s on line %d int(0) --- -Notice: A non well formed numeric value encountered in %s on line %d +Warning: A non-numeric value encountered in %s on line %d -Notice: A non well formed numeric value encountered in %s on line %d +Warning: A non-numeric value encountered in %s on line %d int(0) Warning: A non-numeric value encountered in %s on line %d @@ -141,11 +145,11 @@ Warning: A non-numeric value encountered in %s on line %d int(0) --- -Notice: A non well formed numeric value encountered in %s on line %d -int(63) +Warning: A non-numeric value encountered in %s on line %d +int(61) -Notice: A non well formed numeric value encountered in %s on line %d -int(71) +Warning: A non-numeric value encountered in %s on line %d +int(67) Warning: A non-numeric value encountered in %s on line %d int(73) @@ -154,11 +158,11 @@ Warning: A non-numeric value encountered in %s on line %d int(79) --- -Notice: A non well formed numeric value encountered in %s on line %d -int(81) +Warning: A non-numeric value encountered in %s on line %d +int(0) -Notice: A non well formed numeric value encountered in %s on line %d -int(97) +Warning: A non-numeric value encountered in %s on line %d +int(0) Warning: A non-numeric value encountered in %s on line %d int(0) @@ -167,11 +171,11 @@ Warning: A non-numeric value encountered in %s on line %d int(0) --- -Notice: A non well formed numeric value encountered in %s on line %d -int(28) +Warning: A non-numeric value encountered in %s on line %d +int(113) -Notice: A non well formed numeric value encountered in %s on line %d -int(252) +Warning: A non-numeric value encountered in %s on line %d +int(127) Warning: A non-numeric value encountered in %s on line %d int(137) @@ -180,15 +184,15 @@ Warning: A non-numeric value encountered in %s on line %d int(139) --- -Notice: A non well formed numeric value encountered in %s on line %d -int(149) +Warning: A non-numeric value encountered in %s on line %d +int(0) Warning: A non-numeric value encountered in %s on line %d int(0) --- -Notice: A non well formed numeric value encountered in %s on line %d -int(-151) +Warning: A non-numeric value encountered in %s on line %d +int(0) Warning: A non-numeric value encountered in %s on line %d int(0) diff --git a/Zend/tests/neg_num_string.phpt b/Zend/tests/numeric_strings/neg_num_string.phpt similarity index 100% rename from Zend/tests/neg_num_string.phpt rename to Zend/tests/numeric_strings/neg_num_string.phpt diff --git a/Zend/tests/numeric_strings/string_offset.phpt b/Zend/tests/numeric_strings/string_offset.phpt new file mode 100644 index 0000000000000..f53766f56e385 --- /dev/null +++ b/Zend/tests/numeric_strings/string_offset.phpt @@ -0,0 +1,78 @@ +--TEST-- +Using different sorts of numerical strings as a string offset +--FILE-- + +--EXPECTF-- +string(1) "l" + +Warning: Illegal string offset "7.5" in %s on line 6 +string(1) "l" +string(1) "l" + +Warning: Illegal string offset " 7.5" in %s on line 8 +string(1) "l" +string(1) "l" + +Warning: Illegal string offset " 7.5 " in %s on line 10 +string(1) "l" +string(1) "l" + +Warning: Illegal string offset "7.5 " in %s on line 12 +string(1) "l" + +Warning: Illegal string offset "7str" in %s on line 13 +string(1) "l" + +Warning: Illegal string offset "7.5str" in %s on line 14 +string(1) "l" + +Warning: Illegal string offset " 7str" in %s on line 15 +string(1) "l" + +Warning: Illegal string offset " 7.5str" in %s on line 16 +string(1) "l" + +Warning: Illegal string offset " 7 str" in %s on line 17 +string(1) "l" + +Warning: Illegal string offset " 7.5 str" in %s on line 18 +string(1) "l" + +Warning: Illegal string offset "7 str" in %s on line 19 +string(1) "l" + +Warning: Illegal string offset "7.5 str" in %s on line 20 +string(1) "l" + +Warning: Illegal string offset "0xC" in %s on line 21 +string(1) "T" + +Warning: Illegal string offset "0b10" in %s on line 22 +string(1) "T" +string(1) "l" +Done diff --git a/Zend/tests/offset_string.phpt b/Zend/tests/offset_string.phpt index 4c7debcaa9bb5..e21d3d0453d06 100644 --- a/Zend/tests/offset_string.phpt +++ b/Zend/tests/offset_string.phpt @@ -55,7 +55,7 @@ string(1) "c" Warning: Illegal string offset "14.5" in %s on line %d string(1) "o" -Notice: A non well formed numeric value encountered in %s on line %d +Warning: Illegal string offset "15 and then some" in %s on line %d string(1) "r" Warning: String offset cast occurred in %s on line %d diff --git a/Zend/tests/self_and.phpt b/Zend/tests/self_and.phpt index 26b86e512586e..ffb5aff82f9c0 100644 --- a/Zend/tests/self_and.phpt +++ b/Zend/tests/self_and.phpt @@ -32,8 +32,8 @@ int(18) Warning: A non-numeric value encountered in %s on line %d int(0) -Notice: A non well formed numeric value encountered in %s on line %d -int(33) +Warning: A non-numeric value encountered in %s on line %d +int(0) string(1) " " string(2) " " Done diff --git a/Zend/tests/self_mod.phpt b/Zend/tests/self_mod.phpt index 0b10987aeb86c..edb2d6f873902 100644 --- a/Zend/tests/self_mod.phpt +++ b/Zend/tests/self_mod.phpt @@ -24,6 +24,6 @@ int(13) Warning: A non-numeric value encountered in %s on line %d int(0) -Notice: A non well formed numeric value encountered in %s on line %d -int(3) +Warning: A non-numeric value encountered in %s on line %d +int(0) Done diff --git a/Zend/tests/self_or.phpt b/Zend/tests/self_or.phpt index cecf70d795db9..c67feac351a2e 100644 --- a/Zend/tests/self_or.phpt +++ b/Zend/tests/self_or.phpt @@ -32,8 +32,8 @@ int(127) Warning: A non-numeric value encountered in %s on line %d int(11) -Notice: A non well formed numeric value encountered in %s on line %d -int(45345) +Warning: A non-numeric value encountered in %s on line %d +int(33) string(1) "f" string(2) "ff" Done diff --git a/Zend/tests/self_xor.phpt b/Zend/tests/self_xor.phpt index e36a315b10d0a..66efd529dec0b 100644 --- a/Zend/tests/self_xor.phpt +++ b/Zend/tests/self_xor.phpt @@ -32,8 +32,8 @@ int(109) Warning: A non-numeric value encountered in %s on line %d int(11) -Notice: A non well formed numeric value encountered in %s on line %d -int(45312) +Warning: A non-numeric value encountered in %s on line %d +int(33) string(1) "F" string(2) "FF" Done diff --git a/Zend/tests/shift_001.phpt b/Zend/tests/shift_001.phpt index fba24f5fd019e..5def47bbc4efd 100644 --- a/Zend/tests/shift_001.phpt +++ b/Zend/tests/shift_001.phpt @@ -24,6 +24,6 @@ int(492) Warning: A non-numeric value encountered in %s on line %d int(0) -Notice: A non well formed numeric value encountered in %s on line %d -int(362760) +Warning: A non-numeric value encountered in %s on line %d +int(0) Done diff --git a/Zend/tests/shift_002.phpt b/Zend/tests/shift_002.phpt index fa068e1a90268..427bdb5365e03 100644 --- a/Zend/tests/shift_002.phpt +++ b/Zend/tests/shift_002.phpt @@ -24,6 +24,6 @@ int(30) Warning: A non-numeric value encountered in %s on line %d int(0) -Notice: A non well formed numeric value encountered in %s on line %d -int(5668) +Warning: A non-numeric value encountered in %s on line %d +int(0) Done diff --git a/Zend/tests/type_declarations/scalar_basic.phpt b/Zend/tests/type_declarations/scalar_basic.phpt index 002cab6042aee..908f1a18b248e 100644 --- a/Zend/tests/type_declarations/scalar_basic.phpt +++ b/Zend/tests/type_declarations/scalar_basic.phpt @@ -74,8 +74,7 @@ int(1) int(1) *** Trying string(2) "1a" -E_NOTICE: A non well formed numeric value encountered on line %d -int(1) +*** Caught {closure}(): Argument #1 ($i) must be of type int, string given, called in %s on line %d *** Trying string(1) "a" *** Caught {closure}(): Argument #1 ($i) must be of type int, string given, called in %s on line %d @@ -128,8 +127,7 @@ float(1) float(1.5) *** Trying string(2) "1a" -E_NOTICE: A non well formed numeric value encountered on line %d -float(1) +*** Caught {closure}(): Argument #1 ($f) must be of type float, string given, called in %s on line %d *** Trying string(1) "a" *** Caught {closure}(): Argument #1 ($f) must be of type float, string given, called in %s on line %d diff --git a/Zend/tests/type_declarations/scalar_return_basic.phpt b/Zend/tests/type_declarations/scalar_return_basic.phpt index 5ecd533840563..deb4289f25445 100644 --- a/Zend/tests/type_declarations/scalar_return_basic.phpt +++ b/Zend/tests/type_declarations/scalar_return_basic.phpt @@ -72,8 +72,7 @@ int(1) *** Trying float(1.5) int(1) *** Trying string(2) "1a" -E_NOTICE: A non well formed numeric value encountered on line %d -int(1) +*** Caught {closure}(): Return value must be of type int, string returned in %s on line %d *** Trying string(1) "a" *** Caught {closure}(): Return value must be of type int, string returned in %s on line %d *** Trying string(0) "" @@ -110,8 +109,7 @@ float(1) *** Trying float(1.5) float(1.5) *** Trying string(2) "1a" -E_NOTICE: A non well formed numeric value encountered on line %d -float(1) +*** Caught {closure}(): Return value must be of type float, string returned in %s on line %d *** Trying string(1) "a" *** Caught {closure}(): Return value must be of type float, string returned in %s on line %d *** Trying string(0) "" diff --git a/Zend/tests/type_declarations/scalar_return_basic_64bit.phpt b/Zend/tests/type_declarations/scalar_return_basic_64bit.phpt index 0fbccb1b69098..e49b9f5b2ad36 100644 --- a/Zend/tests/type_declarations/scalar_return_basic_64bit.phpt +++ b/Zend/tests/type_declarations/scalar_return_basic_64bit.phpt @@ -72,8 +72,7 @@ int(1) *** Trying float(1.5) int(1) *** Trying string(2) "1a" -E_NOTICE: A non well formed numeric value encountered on line %d -int(1) +*** Caught {closure}(): Return value must be of type int, string returned in %s on line %d *** Trying string(1) "a" *** Caught {closure}(): Return value must be of type int, string returned in %s on line %d *** Trying string(0) "" @@ -110,8 +109,7 @@ float(1) *** Trying float(1.5) float(1.5) *** Trying string(2) "1a" -E_NOTICE: A non well formed numeric value encountered on line %d -float(1) +*** Caught {closure}(): Return value must be of type float, string returned in %s on line %d *** Trying string(1) "a" *** Caught {closure}(): Return value must be of type float, string returned in %s on line %d *** Trying string(0) "" diff --git a/Zend/tests/type_declarations/union_types/type_checking_weak.phpt b/Zend/tests/type_declarations/union_types/type_checking_weak.phpt index 5675828953423..351a3e9e78ede 100644 --- a/Zend/tests/type_declarations/union_types/type_checking_weak.phpt +++ b/Zend/tests/type_declarations/union_types/type_checking_weak.phpt @@ -66,7 +66,7 @@ Type int|float: INF => INF "42" => 42 "42.0" => 42.0 -"42x" => 42 (A non well formed numeric value encountered) +"42x" => Argument ... must be of type int|float, string given "x" => Argument ... must be of type int|float, string given "" => Argument ... must be of type int|float, string given true => 1 @@ -82,7 +82,7 @@ Type int|float|false: INF => INF "42" => 42 "42.0" => 42.0 -"42x" => 42 (A non well formed numeric value encountered) +"42x" => Argument ... must be of type int|float|false, string given "x" => Argument ... must be of type int|float|false, string given "" => Argument ... must be of type int|float|false, string given true => 1 @@ -98,7 +98,7 @@ Type int|float|bool: INF => INF "42" => 42 "42.0" => 42.0 -"42x" => 42 (A non well formed numeric value encountered) +"42x" => true "x" => true "" => false true => true @@ -114,7 +114,7 @@ Type int|bool: INF => true "42" => 42 "42.0" => 42 -"42x" => 42 (A non well formed numeric value encountered) +"42x" => true "x" => true "" => false true => true @@ -162,7 +162,7 @@ Type float|array: INF => INF "42" => 42.0 "42.0" => 42.0 -"42x" => 42.0 (A non well formed numeric value encountered) +"42x" => Argument ... must be of type array|float, string given "x" => Argument ... must be of type array|float, string given "" => Argument ... must be of type array|float, string given true => 1.0 diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 7a8816b5cfef5..c6e4b03dfcf28 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -420,7 +420,7 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest) } } else if (EXPECTED(Z_TYPE_P(arg) == IS_STRING)) { double d; - int type; + zend_uchar type; if (UNEXPECTED((type = is_numeric_str_function(Z_STR_P(arg), dest, &d)) != IS_LONG)) { if (EXPECTED(type != 0)) { @@ -465,7 +465,7 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_double_weak(zval *arg, double *dest) / *dest = (double)Z_LVAL_P(arg); } else if (EXPECTED(Z_TYPE_P(arg) == IS_STRING)) { zend_long l; - int type; + zend_uchar type; if (UNEXPECTED((type = is_numeric_str_function(Z_STR_P(arg), &l, dest)) != IS_DOUBLE)) { if (EXPECTED(type != 0)) { @@ -509,7 +509,7 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_number_slow(zval *arg, zval **dest) /* zend_string *str = Z_STR_P(arg); zend_long lval; double dval; - zend_uchar type = is_numeric_string(ZSTR_VAL(str), ZSTR_LEN(str), &lval, &dval, -1); + zend_uchar type = is_numeric_str_function(str, &lval, &dval); if (type == IS_LONG) { ZVAL_LONG(arg, lval); } else if (type == IS_DOUBLE) { diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index efb2d008a87ff..699656fa693fb 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -728,7 +728,7 @@ static zend_bool zend_verify_weak_scalar_type_hint(uint32_t type_mask, zval *arg /* For an int|float union type and string value, * determine chosen type by is_numeric_string() semantics. */ if ((type_mask & MAY_BE_DOUBLE) && Z_TYPE_P(arg) == IS_STRING) { - zend_uchar type = is_numeric_string(Z_STRVAL_P(arg), Z_STRLEN_P(arg), &lval, &dval, -1); + zend_uchar type = is_numeric_string(Z_STRVAL_P(arg), Z_STRLEN_P(arg), &lval, &dval, false); if (type == IS_LONG) { zend_string_release(Z_STR_P(arg)); ZVAL_LONG(arg, lval); @@ -770,35 +770,11 @@ static zend_bool zend_verify_weak_scalar_type_hint_no_sideeffect(uint32_t type_m double dval; zend_bool bval; - if (type_mask & MAY_BE_LONG) { - if (Z_TYPE_P(arg) == IS_STRING) { - /* Handle this case separately to avoid the "non well-formed" warning */ - zend_uchar type = is_numeric_string(Z_STRVAL_P(arg), Z_STRLEN_P(arg), NULL, &dval, 1); - if (type == IS_LONG) { - return 1; - } - if (type == IS_DOUBLE) { - if ((type_mask & MAY_BE_DOUBLE) - || (!zend_isnan(dval) && ZEND_DOUBLE_FITS_LONG(dval))) { - return 1; - } - - } - } - if (zend_parse_arg_long_weak(arg, &lval)) { - return 1; - } + if (type_mask & MAY_BE_LONG && zend_parse_arg_long_weak(arg, &lval)) { + return 1; } - if (type_mask & MAY_BE_DOUBLE) { - if (Z_TYPE_P(arg) == IS_STRING) { - /* Handle this case separately to avoid the "non well-formed" warning */ - if (is_numeric_string(Z_STRVAL_P(arg), Z_STRLEN_P(arg), NULL, NULL, 1) != 0) { - return 1; - } - } - if (zend_parse_arg_double_weak(arg, &dval)) { - return 1; - } + if (type_mask & MAY_BE_DOUBLE && zend_parse_arg_double_weak(arg, &dval)) { + return 1; } /* We don't call cast_object here, because this check must be side-effect free. As this * is only used for a sanity check of arginfo/zpp consistency, it's okay if we accept @@ -1364,7 +1340,7 @@ static zend_never_inline zend_long zend_check_string_offset(zval *dim, int type if (UNEXPECTED(Z_TYPE_P(dim) != IS_LONG)) { switch(Z_TYPE_P(dim)) { case IS_STRING: - if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, -1)) { + if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, false)) { break; } if (type != BP_VAR_UNSET) { @@ -2351,7 +2327,7 @@ static zend_always_inline void zend_fetch_dimension_address_read(zval *result, z switch (Z_TYPE_P(dim)) { /* case IS_LONG: */ case IS_STRING: - if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, -1)) { + if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, false)) { break; } if (type == BP_VAR_IS) { diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index f0c17ea0d3d08..cd3668cf06a87 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -243,7 +243,8 @@ static zend_never_inline int ZEND_FASTCALL _zendi_try_convert_scalar_to_number(z ZVAL_LONG(holder, 1); return SUCCESS; case IS_STRING: - if ((Z_TYPE_INFO_P(holder) = is_numeric_string(Z_STRVAL_P(op), Z_STRLEN_P(op), &Z_LVAL_P(holder), &Z_DVAL_P(holder), -1)) == 0) { + if ((Z_TYPE_INFO_P(holder) = is_numeric_string(Z_STRVAL_P(op), Z_STRLEN_P(op), + &Z_LVAL_P(holder), &Z_DVAL_P(holder), false)) == 0) { ZVAL_LONG(holder, 0); zend_error(E_WARNING, "A non-numeric value encountered"); if (UNEXPECTED(EG(exception))) { @@ -293,7 +294,7 @@ static zend_never_inline zend_long ZEND_FASTCALL zendi_try_get_long(zval *op, ze zend_uchar type; zend_long lval; double dval; - if (0 == (type = is_numeric_string(Z_STRVAL_P(op), Z_STRLEN_P(op), &lval, &dval, -1))) { + if (0 == (type = is_numeric_string(Z_STRVAL_P(op), Z_STRLEN_P(op), &lval, &dval, false))) { zend_error(E_WARNING, "A non-numeric value encountered"); if (UNEXPECTED(EG(exception))) { *failed = 1; @@ -771,7 +772,7 @@ ZEND_API void ZEND_FASTCALL convert_to_object(zval *op) /* {{{ */ } /* }}} */ -static zend_always_inline zend_long ZEND_FASTCALL _zval_get_long_func_ex(zval *op, zend_bool silent) /* {{{ */ +ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op) /* {{{ */ { try_again: switch (Z_TYPE_P(op)) { @@ -792,10 +793,7 @@ static zend_always_inline zend_long ZEND_FASTCALL _zval_get_long_func_ex(zval *o zend_uchar type; zend_long lval; double dval; - if (0 == (type = is_numeric_string(Z_STRVAL_P(op), Z_STRLEN_P(op), &lval, &dval, silent ? 1 : -1))) { - if (!silent) { - zend_error(E_WARNING, "A non-numeric value encountered"); - } + if (0 == (type = is_numeric_string(Z_STRVAL_P(op), Z_STRLEN_P(op), &lval, &dval, true))) { return 0; } else if (EXPECTED(type == IS_LONG)) { return lval; @@ -829,12 +827,6 @@ static zend_always_inline zend_long ZEND_FASTCALL _zval_get_long_func_ex(zval *o } /* }}} */ -ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op) /* {{{ */ -{ - return _zval_get_long_func_ex(op, 1); -} -/* }}} */ - ZEND_API double ZEND_FASTCALL zval_get_double_func(zval *op) /* {{{ */ { try_again: @@ -2404,7 +2396,7 @@ ZEND_API int ZEND_FASTCALL increment_function(zval *op1) /* {{{ */ zend_long lval; double dval; - switch (is_numeric_string(Z_STRVAL_P(op1), Z_STRLEN_P(op1), &lval, &dval, 0)) { + switch (is_numeric_string(Z_STRVAL_P(op1), Z_STRLEN_P(op1), &lval, &dval, false)) { case IS_LONG: zval_ptr_dtor_str(op1); if (lval == ZEND_LONG_MAX) { @@ -2471,7 +2463,7 @@ ZEND_API int ZEND_FASTCALL decrement_function(zval *op1) /* {{{ */ ZVAL_LONG(op1, -1); break; } - switch (is_numeric_string(Z_STRVAL_P(op1), Z_STRLEN_P(op1), &lval, &dval, 0)) { + switch (is_numeric_string(Z_STRVAL_P(op1), Z_STRLEN_P(op1), &lval, &dval, false)) { case IS_LONG: zval_ptr_dtor_str(op1); if (lval == ZEND_LONG_MIN) { @@ -2816,8 +2808,8 @@ ZEND_API int ZEND_FASTCALL zendi_smart_streq(zend_string *s1, zend_string *s2) / zend_long lval1 = 0, lval2 = 0; double dval1 = 0.0, dval2 = 0.0; - if ((ret1 = is_numeric_string_ex(s1->val, s1->len, &lval1, &dval1, 0, &oflow1)) && - (ret2 = is_numeric_string_ex(s2->val, s2->len, &lval2, &dval2, 0, &oflow2))) { + if ((ret1 = is_numeric_string_ex(s1->val, s1->len, &lval1, &dval1, false, &oflow1)) && + (ret2 = is_numeric_string_ex(s2->val, s2->len, &lval2, &dval2, false, &oflow2))) { #if ZEND_ULONG_MAX == 0xFFFFFFFF if (oflow1 != 0 && oflow1 == oflow2 && dval1 - dval2 == 0. && ((oflow1 == 1 && dval1 > 9007199254740991. /*0x1FFFFFFFFFFFFF*/) @@ -2864,8 +2856,8 @@ ZEND_API int ZEND_FASTCALL zendi_smart_strcmp(zend_string *s1, zend_string *s2) zend_long lval1 = 0, lval2 = 0; double dval1 = 0.0, dval2 = 0.0; - if ((ret1 = is_numeric_string_ex(s1->val, s1->len, &lval1, &dval1, 0, &oflow1)) && - (ret2 = is_numeric_string_ex(s2->val, s2->len, &lval2, &dval2, 0, &oflow2))) { + if ((ret1 = is_numeric_string_ex(s1->val, s1->len, &lval1, &dval1, false, &oflow1)) && + (ret2 = is_numeric_string_ex(s2->val, s2->len, &lval2, &dval2, false, &oflow2))) { #if ZEND_ULONG_MAX == 0xFFFFFFFF if (oflow1 != 0 && oflow1 == oflow2 && dval1 - dval2 == 0. && ((oflow1 == 1 && dval1 > 9007199254740991. /*0x1FFFFFFFFFFFFF*/) @@ -2962,11 +2954,12 @@ ZEND_API zend_string* ZEND_FASTCALL zend_long_to_str(zend_long num) /* {{{ */ /* }}} */ ZEND_API zend_uchar ZEND_FASTCALL is_numeric_str_function(const zend_string *str, zend_long *lval, double *dval) /* {{{ */ { - return is_numeric_string_ex(ZSTR_VAL(str), ZSTR_LEN(str), lval, dval, -1, NULL); + return is_numeric_string(ZSTR_VAL(str), ZSTR_LEN(str), lval, dval, false); } /* }}} */ -ZEND_API zend_uchar ZEND_FASTCALL _is_numeric_string_ex(const char *str, size_t length, zend_long *lval, double *dval, int allow_errors, int *oflow_info) /* {{{ */ +ZEND_API zend_uchar ZEND_FASTCALL _is_numeric_string_ex(const char *str, size_t length, zend_long *lval, + double *dval, bool allow_errors, int *oflow_info) /* {{{ */ { const char *ptr; int digits = 0, dp_or_e = 0; @@ -3007,7 +3000,7 @@ ZEND_API zend_uchar ZEND_FASTCALL _is_numeric_string_ex(const char *str, size_t /* Count the number of digits. If a decimal point/exponent is found, * it's a double. Otherwise, if there's a dval or no need to check for * a full match, stop when there are too many digits for a long */ - for (type = IS_LONG; !(digits >= MAX_LENGTH_OF_LONG && (dval || allow_errors == 1)); digits++, ptr++) { + for (type = IS_LONG; !(digits >= MAX_LENGTH_OF_LONG && (dval || allow_errors)); digits++, ptr++) { check_digits: if (ZEND_IS_DIGIT(*ptr)) { tmp_lval = tmp_lval * 10 + (*ptr) - '0'; @@ -3043,7 +3036,7 @@ ZEND_API zend_uchar ZEND_FASTCALL _is_numeric_string_ex(const char *str, size_t * the digits if we need to check for a full match */ if (dval) { local_dval = zend_strtod(str, &ptr); - } else if (allow_errors != 1 && dp_or_e != -1) { + } else if (!allow_errors && dp_or_e != -1) { dp_or_e = (*ptr++ == '.') ? 1 : 2; goto check_digits; } @@ -3061,12 +3054,6 @@ ZEND_API zend_uchar ZEND_FASTCALL _is_numeric_string_ex(const char *str, size_t if (!allow_errors) { return 0; } - if (allow_errors == -1) { - zend_error(E_NOTICE, "A non well formed numeric value encountered"); - } - if (EG(exception)) { - return 0; - } } } diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index 2664514709c7a..246b403ba424a 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -86,7 +86,8 @@ static zend_always_inline zend_bool instanceof_function( * could not be represented as such due to overflow. It writes 1 to oflow_info * if the integer is larger than ZEND_LONG_MAX and -1 if it's smaller than ZEND_LONG_MIN. */ -ZEND_API zend_uchar ZEND_FASTCALL _is_numeric_string_ex(const char *str, size_t length, zend_long *lval, double *dval, int allow_errors, int *oflow_info); +ZEND_API zend_uchar ZEND_FASTCALL _is_numeric_string_ex(const char *str, size_t length, zend_long *lval, + double *dval, bool allow_errors, int *oflow_info); ZEND_API const char* ZEND_FASTCALL zend_memnstr_ex(const char *haystack, const char *needle, size_t needle_len, const char *end); ZEND_API const char* ZEND_FASTCALL zend_memnrstr_ex(const char *haystack, const char *needle, size_t needle_len, const char *end); @@ -135,7 +136,8 @@ static zend_always_inline zend_long zend_dval_to_lval_cap(double d) #define ZEND_IS_DIGIT(c) ((c) >= '0' && (c) <= '9') #define ZEND_IS_XDIGIT(c) (((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f')) -static zend_always_inline zend_uchar is_numeric_string_ex(const char *str, size_t length, zend_long *lval, double *dval, int allow_errors, int *oflow_info) +static zend_always_inline zend_uchar is_numeric_string_ex(const char *str, size_t length, zend_long *lval, + double *dval, bool allow_errors, int *oflow_info) { if (*str > '9') { return 0; @@ -143,7 +145,7 @@ static zend_always_inline zend_uchar is_numeric_string_ex(const char *str, size_ return _is_numeric_string_ex(str, length, lval, dval, allow_errors, oflow_info); } -static zend_always_inline zend_uchar is_numeric_string(const char *str, size_t length, zend_long *lval, double *dval, int allow_errors) { +static zend_always_inline zend_uchar is_numeric_string(const char *str, size_t length, zend_long *lval, double *dval, bool allow_errors) { return is_numeric_string_ex(str, length, lval, dval, allow_errors, NULL); } diff --git a/ext/opcache/jit/zend_jit_helpers.c b/ext/opcache/jit/zend_jit_helpers.c index e42fd196aa93f..2f9a6fe675bf6 100644 --- a/ext/opcache/jit/zend_jit_helpers.c +++ b/ext/opcache/jit/zend_jit_helpers.c @@ -679,7 +679,7 @@ static void ZEND_FASTCALL zend_jit_fetch_dim_str_r_helper(zval *container, zval switch (Z_TYPE_P(dim)) { /* case IS_LONG: */ case IS_STRING: - if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, -1)) { + if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, false)) { break; } zend_error(E_WARNING, "Illegal string offset \"%s\"", Z_STRVAL_P(dim)); @@ -728,7 +728,7 @@ static void ZEND_FASTCALL zend_jit_fetch_dim_str_is_helper(zval *container, zval switch (Z_TYPE_P(dim)) { /* case IS_LONG: */ case IS_STRING: - if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, -1)) { + if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, false)) { break; } ZVAL_NULL(result); @@ -818,7 +818,7 @@ static zend_never_inline zend_long zend_check_string_offset(zval *dim, int type) if (UNEXPECTED(Z_TYPE_P(dim) != IS_LONG)) { switch(Z_TYPE_P(dim)) { case IS_STRING: - if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, -1)) { + if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, false)) { break; } if (type != BP_VAR_UNSET) { @@ -1173,7 +1173,7 @@ static int ZEND_FASTCALL zend_jit_isset_dim_helper(zval *container, zval *offset ZVAL_DEREF(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, 0))) { + && IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, false))) { lval = zval_get_long(offset); goto isset_str_offset; } diff --git a/ext/opcache/tests/jit/fetch_dim_r_003.phpt b/ext/opcache/tests/jit/fetch_dim_r_003.phpt index c71b13ec12da3..da614915d7f7d 100644 --- a/ext/opcache/tests/jit/fetch_dim_r_003.phpt +++ b/ext/opcache/tests/jit/fetch_dim_r_003.phpt @@ -54,8 +54,8 @@ string(1) "A" Warning: Illegal string offset "ab" in %sfetch_dim_r_003.php on line 15 string(1) "A" -Notice: A non well formed numeric value encountered in %sfetch_dim_r_003.php on line 16 +Warning: Illegal string offset "2x" in %sfetch_dim_r_003.php on line 16 string(1) "C" -Notice: A non well formed numeric value encountered in %sfetch_dim_r_003.php on line 19 +Warning: Illegal string offset "2x" in %sfetch_dim_r_003.php on line 19 string(1) "C" diff --git a/ext/opcache/tests/jit/fetch_dim_r_004.phpt b/ext/opcache/tests/jit/fetch_dim_r_004.phpt index b781dc2cc4b42..5660a4dec1fbb 100644 --- a/ext/opcache/tests/jit/fetch_dim_r_004.phpt +++ b/ext/opcache/tests/jit/fetch_dim_r_004.phpt @@ -54,8 +54,8 @@ string(1) "A" Warning: Illegal string offset "ab" in %sfetch_dim_r_004.php on line 4 string(1) "A" -Notice: A non well formed numeric value encountered in %sfetch_dim_r_004.php on line 4 +Warning: Illegal string offset "2x" in %sfetch_dim_r_004.php on line 4 string(1) "C" -Notice: A non well formed numeric value encountered in %sfetch_dim_r_004.php on line 4 +Warning: Illegal string offset "2x" in %sfetch_dim_r_004.php on line 4 string(1) "C" diff --git a/ext/standard/tests/general_functions/floatval.phpt b/ext/standard/tests/general_functions/floatval.phpt index 73075c8163fa4..c7428c1710791 100644 --- a/ext/standard/tests/general_functions/floatval.phpt +++ b/ext/standard/tests/general_functions/floatval.phpt @@ -140,21 +140,21 @@ float(-5000000) *** Testing floatval() on non floating types *** -Notice: A non well formed numeric value encountered in %s on line %d +Warning: A non-numeric value encountered in %s on line %d -Notice: A non well formed numeric value encountered in %s on line %d +Warning: A non-numeric value encountered in %s on line %d float(-2147483648) float(2147483648) -float(%d) -float(%d) +float(5) +float(6) float(0) float(1) float(-1300) float(0) float(10) float(10.2) -float(11) -float(11) +float(1) +float(1) float(0) float(1) float(0) @@ -163,16 +163,16 @@ float(0) *** Testing doubleval() on non floating types *** float(-2147483648) float(2147483648) -float(%d) -float(%d) +float(5) +float(6) float(0) float(1) float(-1300) float(0) float(10) float(10.2) -float(11) -float(11) +float(1) +float(1) float(0) float(1) float(0) diff --git a/ext/standard/tests/general_functions/floatval_variation1.phpt b/ext/standard/tests/general_functions/floatval_variation1.phpt index 2f184a53e7aee..24af4c8dc2ebf 100644 --- a/ext/standard/tests/general_functions/floatval_variation1.phpt +++ b/ext/standard/tests/general_functions/floatval_variation1.phpt @@ -45,9 +45,9 @@ foreach ($not_float_types as $key => $type ) { } ?> --EXPECTF-- -Notice: A non well formed numeric value encountered in %s on line %d +Warning: A non-numeric value encountered in %s on line %d -Notice: A non well formed numeric value encountered in %s on line %d +Warning: A non-numeric value encountered in %s on line %d *** Testing floatval() on non floating types *** @@ -58,10 +58,10 @@ float(-2147483648) float(2147483648) -- Iteration : file resoruce -- -float(%d) +float(5) -- Iteration : directory resource -- -float(%d) +float(6) -- Iteration : "0.0" -- float(0) @@ -82,10 +82,10 @@ float(10) float(10.2) -- Iteration : "10.0 dollar" + 1 -- -float(11) +float(1) -- Iteration : "10.0 dollar" + 1.0 -- -float(11) +float(1) -- Iteration : "" -- float(0) @@ -108,10 +108,10 @@ float(-2147483648) float(2147483648) -- Iteration : file resoruce -- -float(%d) +float(5) -- Iteration : directory resource -- -float(%d) +float(6) -- Iteration : "0.0" -- float(0) @@ -132,10 +132,10 @@ float(10) float(10.2) -- Iteration : "10.0 dollar" + 1 -- -float(11) +float(1) -- Iteration : "10.0 dollar" + 1.0 -- -float(11) +float(1) -- Iteration : "" -- float(0) diff --git a/tests/lang/operators/add_variationStr.phpt b/tests/lang/operators/add_variationStr.phpt index 69dd870dcc360..e09c15fde64f4 100644 --- a/tests/lang/operators/add_variationStr.phpt +++ b/tests/lang/operators/add_variationStr.phpt @@ -33,19 +33,19 @@ float(-7.7) --- testing: '0' + 'abc' --- int(0) --- testing: '0' + '123abc' --- -int(123) +int(0) --- testing: '0' + '123e5' --- float(12300000) --- testing: '0' + '123e5xyz' --- -float(12300000) +int(0) --- testing: '0' + ' 123abc' --- -int(123) +int(0) --- testing: '0' + '123 abc' --- -int(123) +int(0) --- testing: '0' + '123abc ' --- -int(123) +int(0) --- testing: '0' + '3.4a' --- -float(3.4) +int(0) --- testing: '0' + 'a5.9' --- int(0) --- testing: '65' + '0' --- @@ -61,19 +61,19 @@ float(57.3) --- testing: '65' + 'abc' --- int(65) --- testing: '65' + '123abc' --- -int(188) +int(65) --- testing: '65' + '123e5' --- float(12300065) --- testing: '65' + '123e5xyz' --- -float(12300065) +int(65) --- testing: '65' + ' 123abc' --- -int(188) +int(65) --- testing: '65' + '123 abc' --- -int(188) +int(65) --- testing: '65' + '123abc ' --- -int(188) +int(65) --- testing: '65' + '3.4a' --- -float(68.4) +int(65) --- testing: '65' + 'a5.9' --- int(65) --- testing: '-44' + '0' --- @@ -89,19 +89,19 @@ float(-51.7) --- testing: '-44' + 'abc' --- int(-44) --- testing: '-44' + '123abc' --- -int(79) +int(-44) --- testing: '-44' + '123e5' --- float(12299956) --- testing: '-44' + '123e5xyz' --- -float(12299956) +int(-44) --- testing: '-44' + ' 123abc' --- -int(79) +int(-44) --- testing: '-44' + '123 abc' --- -int(79) +int(-44) --- testing: '-44' + '123abc ' --- -int(79) +int(-44) --- testing: '-44' + '3.4a' --- -float(-40.6) +int(-44) --- testing: '-44' + 'a5.9' --- int(-44) --- testing: '1.2' + '0' --- @@ -117,19 +117,19 @@ float(-6.5) --- testing: '1.2' + 'abc' --- float(1.2) --- testing: '1.2' + '123abc' --- -float(124.2) +float(1.2) --- testing: '1.2' + '123e5' --- float(12300001.2) --- testing: '1.2' + '123e5xyz' --- -float(12300001.2) +float(1.2) --- testing: '1.2' + ' 123abc' --- -float(124.2) +float(1.2) --- testing: '1.2' + '123 abc' --- -float(124.2) +float(1.2) --- testing: '1.2' + '123abc ' --- -float(124.2) +float(1.2) --- testing: '1.2' + '3.4a' --- -float(4.6) +float(1.2) --- testing: '1.2' + 'a5.9' --- float(1.2) --- testing: '-7.7' + '0' --- @@ -145,19 +145,19 @@ float(-15.4) --- testing: '-7.7' + 'abc' --- float(-7.7) --- testing: '-7.7' + '123abc' --- -float(115.3) +float(-7.7) --- testing: '-7.7' + '123e5' --- float(12299992.3) --- testing: '-7.7' + '123e5xyz' --- -float(12299992.3) +float(-7.7) --- testing: '-7.7' + ' 123abc' --- -float(115.3) +float(-7.7) --- testing: '-7.7' + '123 abc' --- -float(115.3) +float(-7.7) --- testing: '-7.7' + '123abc ' --- -float(115.3) +float(-7.7) --- testing: '-7.7' + '3.4a' --- -float(-4.300000000000001) +float(-7.7) --- testing: '-7.7' + 'a5.9' --- float(-7.7) --- testing: 'abc' + '0' --- @@ -173,49 +173,49 @@ float(-7.7) --- testing: 'abc' + 'abc' --- int(0) --- testing: 'abc' + '123abc' --- -int(123) +int(0) --- testing: 'abc' + '123e5' --- float(12300000) --- testing: 'abc' + '123e5xyz' --- -float(12300000) +int(0) --- testing: 'abc' + ' 123abc' --- -int(123) +int(0) --- testing: 'abc' + '123 abc' --- -int(123) +int(0) --- testing: 'abc' + '123abc ' --- -int(123) +int(0) --- testing: 'abc' + '3.4a' --- -float(3.4) +int(0) --- testing: 'abc' + 'a5.9' --- int(0) --- testing: '123abc' + '0' --- -int(123) +int(0) --- testing: '123abc' + '65' --- -int(188) +int(65) --- testing: '123abc' + '-44' --- -int(79) +int(-44) --- testing: '123abc' + '1.2' --- -float(124.2) +float(1.2) --- testing: '123abc' + '-7.7' --- -float(115.3) +float(-7.7) --- testing: '123abc' + 'abc' --- -int(123) +int(0) --- testing: '123abc' + '123abc' --- -int(246) +int(0) --- testing: '123abc' + '123e5' --- -float(12300123) +float(12300000) --- testing: '123abc' + '123e5xyz' --- -float(12300123) +int(0) --- testing: '123abc' + ' 123abc' --- -int(246) +int(0) --- testing: '123abc' + '123 abc' --- -int(246) +int(0) --- testing: '123abc' + '123abc ' --- -int(246) +int(0) --- testing: '123abc' + '3.4a' --- -float(126.4) +int(0) --- testing: '123abc' + 'a5.9' --- -int(123) +int(0) --- testing: '123e5' + '0' --- float(12300000) --- testing: '123e5' + '65' --- @@ -229,161 +229,161 @@ float(12299992.3) --- testing: '123e5' + 'abc' --- float(12300000) --- testing: '123e5' + '123abc' --- -float(12300123) +float(12300000) --- testing: '123e5' + '123e5' --- float(24600000) --- testing: '123e5' + '123e5xyz' --- -float(24600000) +float(12300000) --- testing: '123e5' + ' 123abc' --- -float(12300123) +float(12300000) --- testing: '123e5' + '123 abc' --- -float(12300123) +float(12300000) --- testing: '123e5' + '123abc ' --- -float(12300123) +float(12300000) --- testing: '123e5' + '3.4a' --- -float(12300003.4) +float(12300000) --- testing: '123e5' + 'a5.9' --- float(12300000) --- testing: '123e5xyz' + '0' --- -float(12300000) +int(0) --- testing: '123e5xyz' + '65' --- -float(12300065) +int(65) --- testing: '123e5xyz' + '-44' --- -float(12299956) +int(-44) --- testing: '123e5xyz' + '1.2' --- -float(12300001.2) +float(1.2) --- testing: '123e5xyz' + '-7.7' --- -float(12299992.3) +float(-7.7) --- testing: '123e5xyz' + 'abc' --- -float(12300000) +int(0) --- testing: '123e5xyz' + '123abc' --- -float(12300123) +int(0) --- testing: '123e5xyz' + '123e5' --- -float(24600000) +float(12300000) --- testing: '123e5xyz' + '123e5xyz' --- -float(24600000) +int(0) --- testing: '123e5xyz' + ' 123abc' --- -float(12300123) +int(0) --- testing: '123e5xyz' + '123 abc' --- -float(12300123) +int(0) --- testing: '123e5xyz' + '123abc ' --- -float(12300123) +int(0) --- testing: '123e5xyz' + '3.4a' --- -float(12300003.4) +int(0) --- testing: '123e5xyz' + 'a5.9' --- -float(12300000) +int(0) --- testing: ' 123abc' + '0' --- -int(123) +int(0) --- testing: ' 123abc' + '65' --- -int(188) +int(65) --- testing: ' 123abc' + '-44' --- -int(79) +int(-44) --- testing: ' 123abc' + '1.2' --- -float(124.2) +float(1.2) --- testing: ' 123abc' + '-7.7' --- -float(115.3) +float(-7.7) --- testing: ' 123abc' + 'abc' --- -int(123) +int(0) --- testing: ' 123abc' + '123abc' --- -int(246) +int(0) --- testing: ' 123abc' + '123e5' --- -float(12300123) +float(12300000) --- testing: ' 123abc' + '123e5xyz' --- -float(12300123) +int(0) --- testing: ' 123abc' + ' 123abc' --- -int(246) +int(0) --- testing: ' 123abc' + '123 abc' --- -int(246) +int(0) --- testing: ' 123abc' + '123abc ' --- -int(246) +int(0) --- testing: ' 123abc' + '3.4a' --- -float(126.4) +int(0) --- testing: ' 123abc' + 'a5.9' --- -int(123) +int(0) --- testing: '123 abc' + '0' --- -int(123) +int(0) --- testing: '123 abc' + '65' --- -int(188) +int(65) --- testing: '123 abc' + '-44' --- -int(79) +int(-44) --- testing: '123 abc' + '1.2' --- -float(124.2) +float(1.2) --- testing: '123 abc' + '-7.7' --- -float(115.3) +float(-7.7) --- testing: '123 abc' + 'abc' --- -int(123) +int(0) --- testing: '123 abc' + '123abc' --- -int(246) +int(0) --- testing: '123 abc' + '123e5' --- -float(12300123) +float(12300000) --- testing: '123 abc' + '123e5xyz' --- -float(12300123) +int(0) --- testing: '123 abc' + ' 123abc' --- -int(246) +int(0) --- testing: '123 abc' + '123 abc' --- -int(246) +int(0) --- testing: '123 abc' + '123abc ' --- -int(246) +int(0) --- testing: '123 abc' + '3.4a' --- -float(126.4) +int(0) --- testing: '123 abc' + 'a5.9' --- -int(123) +int(0) --- testing: '123abc ' + '0' --- -int(123) +int(0) --- testing: '123abc ' + '65' --- -int(188) +int(65) --- testing: '123abc ' + '-44' --- -int(79) +int(-44) --- testing: '123abc ' + '1.2' --- -float(124.2) +float(1.2) --- testing: '123abc ' + '-7.7' --- -float(115.3) +float(-7.7) --- testing: '123abc ' + 'abc' --- -int(123) +int(0) --- testing: '123abc ' + '123abc' --- -int(246) +int(0) --- testing: '123abc ' + '123e5' --- -float(12300123) +float(12300000) --- testing: '123abc ' + '123e5xyz' --- -float(12300123) +int(0) --- testing: '123abc ' + ' 123abc' --- -int(246) +int(0) --- testing: '123abc ' + '123 abc' --- -int(246) +int(0) --- testing: '123abc ' + '123abc ' --- -int(246) +int(0) --- testing: '123abc ' + '3.4a' --- -float(126.4) +int(0) --- testing: '123abc ' + 'a5.9' --- -int(123) +int(0) --- testing: '3.4a' + '0' --- -float(3.4) +int(0) --- testing: '3.4a' + '65' --- -float(68.4) +int(65) --- testing: '3.4a' + '-44' --- -float(-40.6) +int(-44) --- testing: '3.4a' + '1.2' --- -float(4.6) +float(1.2) --- testing: '3.4a' + '-7.7' --- -float(-4.300000000000001) +float(-7.7) --- testing: '3.4a' + 'abc' --- -float(3.4) +int(0) --- testing: '3.4a' + '123abc' --- -float(126.4) +int(0) --- testing: '3.4a' + '123e5' --- -float(12300003.4) +float(12300000) --- testing: '3.4a' + '123e5xyz' --- -float(12300003.4) +int(0) --- testing: '3.4a' + ' 123abc' --- -float(126.4) +int(0) --- testing: '3.4a' + '123 abc' --- -float(126.4) +int(0) --- testing: '3.4a' + '123abc ' --- -float(126.4) +int(0) --- testing: '3.4a' + '3.4a' --- -float(6.8) +int(0) --- testing: '3.4a' + 'a5.9' --- -float(3.4) +int(0) --- testing: 'a5.9' + '0' --- int(0) --- testing: 'a5.9' + '65' --- @@ -397,18 +397,18 @@ float(-7.7) --- testing: 'a5.9' + 'abc' --- int(0) --- testing: 'a5.9' + '123abc' --- -int(123) +int(0) --- testing: 'a5.9' + '123e5' --- float(12300000) --- testing: 'a5.9' + '123e5xyz' --- -float(12300000) +int(0) --- testing: 'a5.9' + ' 123abc' --- -int(123) +int(0) --- testing: 'a5.9' + '123 abc' --- -int(123) +int(0) --- testing: 'a5.9' + '123abc ' --- -int(123) +int(0) --- testing: 'a5.9' + '3.4a' --- -float(3.4) +int(0) --- testing: 'a5.9' + 'a5.9' --- int(0) diff --git a/tests/lang/operators/bitwiseShiftLeft_variationStr.phpt b/tests/lang/operators/bitwiseShiftLeft_variationStr.phpt index 49de21f64bcc4..3c094a7d61106 100644 --- a/tests/lang/operators/bitwiseShiftLeft_variationStr.phpt +++ b/tests/lang/operators/bitwiseShiftLeft_variationStr.phpt @@ -64,19 +64,19 @@ Exception: Bit shift by negative number --- testing: '65' << 'abc' --- int(65) --- testing: '65' << '123abc' --- -int(0) +int(65) --- testing: '65' << '123e5' --- int(0) --- testing: '65' << '123e5xyz' --- -int(0) +int(65) --- testing: '65' << ' 123abc' --- -int(0) +int(65) --- testing: '65' << '123 abc' --- -int(0) +int(65) --- testing: '65' << '123abc ' --- -int(0) +int(65) --- testing: '65' << '3.4a' --- -int(520) +int(65) --- testing: '65' << 'a5.9' --- int(65) --- testing: '-44' << '0' --- @@ -92,19 +92,19 @@ Exception: Bit shift by negative number --- testing: '-44' << 'abc' --- int(-44) --- testing: '-44' << '123abc' --- -int(0) +int(-44) --- testing: '-44' << '123e5' --- int(0) --- testing: '-44' << '123e5xyz' --- -int(0) +int(-44) --- testing: '-44' << ' 123abc' --- -int(0) +int(-44) --- testing: '-44' << '123 abc' --- -int(0) +int(-44) --- testing: '-44' << '123abc ' --- -int(0) +int(-44) --- testing: '-44' << '3.4a' --- -int(-352) +int(-44) --- testing: '-44' << 'a5.9' --- int(-44) --- testing: '1.2' << '0' --- @@ -120,19 +120,19 @@ Exception: Bit shift by negative number --- testing: '1.2' << 'abc' --- int(1) --- testing: '1.2' << '123abc' --- -int(0) +int(1) --- testing: '1.2' << '123e5' --- int(0) --- testing: '1.2' << '123e5xyz' --- -int(0) +int(1) --- testing: '1.2' << ' 123abc' --- -int(0) +int(1) --- testing: '1.2' << '123 abc' --- -int(0) +int(1) --- testing: '1.2' << '123abc ' --- -int(0) +int(1) --- testing: '1.2' << '3.4a' --- -int(8) +int(1) --- testing: '1.2' << 'a5.9' --- int(1) --- testing: '-7.7' << '0' --- @@ -148,19 +148,19 @@ Exception: Bit shift by negative number --- testing: '-7.7' << 'abc' --- int(-7) --- testing: '-7.7' << '123abc' --- -int(0) +int(-7) --- testing: '-7.7' << '123e5' --- int(0) --- testing: '-7.7' << '123e5xyz' --- -int(0) +int(-7) --- testing: '-7.7' << ' 123abc' --- -int(0) +int(-7) --- testing: '-7.7' << '123 abc' --- -int(0) +int(-7) --- testing: '-7.7' << '123abc ' --- -int(0) +int(-7) --- testing: '-7.7' << '3.4a' --- -int(-56) +int(-7) --- testing: '-7.7' << 'a5.9' --- int(-7) --- testing: 'abc' << '0' --- @@ -192,17 +192,17 @@ int(0) --- testing: 'abc' << 'a5.9' --- int(0) --- testing: '123abc' << '0' --- -int(123) +int(0) --- testing: '123abc' << '65' --- int(0) --- testing: '123abc' << '-44' --- Exception: Bit shift by negative number --- testing: '123abc' << '1.2' --- -int(246) +int(0) --- testing: '123abc' << '-7.7' --- Exception: Bit shift by negative number --- testing: '123abc' << 'abc' --- -int(123) +int(0) --- testing: '123abc' << '123abc' --- int(0) --- testing: '123abc' << '123e5' --- @@ -216,9 +216,9 @@ int(0) --- testing: '123abc' << '123abc ' --- int(0) --- testing: '123abc' << '3.4a' --- -int(984) +int(0) --- testing: '123abc' << 'a5.9' --- -int(123) +int(0) --- testing: '123e5' << '0' --- int(12300000) --- testing: '123e5' << '65' --- @@ -232,33 +232,33 @@ Exception: Bit shift by negative number --- testing: '123e5' << 'abc' --- int(12300000) --- testing: '123e5' << '123abc' --- -int(0) +int(12300000) --- testing: '123e5' << '123e5' --- int(0) --- testing: '123e5' << '123e5xyz' --- -int(0) +int(12300000) --- testing: '123e5' << ' 123abc' --- -int(0) +int(12300000) --- testing: '123e5' << '123 abc' --- -int(0) +int(12300000) --- testing: '123e5' << '123abc ' --- -int(0) +int(12300000) --- testing: '123e5' << '3.4a' --- -int(98400000) +int(12300000) --- testing: '123e5' << 'a5.9' --- int(12300000) --- testing: '123e5xyz' << '0' --- -int(12300000) +int(0) --- testing: '123e5xyz' << '65' --- int(0) --- testing: '123e5xyz' << '-44' --- Exception: Bit shift by negative number --- testing: '123e5xyz' << '1.2' --- -int(24600000) +int(0) --- testing: '123e5xyz' << '-7.7' --- Exception: Bit shift by negative number --- testing: '123e5xyz' << 'abc' --- -int(12300000) +int(0) --- testing: '123e5xyz' << '123abc' --- int(0) --- testing: '123e5xyz' << '123e5' --- @@ -272,21 +272,21 @@ int(0) --- testing: '123e5xyz' << '123abc ' --- int(0) --- testing: '123e5xyz' << '3.4a' --- -int(98400000) +int(0) --- testing: '123e5xyz' << 'a5.9' --- -int(12300000) +int(0) --- testing: ' 123abc' << '0' --- -int(123) +int(0) --- testing: ' 123abc' << '65' --- int(0) --- testing: ' 123abc' << '-44' --- Exception: Bit shift by negative number --- testing: ' 123abc' << '1.2' --- -int(246) +int(0) --- testing: ' 123abc' << '-7.7' --- Exception: Bit shift by negative number --- testing: ' 123abc' << 'abc' --- -int(123) +int(0) --- testing: ' 123abc' << '123abc' --- int(0) --- testing: ' 123abc' << '123e5' --- @@ -300,21 +300,21 @@ int(0) --- testing: ' 123abc' << '123abc ' --- int(0) --- testing: ' 123abc' << '3.4a' --- -int(984) +int(0) --- testing: ' 123abc' << 'a5.9' --- -int(123) +int(0) --- testing: '123 abc' << '0' --- -int(123) +int(0) --- testing: '123 abc' << '65' --- int(0) --- testing: '123 abc' << '-44' --- Exception: Bit shift by negative number --- testing: '123 abc' << '1.2' --- -int(246) +int(0) --- testing: '123 abc' << '-7.7' --- Exception: Bit shift by negative number --- testing: '123 abc' << 'abc' --- -int(123) +int(0) --- testing: '123 abc' << '123abc' --- int(0) --- testing: '123 abc' << '123e5' --- @@ -328,21 +328,21 @@ int(0) --- testing: '123 abc' << '123abc ' --- int(0) --- testing: '123 abc' << '3.4a' --- -int(984) +int(0) --- testing: '123 abc' << 'a5.9' --- -int(123) +int(0) --- testing: '123abc ' << '0' --- -int(123) +int(0) --- testing: '123abc ' << '65' --- int(0) --- testing: '123abc ' << '-44' --- Exception: Bit shift by negative number --- testing: '123abc ' << '1.2' --- -int(246) +int(0) --- testing: '123abc ' << '-7.7' --- Exception: Bit shift by negative number --- testing: '123abc ' << 'abc' --- -int(123) +int(0) --- testing: '123abc ' << '123abc' --- int(0) --- testing: '123abc ' << '123e5' --- @@ -356,21 +356,21 @@ int(0) --- testing: '123abc ' << '123abc ' --- int(0) --- testing: '123abc ' << '3.4a' --- -int(984) +int(0) --- testing: '123abc ' << 'a5.9' --- -int(123) +int(0) --- testing: '3.4a' << '0' --- -int(3) +int(0) --- testing: '3.4a' << '65' --- int(0) --- testing: '3.4a' << '-44' --- Exception: Bit shift by negative number --- testing: '3.4a' << '1.2' --- -int(6) +int(0) --- testing: '3.4a' << '-7.7' --- Exception: Bit shift by negative number --- testing: '3.4a' << 'abc' --- -int(3) +int(0) --- testing: '3.4a' << '123abc' --- int(0) --- testing: '3.4a' << '123e5' --- @@ -384,9 +384,9 @@ int(0) --- testing: '3.4a' << '123abc ' --- int(0) --- testing: '3.4a' << '3.4a' --- -int(24) +int(0) --- testing: '3.4a' << 'a5.9' --- -int(3) +int(0) --- testing: 'a5.9' << '0' --- int(0) --- testing: 'a5.9' << '65' --- diff --git a/tests/lang/operators/bitwiseShiftLeft_variationStr_64bit.phpt b/tests/lang/operators/bitwiseShiftLeft_variationStr_64bit.phpt index b3ca624abb2c1..709ff1b906e89 100644 --- a/tests/lang/operators/bitwiseShiftLeft_variationStr_64bit.phpt +++ b/tests/lang/operators/bitwiseShiftLeft_variationStr_64bit.phpt @@ -69,19 +69,19 @@ Exception: Bit shift by negative number --- testing: '65' << 'abc' --- int(65) --- testing: '65' << '123abc' --- -int(0) +int(65) --- testing: '65' << '123e5' --- int(0) --- testing: '65' << '123e5xyz' --- -int(0) +int(65) --- testing: '65' << ' 123abc' --- -int(0) +int(65) --- testing: '65' << '123 abc' --- -int(0) +int(65) --- testing: '65' << '123abc ' --- -int(0) +int(65) --- testing: '65' << '3.4a' --- -int(520) +int(65) --- testing: '65' << 'a5.9' --- int(65) --- testing: '-44' << '0' --- @@ -97,19 +97,19 @@ Exception: Bit shift by negative number --- testing: '-44' << 'abc' --- int(-44) --- testing: '-44' << '123abc' --- -int(0) +int(-44) --- testing: '-44' << '123e5' --- int(0) --- testing: '-44' << '123e5xyz' --- -int(0) +int(-44) --- testing: '-44' << ' 123abc' --- -int(0) +int(-44) --- testing: '-44' << '123 abc' --- -int(0) +int(-44) --- testing: '-44' << '123abc ' --- -int(0) +int(-44) --- testing: '-44' << '3.4a' --- -int(-352) +int(-44) --- testing: '-44' << 'a5.9' --- int(-44) --- testing: '1.2' << '0' --- @@ -125,19 +125,19 @@ Exception: Bit shift by negative number --- testing: '1.2' << 'abc' --- int(1) --- testing: '1.2' << '123abc' --- -int(0) +int(1) --- testing: '1.2' << '123e5' --- int(0) --- testing: '1.2' << '123e5xyz' --- -int(0) +int(1) --- testing: '1.2' << ' 123abc' --- -int(0) +int(1) --- testing: '1.2' << '123 abc' --- -int(0) +int(1) --- testing: '1.2' << '123abc ' --- -int(0) +int(1) --- testing: '1.2' << '3.4a' --- -int(8) +int(1) --- testing: '1.2' << 'a5.9' --- int(1) --- testing: '-7.7' << '0' --- @@ -153,19 +153,19 @@ Exception: Bit shift by negative number --- testing: '-7.7' << 'abc' --- int(-7) --- testing: '-7.7' << '123abc' --- -int(0) +int(-7) --- testing: '-7.7' << '123e5' --- int(0) --- testing: '-7.7' << '123e5xyz' --- -int(0) +int(-7) --- testing: '-7.7' << ' 123abc' --- -int(0) +int(-7) --- testing: '-7.7' << '123 abc' --- -int(0) +int(-7) --- testing: '-7.7' << '123abc ' --- -int(0) +int(-7) --- testing: '-7.7' << '3.4a' --- -int(-56) +int(-7) --- testing: '-7.7' << 'a5.9' --- int(-7) --- testing: 'abc' << '0' --- @@ -197,17 +197,17 @@ int(0) --- testing: 'abc' << 'a5.9' --- int(0) --- testing: '123abc' << '0' --- -int(123) +int(0) --- testing: '123abc' << '65' --- int(0) --- testing: '123abc' << '-44' --- Exception: Bit shift by negative number --- testing: '123abc' << '1.2' --- -int(246) +int(0) --- testing: '123abc' << '-7.7' --- Exception: Bit shift by negative number --- testing: '123abc' << 'abc' --- -int(123) +int(0) --- testing: '123abc' << '123abc' --- int(0) --- testing: '123abc' << '123e5' --- @@ -221,9 +221,9 @@ int(0) --- testing: '123abc' << '123abc ' --- int(0) --- testing: '123abc' << '3.4a' --- -int(984) +int(0) --- testing: '123abc' << 'a5.9' --- -int(123) +int(0) --- testing: '123e5' << '0' --- int(12300000) --- testing: '123e5' << '65' --- @@ -237,33 +237,33 @@ Exception: Bit shift by negative number --- testing: '123e5' << 'abc' --- int(12300000) --- testing: '123e5' << '123abc' --- -int(0) +int(12300000) --- testing: '123e5' << '123e5' --- int(0) --- testing: '123e5' << '123e5xyz' --- -int(0) +int(12300000) --- testing: '123e5' << ' 123abc' --- -int(0) +int(12300000) --- testing: '123e5' << '123 abc' --- -int(0) +int(12300000) --- testing: '123e5' << '123abc ' --- -int(0) +int(12300000) --- testing: '123e5' << '3.4a' --- -int(98400000) +int(12300000) --- testing: '123e5' << 'a5.9' --- int(12300000) --- testing: '123e5xyz' << '0' --- -int(12300000) +int(0) --- testing: '123e5xyz' << '65' --- int(0) --- testing: '123e5xyz' << '-44' --- Exception: Bit shift by negative number --- testing: '123e5xyz' << '1.2' --- -int(24600000) +int(0) --- testing: '123e5xyz' << '-7.7' --- Exception: Bit shift by negative number --- testing: '123e5xyz' << 'abc' --- -int(12300000) +int(0) --- testing: '123e5xyz' << '123abc' --- int(0) --- testing: '123e5xyz' << '123e5' --- @@ -277,21 +277,21 @@ int(0) --- testing: '123e5xyz' << '123abc ' --- int(0) --- testing: '123e5xyz' << '3.4a' --- -int(98400000) +int(0) --- testing: '123e5xyz' << 'a5.9' --- -int(12300000) +int(0) --- testing: ' 123abc' << '0' --- -int(123) +int(0) --- testing: ' 123abc' << '65' --- int(0) --- testing: ' 123abc' << '-44' --- Exception: Bit shift by negative number --- testing: ' 123abc' << '1.2' --- -int(246) +int(0) --- testing: ' 123abc' << '-7.7' --- Exception: Bit shift by negative number --- testing: ' 123abc' << 'abc' --- -int(123) +int(0) --- testing: ' 123abc' << '123abc' --- int(0) --- testing: ' 123abc' << '123e5' --- @@ -305,21 +305,21 @@ int(0) --- testing: ' 123abc' << '123abc ' --- int(0) --- testing: ' 123abc' << '3.4a' --- -int(984) +int(0) --- testing: ' 123abc' << 'a5.9' --- -int(123) +int(0) --- testing: '123 abc' << '0' --- -int(123) +int(0) --- testing: '123 abc' << '65' --- int(0) --- testing: '123 abc' << '-44' --- Exception: Bit shift by negative number --- testing: '123 abc' << '1.2' --- -int(246) +int(0) --- testing: '123 abc' << '-7.7' --- Exception: Bit shift by negative number --- testing: '123 abc' << 'abc' --- -int(123) +int(0) --- testing: '123 abc' << '123abc' --- int(0) --- testing: '123 abc' << '123e5' --- @@ -333,21 +333,21 @@ int(0) --- testing: '123 abc' << '123abc ' --- int(0) --- testing: '123 abc' << '3.4a' --- -int(984) +int(0) --- testing: '123 abc' << 'a5.9' --- -int(123) +int(0) --- testing: '123abc ' << '0' --- -int(123) +int(0) --- testing: '123abc ' << '65' --- int(0) --- testing: '123abc ' << '-44' --- Exception: Bit shift by negative number --- testing: '123abc ' << '1.2' --- -int(246) +int(0) --- testing: '123abc ' << '-7.7' --- Exception: Bit shift by negative number --- testing: '123abc ' << 'abc' --- -int(123) +int(0) --- testing: '123abc ' << '123abc' --- int(0) --- testing: '123abc ' << '123e5' --- @@ -361,21 +361,21 @@ int(0) --- testing: '123abc ' << '123abc ' --- int(0) --- testing: '123abc ' << '3.4a' --- -int(984) +int(0) --- testing: '123abc ' << 'a5.9' --- -int(123) +int(0) --- testing: '3.4a' << '0' --- -int(3) +int(0) --- testing: '3.4a' << '65' --- int(0) --- testing: '3.4a' << '-44' --- Exception: Bit shift by negative number --- testing: '3.4a' << '1.2' --- -int(6) +int(0) --- testing: '3.4a' << '-7.7' --- Exception: Bit shift by negative number --- testing: '3.4a' << 'abc' --- -int(3) +int(0) --- testing: '3.4a' << '123abc' --- int(0) --- testing: '3.4a' << '123e5' --- @@ -389,9 +389,9 @@ int(0) --- testing: '3.4a' << '123abc ' --- int(0) --- testing: '3.4a' << '3.4a' --- -int(24) +int(0) --- testing: '3.4a' << 'a5.9' --- -int(3) +int(0) --- testing: 'a5.9' << '0' --- int(0) --- testing: 'a5.9' << '65' --- diff --git a/tests/lang/operators/bitwiseShiftRight_variationStr.phpt b/tests/lang/operators/bitwiseShiftRight_variationStr.phpt index 525f951a5170f..5e08979e84f2f 100644 --- a/tests/lang/operators/bitwiseShiftRight_variationStr.phpt +++ b/tests/lang/operators/bitwiseShiftRight_variationStr.phpt @@ -65,19 +65,19 @@ Exception: Bit shift by negative number --- testing: '65' >> 'abc' --- int(65) --- testing: '65' >> '123abc' --- -int(0) +int(65) --- testing: '65' >> '123e5' --- int(0) --- testing: '65' >> '123e5xyz' --- -int(0) +int(65) --- testing: '65' >> ' 123abc' --- -int(0) +int(65) --- testing: '65' >> '123 abc' --- -int(0) +int(65) --- testing: '65' >> '123abc ' --- -int(0) +int(65) --- testing: '65' >> '3.4a' --- -int(8) +int(65) --- testing: '65' >> 'a5.9' --- int(65) --- testing: '-44' >> '0' --- @@ -93,19 +93,19 @@ Exception: Bit shift by negative number --- testing: '-44' >> 'abc' --- int(-44) --- testing: '-44' >> '123abc' --- -int(-1) +int(-44) --- testing: '-44' >> '123e5' --- int(-1) --- testing: '-44' >> '123e5xyz' --- -int(-1) +int(-44) --- testing: '-44' >> ' 123abc' --- -int(-1) +int(-44) --- testing: '-44' >> '123 abc' --- -int(-1) +int(-44) --- testing: '-44' >> '123abc ' --- -int(-1) +int(-44) --- testing: '-44' >> '3.4a' --- -int(-6) +int(-44) --- testing: '-44' >> 'a5.9' --- int(-44) --- testing: '1.2' >> '0' --- @@ -121,19 +121,19 @@ Exception: Bit shift by negative number --- testing: '1.2' >> 'abc' --- int(1) --- testing: '1.2' >> '123abc' --- -int(0) +int(1) --- testing: '1.2' >> '123e5' --- int(0) --- testing: '1.2' >> '123e5xyz' --- -int(0) +int(1) --- testing: '1.2' >> ' 123abc' --- -int(0) +int(1) --- testing: '1.2' >> '123 abc' --- -int(0) +int(1) --- testing: '1.2' >> '123abc ' --- -int(0) +int(1) --- testing: '1.2' >> '3.4a' --- -int(0) +int(1) --- testing: '1.2' >> 'a5.9' --- int(1) --- testing: '-7.7' >> '0' --- @@ -149,19 +149,19 @@ Exception: Bit shift by negative number --- testing: '-7.7' >> 'abc' --- int(-7) --- testing: '-7.7' >> '123abc' --- -int(-1) +int(-7) --- testing: '-7.7' >> '123e5' --- int(-1) --- testing: '-7.7' >> '123e5xyz' --- -int(-1) +int(-7) --- testing: '-7.7' >> ' 123abc' --- -int(-1) +int(-7) --- testing: '-7.7' >> '123 abc' --- -int(-1) +int(-7) --- testing: '-7.7' >> '123abc ' --- -int(-1) +int(-7) --- testing: '-7.7' >> '3.4a' --- -int(-1) +int(-7) --- testing: '-7.7' >> 'a5.9' --- int(-7) --- testing: 'abc' >> '0' --- @@ -193,17 +193,17 @@ int(0) --- testing: 'abc' >> 'a5.9' --- int(0) --- testing: '123abc' >> '0' --- -int(123) +int(0) --- testing: '123abc' >> '65' --- int(0) --- testing: '123abc' >> '-44' --- Exception: Bit shift by negative number --- testing: '123abc' >> '1.2' --- -int(61) +int(0) --- testing: '123abc' >> '-7.7' --- Exception: Bit shift by negative number --- testing: '123abc' >> 'abc' --- -int(123) +int(0) --- testing: '123abc' >> '123abc' --- int(0) --- testing: '123abc' >> '123e5' --- @@ -217,9 +217,9 @@ int(0) --- testing: '123abc' >> '123abc ' --- int(0) --- testing: '123abc' >> '3.4a' --- -int(15) +int(0) --- testing: '123abc' >> 'a5.9' --- -int(123) +int(0) --- testing: '123e5' >> '0' --- int(12300000) --- testing: '123e5' >> '65' --- @@ -233,33 +233,33 @@ Exception: Bit shift by negative number --- testing: '123e5' >> 'abc' --- int(12300000) --- testing: '123e5' >> '123abc' --- -int(0) +int(12300000) --- testing: '123e5' >> '123e5' --- int(0) --- testing: '123e5' >> '123e5xyz' --- -int(0) +int(12300000) --- testing: '123e5' >> ' 123abc' --- -int(0) +int(12300000) --- testing: '123e5' >> '123 abc' --- -int(0) +int(12300000) --- testing: '123e5' >> '123abc ' --- -int(0) +int(12300000) --- testing: '123e5' >> '3.4a' --- -int(1537500) +int(12300000) --- testing: '123e5' >> 'a5.9' --- int(12300000) --- testing: '123e5xyz' >> '0' --- -int(12300000) +int(0) --- testing: '123e5xyz' >> '65' --- int(0) --- testing: '123e5xyz' >> '-44' --- Exception: Bit shift by negative number --- testing: '123e5xyz' >> '1.2' --- -int(6150000) +int(0) --- testing: '123e5xyz' >> '-7.7' --- Exception: Bit shift by negative number --- testing: '123e5xyz' >> 'abc' --- -int(12300000) +int(0) --- testing: '123e5xyz' >> '123abc' --- int(0) --- testing: '123e5xyz' >> '123e5' --- @@ -273,21 +273,21 @@ int(0) --- testing: '123e5xyz' >> '123abc ' --- int(0) --- testing: '123e5xyz' >> '3.4a' --- -int(1537500) +int(0) --- testing: '123e5xyz' >> 'a5.9' --- -int(12300000) +int(0) --- testing: ' 123abc' >> '0' --- -int(123) +int(0) --- testing: ' 123abc' >> '65' --- int(0) --- testing: ' 123abc' >> '-44' --- Exception: Bit shift by negative number --- testing: ' 123abc' >> '1.2' --- -int(61) +int(0) --- testing: ' 123abc' >> '-7.7' --- Exception: Bit shift by negative number --- testing: ' 123abc' >> 'abc' --- -int(123) +int(0) --- testing: ' 123abc' >> '123abc' --- int(0) --- testing: ' 123abc' >> '123e5' --- @@ -301,21 +301,21 @@ int(0) --- testing: ' 123abc' >> '123abc ' --- int(0) --- testing: ' 123abc' >> '3.4a' --- -int(15) +int(0) --- testing: ' 123abc' >> 'a5.9' --- -int(123) +int(0) --- testing: '123 abc' >> '0' --- -int(123) +int(0) --- testing: '123 abc' >> '65' --- int(0) --- testing: '123 abc' >> '-44' --- Exception: Bit shift by negative number --- testing: '123 abc' >> '1.2' --- -int(61) +int(0) --- testing: '123 abc' >> '-7.7' --- Exception: Bit shift by negative number --- testing: '123 abc' >> 'abc' --- -int(123) +int(0) --- testing: '123 abc' >> '123abc' --- int(0) --- testing: '123 abc' >> '123e5' --- @@ -329,21 +329,21 @@ int(0) --- testing: '123 abc' >> '123abc ' --- int(0) --- testing: '123 abc' >> '3.4a' --- -int(15) +int(0) --- testing: '123 abc' >> 'a5.9' --- -int(123) +int(0) --- testing: '123abc ' >> '0' --- -int(123) +int(0) --- testing: '123abc ' >> '65' --- int(0) --- testing: '123abc ' >> '-44' --- Exception: Bit shift by negative number --- testing: '123abc ' >> '1.2' --- -int(61) +int(0) --- testing: '123abc ' >> '-7.7' --- Exception: Bit shift by negative number --- testing: '123abc ' >> 'abc' --- -int(123) +int(0) --- testing: '123abc ' >> '123abc' --- int(0) --- testing: '123abc ' >> '123e5' --- @@ -357,21 +357,21 @@ int(0) --- testing: '123abc ' >> '123abc ' --- int(0) --- testing: '123abc ' >> '3.4a' --- -int(15) +int(0) --- testing: '123abc ' >> 'a5.9' --- -int(123) +int(0) --- testing: '3.4a' >> '0' --- -int(3) +int(0) --- testing: '3.4a' >> '65' --- int(0) --- testing: '3.4a' >> '-44' --- Exception: Bit shift by negative number --- testing: '3.4a' >> '1.2' --- -int(1) +int(0) --- testing: '3.4a' >> '-7.7' --- Exception: Bit shift by negative number --- testing: '3.4a' >> 'abc' --- -int(3) +int(0) --- testing: '3.4a' >> '123abc' --- int(0) --- testing: '3.4a' >> '123e5' --- @@ -387,7 +387,7 @@ int(0) --- testing: '3.4a' >> '3.4a' --- int(0) --- testing: '3.4a' >> 'a5.9' --- -int(3) +int(0) --- testing: 'a5.9' >> '0' --- int(0) --- testing: 'a5.9' >> '65' --- diff --git a/tests/lang/operators/divide_variationStr.phpt b/tests/lang/operators/divide_variationStr.phpt index b3a11591eddef..7c0c0ff6be005 100644 --- a/tests/lang/operators/divide_variationStr.phpt +++ b/tests/lang/operators/divide_variationStr.phpt @@ -33,19 +33,19 @@ float(-0) --- testing: '0' / 'abc' --- float(NAN) --- testing: '0' / '123abc' --- -int(0) +float(NAN) --- testing: '0' / '123e5' --- float(0) --- testing: '0' / '123e5xyz' --- -float(0) +float(NAN) --- testing: '0' / ' 123abc' --- -int(0) +float(NAN) --- testing: '0' / '123 abc' --- -int(0) +float(NAN) --- testing: '0' / '123abc ' --- -int(0) +float(NAN) --- testing: '0' / '3.4a' --- -float(0) +float(NAN) --- testing: '0' / 'a5.9' --- float(NAN) --- testing: '65' / '0' --- @@ -61,19 +61,19 @@ float(-8.441558441558442) --- testing: '65' / 'abc' --- float(INF) --- testing: '65' / '123abc' --- -float(0.5284552845528455) +float(INF) --- testing: '65' / '123e5' --- float(5.2845528455284555E-6) --- testing: '65' / '123e5xyz' --- -float(5.2845528455284555E-6) +float(INF) --- testing: '65' / ' 123abc' --- -float(0.5284552845528455) +float(INF) --- testing: '65' / '123 abc' --- -float(0.5284552845528455) +float(INF) --- testing: '65' / '123abc ' --- -float(0.5284552845528455) +float(INF) --- testing: '65' / '3.4a' --- -float(19.11764705882353) +float(INF) --- testing: '65' / 'a5.9' --- float(INF) --- testing: '-44' / '0' --- @@ -89,19 +89,19 @@ float(5.714285714285714) --- testing: '-44' / 'abc' --- float(-INF) --- testing: '-44' / '123abc' --- -float(-0.35772357723577236) +float(-INF) --- testing: '-44' / '123e5' --- float(-3.5772357723577236E-6) --- testing: '-44' / '123e5xyz' --- -float(-3.5772357723577236E-6) +float(-INF) --- testing: '-44' / ' 123abc' --- -float(-0.35772357723577236) +float(-INF) --- testing: '-44' / '123 abc' --- -float(-0.35772357723577236) +float(-INF) --- testing: '-44' / '123abc ' --- -float(-0.35772357723577236) +float(-INF) --- testing: '-44' / '3.4a' --- -float(-12.941176470588236) +float(-INF) --- testing: '-44' / 'a5.9' --- float(-INF) --- testing: '1.2' / '0' --- @@ -117,19 +117,19 @@ float(-0.15584415584415584) --- testing: '1.2' / 'abc' --- float(INF) --- testing: '1.2' / '123abc' --- -float(0.00975609756097561) +float(INF) --- testing: '1.2' / '123e5' --- float(9.75609756097561E-8) --- testing: '1.2' / '123e5xyz' --- -float(9.75609756097561E-8) +float(INF) --- testing: '1.2' / ' 123abc' --- -float(0.00975609756097561) +float(INF) --- testing: '1.2' / '123 abc' --- -float(0.00975609756097561) +float(INF) --- testing: '1.2' / '123abc ' --- -float(0.00975609756097561) +float(INF) --- testing: '1.2' / '3.4a' --- -float(0.35294117647058826) +float(INF) --- testing: '1.2' / 'a5.9' --- float(INF) --- testing: '-7.7' / '0' --- @@ -145,19 +145,19 @@ float(1) --- testing: '-7.7' / 'abc' --- float(-INF) --- testing: '-7.7' / '123abc' --- -float(-0.06260162601626017) +float(-INF) --- testing: '-7.7' / '123e5' --- float(-6.260162601626017E-7) --- testing: '-7.7' / '123e5xyz' --- -float(-6.260162601626017E-7) +float(-INF) --- testing: '-7.7' / ' 123abc' --- -float(-0.06260162601626017) +float(-INF) --- testing: '-7.7' / '123 abc' --- -float(-0.06260162601626017) +float(-INF) --- testing: '-7.7' / '123abc ' --- -float(-0.06260162601626017) +float(-INF) --- testing: '-7.7' / '3.4a' --- -float(-2.264705882352941) +float(-INF) --- testing: '-7.7' / 'a5.9' --- float(-INF) --- testing: 'abc' / '0' --- @@ -173,49 +173,49 @@ float(-0) --- testing: 'abc' / 'abc' --- float(NAN) --- testing: 'abc' / '123abc' --- -int(0) +float(NAN) --- testing: 'abc' / '123e5' --- float(0) --- testing: 'abc' / '123e5xyz' --- -float(0) +float(NAN) --- testing: 'abc' / ' 123abc' --- -int(0) +float(NAN) --- testing: 'abc' / '123 abc' --- -int(0) +float(NAN) --- testing: 'abc' / '123abc ' --- -int(0) +float(NAN) --- testing: 'abc' / '3.4a' --- -float(0) +float(NAN) --- testing: 'abc' / 'a5.9' --- float(NAN) --- testing: '123abc' / '0' --- -float(INF) +float(NAN) --- testing: '123abc' / '65' --- -float(1.8923076923076922) +int(0) --- testing: '123abc' / '-44' --- -float(-2.7954545454545454) +int(0) --- testing: '123abc' / '1.2' --- -float(102.5) +float(0) --- testing: '123abc' / '-7.7' --- -float(-15.974025974025974) +float(-0) --- testing: '123abc' / 'abc' --- -float(INF) +float(NAN) --- testing: '123abc' / '123abc' --- -int(1) +float(NAN) --- testing: '123abc' / '123e5' --- -float(1.0E-5) +float(0) --- testing: '123abc' / '123e5xyz' --- -float(1.0E-5) +float(NAN) --- testing: '123abc' / ' 123abc' --- -int(1) +float(NAN) --- testing: '123abc' / '123 abc' --- -int(1) +float(NAN) --- testing: '123abc' / '123abc ' --- -int(1) +float(NAN) --- testing: '123abc' / '3.4a' --- -float(36.1764705882353) +float(NAN) --- testing: '123abc' / 'a5.9' --- -float(INF) +float(NAN) --- testing: '123e5' / '0' --- float(INF) --- testing: '123e5' / '65' --- @@ -229,161 +229,161 @@ float(-1597402.5974025973) --- testing: '123e5' / 'abc' --- float(INF) --- testing: '123e5' / '123abc' --- -float(100000) +float(INF) --- testing: '123e5' / '123e5' --- float(1) --- testing: '123e5' / '123e5xyz' --- -float(1) +float(INF) --- testing: '123e5' / ' 123abc' --- -float(100000) +float(INF) --- testing: '123e5' / '123 abc' --- -float(100000) +float(INF) --- testing: '123e5' / '123abc ' --- -float(100000) +float(INF) --- testing: '123e5' / '3.4a' --- -float(3617647.0588235296) +float(INF) --- testing: '123e5' / 'a5.9' --- float(INF) --- testing: '123e5xyz' / '0' --- -float(INF) +float(NAN) --- testing: '123e5xyz' / '65' --- -float(189230.76923076922) +int(0) --- testing: '123e5xyz' / '-44' --- -float(-279545.45454545453) +int(0) --- testing: '123e5xyz' / '1.2' --- -float(10250000) +float(0) --- testing: '123e5xyz' / '-7.7' --- -float(-1597402.5974025973) +float(-0) --- testing: '123e5xyz' / 'abc' --- -float(INF) +float(NAN) --- testing: '123e5xyz' / '123abc' --- -float(100000) +float(NAN) --- testing: '123e5xyz' / '123e5' --- -float(1) +float(0) --- testing: '123e5xyz' / '123e5xyz' --- -float(1) +float(NAN) --- testing: '123e5xyz' / ' 123abc' --- -float(100000) +float(NAN) --- testing: '123e5xyz' / '123 abc' --- -float(100000) +float(NAN) --- testing: '123e5xyz' / '123abc ' --- -float(100000) +float(NAN) --- testing: '123e5xyz' / '3.4a' --- -float(3617647.0588235296) +float(NAN) --- testing: '123e5xyz' / 'a5.9' --- -float(INF) +float(NAN) --- testing: ' 123abc' / '0' --- -float(INF) +float(NAN) --- testing: ' 123abc' / '65' --- -float(1.8923076923076922) +int(0) --- testing: ' 123abc' / '-44' --- -float(-2.7954545454545454) +int(0) --- testing: ' 123abc' / '1.2' --- -float(102.5) +float(0) --- testing: ' 123abc' / '-7.7' --- -float(-15.974025974025974) +float(-0) --- testing: ' 123abc' / 'abc' --- -float(INF) +float(NAN) --- testing: ' 123abc' / '123abc' --- -int(1) +float(NAN) --- testing: ' 123abc' / '123e5' --- -float(1.0E-5) +float(0) --- testing: ' 123abc' / '123e5xyz' --- -float(1.0E-5) +float(NAN) --- testing: ' 123abc' / ' 123abc' --- -int(1) +float(NAN) --- testing: ' 123abc' / '123 abc' --- -int(1) +float(NAN) --- testing: ' 123abc' / '123abc ' --- -int(1) +float(NAN) --- testing: ' 123abc' / '3.4a' --- -float(36.1764705882353) +float(NAN) --- testing: ' 123abc' / 'a5.9' --- -float(INF) +float(NAN) --- testing: '123 abc' / '0' --- -float(INF) +float(NAN) --- testing: '123 abc' / '65' --- -float(1.8923076923076922) +int(0) --- testing: '123 abc' / '-44' --- -float(-2.7954545454545454) +int(0) --- testing: '123 abc' / '1.2' --- -float(102.5) +float(0) --- testing: '123 abc' / '-7.7' --- -float(-15.974025974025974) +float(-0) --- testing: '123 abc' / 'abc' --- -float(INF) +float(NAN) --- testing: '123 abc' / '123abc' --- -int(1) +float(NAN) --- testing: '123 abc' / '123e5' --- -float(1.0E-5) +float(0) --- testing: '123 abc' / '123e5xyz' --- -float(1.0E-5) +float(NAN) --- testing: '123 abc' / ' 123abc' --- -int(1) +float(NAN) --- testing: '123 abc' / '123 abc' --- -int(1) +float(NAN) --- testing: '123 abc' / '123abc ' --- -int(1) +float(NAN) --- testing: '123 abc' / '3.4a' --- -float(36.1764705882353) +float(NAN) --- testing: '123 abc' / 'a5.9' --- -float(INF) +float(NAN) --- testing: '123abc ' / '0' --- -float(INF) +float(NAN) --- testing: '123abc ' / '65' --- -float(1.8923076923076922) +int(0) --- testing: '123abc ' / '-44' --- -float(-2.7954545454545454) +int(0) --- testing: '123abc ' / '1.2' --- -float(102.5) +float(0) --- testing: '123abc ' / '-7.7' --- -float(-15.974025974025974) +float(-0) --- testing: '123abc ' / 'abc' --- -float(INF) +float(NAN) --- testing: '123abc ' / '123abc' --- -int(1) +float(NAN) --- testing: '123abc ' / '123e5' --- -float(1.0E-5) +float(0) --- testing: '123abc ' / '123e5xyz' --- -float(1.0E-5) +float(NAN) --- testing: '123abc ' / ' 123abc' --- -int(1) +float(NAN) --- testing: '123abc ' / '123 abc' --- -int(1) +float(NAN) --- testing: '123abc ' / '123abc ' --- -int(1) +float(NAN) --- testing: '123abc ' / '3.4a' --- -float(36.1764705882353) +float(NAN) --- testing: '123abc ' / 'a5.9' --- -float(INF) +float(NAN) --- testing: '3.4a' / '0' --- -float(INF) +float(NAN) --- testing: '3.4a' / '65' --- -float(0.052307692307692305) +int(0) --- testing: '3.4a' / '-44' --- -float(-0.07727272727272727) +int(0) --- testing: '3.4a' / '1.2' --- -float(2.8333333333333335) +float(0) --- testing: '3.4a' / '-7.7' --- -float(-0.44155844155844154) +float(-0) --- testing: '3.4a' / 'abc' --- -float(INF) +float(NAN) --- testing: '3.4a' / '123abc' --- -float(0.027642276422764227) +float(NAN) --- testing: '3.4a' / '123e5' --- -float(2.764227642276423E-7) +float(0) --- testing: '3.4a' / '123e5xyz' --- -float(2.764227642276423E-7) +float(NAN) --- testing: '3.4a' / ' 123abc' --- -float(0.027642276422764227) +float(NAN) --- testing: '3.4a' / '123 abc' --- -float(0.027642276422764227) +float(NAN) --- testing: '3.4a' / '123abc ' --- -float(0.027642276422764227) +float(NAN) --- testing: '3.4a' / '3.4a' --- -float(1) +float(NAN) --- testing: '3.4a' / 'a5.9' --- -float(INF) +float(NAN) --- testing: 'a5.9' / '0' --- float(NAN) --- testing: 'a5.9' / '65' --- @@ -397,18 +397,18 @@ float(-0) --- testing: 'a5.9' / 'abc' --- float(NAN) --- testing: 'a5.9' / '123abc' --- -int(0) +float(NAN) --- testing: 'a5.9' / '123e5' --- float(0) --- testing: 'a5.9' / '123e5xyz' --- -float(0) +float(NAN) --- testing: 'a5.9' / ' 123abc' --- -int(0) +float(NAN) --- testing: 'a5.9' / '123 abc' --- -int(0) +float(NAN) --- testing: 'a5.9' / '123abc ' --- -int(0) +float(NAN) --- testing: 'a5.9' / '3.4a' --- -float(0) +float(NAN) --- testing: 'a5.9' / 'a5.9' --- float(NAN) diff --git a/tests/lang/operators/modulus_variationStr.phpt b/tests/lang/operators/modulus_variationStr.phpt index 8d31c3ec91912..8e43394c9e4ac 100644 --- a/tests/lang/operators/modulus_variationStr.phpt +++ b/tests/lang/operators/modulus_variationStr.phpt @@ -37,19 +37,19 @@ int(0) --- testing: '0' % 'abc' --- Exception: Modulo by zero --- testing: '0' % '123abc' --- -int(0) +Exception: Modulo by zero --- testing: '0' % '123e5' --- int(0) --- testing: '0' % '123e5xyz' --- -int(0) +Exception: Modulo by zero --- testing: '0' % ' 123abc' --- -int(0) +Exception: Modulo by zero --- testing: '0' % '123 abc' --- -int(0) +Exception: Modulo by zero --- testing: '0' % '123abc ' --- -int(0) +Exception: Modulo by zero --- testing: '0' % '3.4a' --- -int(0) +Exception: Modulo by zero --- testing: '0' % 'a5.9' --- Exception: Modulo by zero --- testing: '65' % '0' --- @@ -65,19 +65,19 @@ int(2) --- testing: '65' % 'abc' --- Exception: Modulo by zero --- testing: '65' % '123abc' --- -int(65) +Exception: Modulo by zero --- testing: '65' % '123e5' --- int(65) --- testing: '65' % '123e5xyz' --- -int(65) +Exception: Modulo by zero --- testing: '65' % ' 123abc' --- -int(65) +Exception: Modulo by zero --- testing: '65' % '123 abc' --- -int(65) +Exception: Modulo by zero --- testing: '65' % '123abc ' --- -int(65) +Exception: Modulo by zero --- testing: '65' % '3.4a' --- -int(2) +Exception: Modulo by zero --- testing: '65' % 'a5.9' --- Exception: Modulo by zero --- testing: '-44' % '0' --- @@ -93,19 +93,19 @@ int(-2) --- testing: '-44' % 'abc' --- Exception: Modulo by zero --- testing: '-44' % '123abc' --- -int(-44) +Exception: Modulo by zero --- testing: '-44' % '123e5' --- int(-44) --- testing: '-44' % '123e5xyz' --- -int(-44) +Exception: Modulo by zero --- testing: '-44' % ' 123abc' --- -int(-44) +Exception: Modulo by zero --- testing: '-44' % '123 abc' --- -int(-44) +Exception: Modulo by zero --- testing: '-44' % '123abc ' --- -int(-44) +Exception: Modulo by zero --- testing: '-44' % '3.4a' --- -int(-2) +Exception: Modulo by zero --- testing: '-44' % 'a5.9' --- Exception: Modulo by zero --- testing: '1.2' % '0' --- @@ -121,19 +121,19 @@ int(1) --- testing: '1.2' % 'abc' --- Exception: Modulo by zero --- testing: '1.2' % '123abc' --- -int(1) +Exception: Modulo by zero --- testing: '1.2' % '123e5' --- int(1) --- testing: '1.2' % '123e5xyz' --- -int(1) +Exception: Modulo by zero --- testing: '1.2' % ' 123abc' --- -int(1) +Exception: Modulo by zero --- testing: '1.2' % '123 abc' --- -int(1) +Exception: Modulo by zero --- testing: '1.2' % '123abc ' --- -int(1) +Exception: Modulo by zero --- testing: '1.2' % '3.4a' --- -int(1) +Exception: Modulo by zero --- testing: '1.2' % 'a5.9' --- Exception: Modulo by zero --- testing: '-7.7' % '0' --- @@ -149,19 +149,19 @@ int(0) --- testing: '-7.7' % 'abc' --- Exception: Modulo by zero --- testing: '-7.7' % '123abc' --- -int(-7) +Exception: Modulo by zero --- testing: '-7.7' % '123e5' --- int(-7) --- testing: '-7.7' % '123e5xyz' --- -int(-7) +Exception: Modulo by zero --- testing: '-7.7' % ' 123abc' --- -int(-7) +Exception: Modulo by zero --- testing: '-7.7' % '123 abc' --- -int(-7) +Exception: Modulo by zero --- testing: '-7.7' % '123abc ' --- -int(-7) +Exception: Modulo by zero --- testing: '-7.7' % '3.4a' --- -int(-1) +Exception: Modulo by zero --- testing: '-7.7' % 'a5.9' --- Exception: Modulo by zero --- testing: 'abc' % '0' --- @@ -177,47 +177,47 @@ int(0) --- testing: 'abc' % 'abc' --- Exception: Modulo by zero --- testing: 'abc' % '123abc' --- -int(0) +Exception: Modulo by zero --- testing: 'abc' % '123e5' --- int(0) --- testing: 'abc' % '123e5xyz' --- -int(0) +Exception: Modulo by zero --- testing: 'abc' % ' 123abc' --- -int(0) +Exception: Modulo by zero --- testing: 'abc' % '123 abc' --- -int(0) +Exception: Modulo by zero --- testing: 'abc' % '123abc ' --- -int(0) +Exception: Modulo by zero --- testing: 'abc' % '3.4a' --- -int(0) +Exception: Modulo by zero --- testing: 'abc' % 'a5.9' --- Exception: Modulo by zero --- testing: '123abc' % '0' --- Exception: Modulo by zero --- testing: '123abc' % '65' --- -int(58) +int(0) --- testing: '123abc' % '-44' --- -int(35) +int(0) --- testing: '123abc' % '1.2' --- int(0) --- testing: '123abc' % '-7.7' --- -int(4) +int(0) --- testing: '123abc' % 'abc' --- Exception: Modulo by zero --- testing: '123abc' % '123abc' --- -int(0) +Exception: Modulo by zero --- testing: '123abc' % '123e5' --- -int(123) +int(0) --- testing: '123abc' % '123e5xyz' --- -int(123) +Exception: Modulo by zero --- testing: '123abc' % ' 123abc' --- -int(0) +Exception: Modulo by zero --- testing: '123abc' % '123 abc' --- -int(0) +Exception: Modulo by zero --- testing: '123abc' % '123abc ' --- -int(0) +Exception: Modulo by zero --- testing: '123abc' % '3.4a' --- -int(0) +Exception: Modulo by zero --- testing: '123abc' % 'a5.9' --- Exception: Modulo by zero --- testing: '123e5' % '0' --- @@ -233,159 +233,159 @@ int(6) --- testing: '123e5' % 'abc' --- Exception: Modulo by zero --- testing: '123e5' % '123abc' --- -int(0) +Exception: Modulo by zero --- testing: '123e5' % '123e5' --- int(0) --- testing: '123e5' % '123e5xyz' --- -int(0) +Exception: Modulo by zero --- testing: '123e5' % ' 123abc' --- -int(0) +Exception: Modulo by zero --- testing: '123e5' % '123 abc' --- -int(0) +Exception: Modulo by zero --- testing: '123e5' % '123abc ' --- -int(0) +Exception: Modulo by zero --- testing: '123e5' % '3.4a' --- -int(0) +Exception: Modulo by zero --- testing: '123e5' % 'a5.9' --- Exception: Modulo by zero --- testing: '123e5xyz' % '0' --- Exception: Modulo by zero --- testing: '123e5xyz' % '65' --- -int(50) +int(0) --- testing: '123e5xyz' % '-44' --- -int(20) +int(0) --- testing: '123e5xyz' % '1.2' --- int(0) --- testing: '123e5xyz' % '-7.7' --- -int(6) +int(0) --- testing: '123e5xyz' % 'abc' --- Exception: Modulo by zero --- testing: '123e5xyz' % '123abc' --- -int(0) +Exception: Modulo by zero --- testing: '123e5xyz' % '123e5' --- int(0) --- testing: '123e5xyz' % '123e5xyz' --- -int(0) +Exception: Modulo by zero --- testing: '123e5xyz' % ' 123abc' --- -int(0) +Exception: Modulo by zero --- testing: '123e5xyz' % '123 abc' --- -int(0) +Exception: Modulo by zero --- testing: '123e5xyz' % '123abc ' --- -int(0) +Exception: Modulo by zero --- testing: '123e5xyz' % '3.4a' --- -int(0) +Exception: Modulo by zero --- testing: '123e5xyz' % 'a5.9' --- Exception: Modulo by zero --- testing: ' 123abc' % '0' --- Exception: Modulo by zero --- testing: ' 123abc' % '65' --- -int(58) +int(0) --- testing: ' 123abc' % '-44' --- -int(35) +int(0) --- testing: ' 123abc' % '1.2' --- int(0) --- testing: ' 123abc' % '-7.7' --- -int(4) +int(0) --- testing: ' 123abc' % 'abc' --- Exception: Modulo by zero --- testing: ' 123abc' % '123abc' --- -int(0) +Exception: Modulo by zero --- testing: ' 123abc' % '123e5' --- -int(123) +int(0) --- testing: ' 123abc' % '123e5xyz' --- -int(123) +Exception: Modulo by zero --- testing: ' 123abc' % ' 123abc' --- -int(0) +Exception: Modulo by zero --- testing: ' 123abc' % '123 abc' --- -int(0) +Exception: Modulo by zero --- testing: ' 123abc' % '123abc ' --- -int(0) +Exception: Modulo by zero --- testing: ' 123abc' % '3.4a' --- -int(0) +Exception: Modulo by zero --- testing: ' 123abc' % 'a5.9' --- Exception: Modulo by zero --- testing: '123 abc' % '0' --- Exception: Modulo by zero --- testing: '123 abc' % '65' --- -int(58) +int(0) --- testing: '123 abc' % '-44' --- -int(35) +int(0) --- testing: '123 abc' % '1.2' --- int(0) --- testing: '123 abc' % '-7.7' --- -int(4) +int(0) --- testing: '123 abc' % 'abc' --- Exception: Modulo by zero --- testing: '123 abc' % '123abc' --- -int(0) +Exception: Modulo by zero --- testing: '123 abc' % '123e5' --- -int(123) +int(0) --- testing: '123 abc' % '123e5xyz' --- -int(123) +Exception: Modulo by zero --- testing: '123 abc' % ' 123abc' --- -int(0) +Exception: Modulo by zero --- testing: '123 abc' % '123 abc' --- -int(0) +Exception: Modulo by zero --- testing: '123 abc' % '123abc ' --- -int(0) +Exception: Modulo by zero --- testing: '123 abc' % '3.4a' --- -int(0) +Exception: Modulo by zero --- testing: '123 abc' % 'a5.9' --- Exception: Modulo by zero --- testing: '123abc ' % '0' --- Exception: Modulo by zero --- testing: '123abc ' % '65' --- -int(58) +int(0) --- testing: '123abc ' % '-44' --- -int(35) +int(0) --- testing: '123abc ' % '1.2' --- int(0) --- testing: '123abc ' % '-7.7' --- -int(4) +int(0) --- testing: '123abc ' % 'abc' --- Exception: Modulo by zero --- testing: '123abc ' % '123abc' --- -int(0) +Exception: Modulo by zero --- testing: '123abc ' % '123e5' --- -int(123) +int(0) --- testing: '123abc ' % '123e5xyz' --- -int(123) +Exception: Modulo by zero --- testing: '123abc ' % ' 123abc' --- -int(0) +Exception: Modulo by zero --- testing: '123abc ' % '123 abc' --- -int(0) +Exception: Modulo by zero --- testing: '123abc ' % '123abc ' --- -int(0) +Exception: Modulo by zero --- testing: '123abc ' % '3.4a' --- -int(0) +Exception: Modulo by zero --- testing: '123abc ' % 'a5.9' --- Exception: Modulo by zero --- testing: '3.4a' % '0' --- Exception: Modulo by zero --- testing: '3.4a' % '65' --- -int(3) +int(0) --- testing: '3.4a' % '-44' --- -int(3) +int(0) --- testing: '3.4a' % '1.2' --- int(0) --- testing: '3.4a' % '-7.7' --- -int(3) +int(0) --- testing: '3.4a' % 'abc' --- Exception: Modulo by zero --- testing: '3.4a' % '123abc' --- -int(3) +Exception: Modulo by zero --- testing: '3.4a' % '123e5' --- -int(3) +int(0) --- testing: '3.4a' % '123e5xyz' --- -int(3) +Exception: Modulo by zero --- testing: '3.4a' % ' 123abc' --- -int(3) +Exception: Modulo by zero --- testing: '3.4a' % '123 abc' --- -int(3) +Exception: Modulo by zero --- testing: '3.4a' % '123abc ' --- -int(3) +Exception: Modulo by zero --- testing: '3.4a' % '3.4a' --- -int(0) +Exception: Modulo by zero --- testing: '3.4a' % 'a5.9' --- Exception: Modulo by zero --- testing: 'a5.9' % '0' --- @@ -401,18 +401,18 @@ int(0) --- testing: 'a5.9' % 'abc' --- Exception: Modulo by zero --- testing: 'a5.9' % '123abc' --- -int(0) +Exception: Modulo by zero --- testing: 'a5.9' % '123e5' --- int(0) --- testing: 'a5.9' % '123e5xyz' --- -int(0) +Exception: Modulo by zero --- testing: 'a5.9' % ' 123abc' --- -int(0) +Exception: Modulo by zero --- testing: 'a5.9' % '123 abc' --- -int(0) +Exception: Modulo by zero --- testing: 'a5.9' % '123abc ' --- -int(0) +Exception: Modulo by zero --- testing: 'a5.9' % '3.4a' --- -int(0) +Exception: Modulo by zero --- testing: 'a5.9' % 'a5.9' --- Exception: Modulo by zero diff --git a/tests/lang/operators/multiply_variationStr.phpt b/tests/lang/operators/multiply_variationStr.phpt index a9f73c6bda5df..68d71a48683ba 100644 --- a/tests/lang/operators/multiply_variationStr.phpt +++ b/tests/lang/operators/multiply_variationStr.phpt @@ -37,7 +37,7 @@ int(0) --- testing: '0' * '123e5' --- float(0) --- testing: '0' * '123e5xyz' --- -float(0) +int(0) --- testing: '0' * ' 123abc' --- int(0) --- testing: '0' * '123 abc' --- @@ -45,7 +45,7 @@ int(0) --- testing: '0' * '123abc ' --- int(0) --- testing: '0' * '3.4a' --- -float(0) +int(0) --- testing: '0' * 'a5.9' --- int(0) --- testing: '65' * '0' --- @@ -61,19 +61,19 @@ float(-500.5) --- testing: '65' * 'abc' --- int(0) --- testing: '65' * '123abc' --- -int(7995) +int(0) --- testing: '65' * '123e5' --- float(799500000) --- testing: '65' * '123e5xyz' --- -float(799500000) +int(0) --- testing: '65' * ' 123abc' --- -int(7995) +int(0) --- testing: '65' * '123 abc' --- -int(7995) +int(0) --- testing: '65' * '123abc ' --- -int(7995) +int(0) --- testing: '65' * '3.4a' --- -float(221) +int(0) --- testing: '65' * 'a5.9' --- int(0) --- testing: '-44' * '0' --- @@ -89,19 +89,19 @@ float(338.8) --- testing: '-44' * 'abc' --- int(0) --- testing: '-44' * '123abc' --- -int(-5412) +int(0) --- testing: '-44' * '123e5' --- float(-541200000) --- testing: '-44' * '123e5xyz' --- -float(-541200000) +int(0) --- testing: '-44' * ' 123abc' --- -int(-5412) +int(0) --- testing: '-44' * '123 abc' --- -int(-5412) +int(0) --- testing: '-44' * '123abc ' --- -int(-5412) +int(0) --- testing: '-44' * '3.4a' --- -float(-149.6) +int(0) --- testing: '-44' * 'a5.9' --- int(0) --- testing: '1.2' * '0' --- @@ -117,19 +117,19 @@ float(-9.24) --- testing: '1.2' * 'abc' --- float(0) --- testing: '1.2' * '123abc' --- -float(147.6) +float(0) --- testing: '1.2' * '123e5' --- float(14760000) --- testing: '1.2' * '123e5xyz' --- -float(14760000) +float(0) --- testing: '1.2' * ' 123abc' --- -float(147.6) +float(0) --- testing: '1.2' * '123 abc' --- -float(147.6) +float(0) --- testing: '1.2' * '123abc ' --- -float(147.6) +float(0) --- testing: '1.2' * '3.4a' --- -float(4.08) +float(0) --- testing: '1.2' * 'a5.9' --- float(0) --- testing: '-7.7' * '0' --- @@ -145,19 +145,19 @@ float(59.290000000000006) --- testing: '-7.7' * 'abc' --- float(-0) --- testing: '-7.7' * '123abc' --- -float(-947.1) +float(-0) --- testing: '-7.7' * '123e5' --- float(-94710000) --- testing: '-7.7' * '123e5xyz' --- -float(-94710000) +float(-0) --- testing: '-7.7' * ' 123abc' --- -float(-947.1) +float(-0) --- testing: '-7.7' * '123 abc' --- -float(-947.1) +float(-0) --- testing: '-7.7' * '123abc ' --- -float(-947.1) +float(-0) --- testing: '-7.7' * '3.4a' --- -float(-26.18) +float(-0) --- testing: '-7.7' * 'a5.9' --- float(-0) --- testing: 'abc' * '0' --- @@ -177,7 +177,7 @@ int(0) --- testing: 'abc' * '123e5' --- float(0) --- testing: 'abc' * '123e5xyz' --- -float(0) +int(0) --- testing: 'abc' * ' 123abc' --- int(0) --- testing: 'abc' * '123 abc' --- @@ -185,35 +185,35 @@ int(0) --- testing: 'abc' * '123abc ' --- int(0) --- testing: 'abc' * '3.4a' --- -float(0) +int(0) --- testing: 'abc' * 'a5.9' --- int(0) --- testing: '123abc' * '0' --- int(0) --- testing: '123abc' * '65' --- -int(7995) +int(0) --- testing: '123abc' * '-44' --- -int(-5412) +int(0) --- testing: '123abc' * '1.2' --- -float(147.6) +float(0) --- testing: '123abc' * '-7.7' --- -float(-947.1) +float(-0) --- testing: '123abc' * 'abc' --- int(0) --- testing: '123abc' * '123abc' --- -int(15129) +int(0) --- testing: '123abc' * '123e5' --- -float(1512900000) +float(0) --- testing: '123abc' * '123e5xyz' --- -float(1512900000) +int(0) --- testing: '123abc' * ' 123abc' --- -int(15129) +int(0) --- testing: '123abc' * '123 abc' --- -int(15129) +int(0) --- testing: '123abc' * '123abc ' --- -int(15129) +int(0) --- testing: '123abc' * '3.4a' --- -float(418.2) +int(0) --- testing: '123abc' * 'a5.9' --- int(0) --- testing: '123e5' * '0' --- @@ -229,161 +229,161 @@ float(-94710000) --- testing: '123e5' * 'abc' --- float(0) --- testing: '123e5' * '123abc' --- -float(1512900000) +float(0) --- testing: '123e5' * '123e5' --- float(151290000000000) --- testing: '123e5' * '123e5xyz' --- -float(151290000000000) +float(0) --- testing: '123e5' * ' 123abc' --- -float(1512900000) +float(0) --- testing: '123e5' * '123 abc' --- -float(1512900000) +float(0) --- testing: '123e5' * '123abc ' --- -float(1512900000) +float(0) --- testing: '123e5' * '3.4a' --- -float(41820000) +float(0) --- testing: '123e5' * 'a5.9' --- float(0) --- testing: '123e5xyz' * '0' --- -float(0) +int(0) --- testing: '123e5xyz' * '65' --- -float(799500000) +int(0) --- testing: '123e5xyz' * '-44' --- -float(-541200000) +int(0) --- testing: '123e5xyz' * '1.2' --- -float(14760000) +float(0) --- testing: '123e5xyz' * '-7.7' --- -float(-94710000) +float(-0) --- testing: '123e5xyz' * 'abc' --- -float(0) +int(0) --- testing: '123e5xyz' * '123abc' --- -float(1512900000) +int(0) --- testing: '123e5xyz' * '123e5' --- -float(151290000000000) +float(0) --- testing: '123e5xyz' * '123e5xyz' --- -float(151290000000000) +int(0) --- testing: '123e5xyz' * ' 123abc' --- -float(1512900000) +int(0) --- testing: '123e5xyz' * '123 abc' --- -float(1512900000) +int(0) --- testing: '123e5xyz' * '123abc ' --- -float(1512900000) +int(0) --- testing: '123e5xyz' * '3.4a' --- -float(41820000) +int(0) --- testing: '123e5xyz' * 'a5.9' --- -float(0) +int(0) --- testing: ' 123abc' * '0' --- int(0) --- testing: ' 123abc' * '65' --- -int(7995) +int(0) --- testing: ' 123abc' * '-44' --- -int(-5412) +int(0) --- testing: ' 123abc' * '1.2' --- -float(147.6) +float(0) --- testing: ' 123abc' * '-7.7' --- -float(-947.1) +float(-0) --- testing: ' 123abc' * 'abc' --- int(0) --- testing: ' 123abc' * '123abc' --- -int(15129) +int(0) --- testing: ' 123abc' * '123e5' --- -float(1512900000) +float(0) --- testing: ' 123abc' * '123e5xyz' --- -float(1512900000) +int(0) --- testing: ' 123abc' * ' 123abc' --- -int(15129) +int(0) --- testing: ' 123abc' * '123 abc' --- -int(15129) +int(0) --- testing: ' 123abc' * '123abc ' --- -int(15129) +int(0) --- testing: ' 123abc' * '3.4a' --- -float(418.2) +int(0) --- testing: ' 123abc' * 'a5.9' --- int(0) --- testing: '123 abc' * '0' --- int(0) --- testing: '123 abc' * '65' --- -int(7995) +int(0) --- testing: '123 abc' * '-44' --- -int(-5412) +int(0) --- testing: '123 abc' * '1.2' --- -float(147.6) +float(0) --- testing: '123 abc' * '-7.7' --- -float(-947.1) +float(-0) --- testing: '123 abc' * 'abc' --- int(0) --- testing: '123 abc' * '123abc' --- -int(15129) +int(0) --- testing: '123 abc' * '123e5' --- -float(1512900000) +float(0) --- testing: '123 abc' * '123e5xyz' --- -float(1512900000) +int(0) --- testing: '123 abc' * ' 123abc' --- -int(15129) +int(0) --- testing: '123 abc' * '123 abc' --- -int(15129) +int(0) --- testing: '123 abc' * '123abc ' --- -int(15129) +int(0) --- testing: '123 abc' * '3.4a' --- -float(418.2) +int(0) --- testing: '123 abc' * 'a5.9' --- int(0) --- testing: '123abc ' * '0' --- int(0) --- testing: '123abc ' * '65' --- -int(7995) +int(0) --- testing: '123abc ' * '-44' --- -int(-5412) +int(0) --- testing: '123abc ' * '1.2' --- -float(147.6) +float(0) --- testing: '123abc ' * '-7.7' --- -float(-947.1) +float(-0) --- testing: '123abc ' * 'abc' --- int(0) --- testing: '123abc ' * '123abc' --- -int(15129) +int(0) --- testing: '123abc ' * '123e5' --- -float(1512900000) +float(0) --- testing: '123abc ' * '123e5xyz' --- -float(1512900000) +int(0) --- testing: '123abc ' * ' 123abc' --- -int(15129) +int(0) --- testing: '123abc ' * '123 abc' --- -int(15129) +int(0) --- testing: '123abc ' * '123abc ' --- -int(15129) +int(0) --- testing: '123abc ' * '3.4a' --- -float(418.2) +int(0) --- testing: '123abc ' * 'a5.9' --- int(0) --- testing: '3.4a' * '0' --- -float(0) +int(0) --- testing: '3.4a' * '65' --- -float(221) +int(0) --- testing: '3.4a' * '-44' --- -float(-149.6) +int(0) --- testing: '3.4a' * '1.2' --- -float(4.08) +float(0) --- testing: '3.4a' * '-7.7' --- -float(-26.18) +float(-0) --- testing: '3.4a' * 'abc' --- -float(0) +int(0) --- testing: '3.4a' * '123abc' --- -float(418.2) +int(0) --- testing: '3.4a' * '123e5' --- -float(41820000) +float(0) --- testing: '3.4a' * '123e5xyz' --- -float(41820000) +int(0) --- testing: '3.4a' * ' 123abc' --- -float(418.2) +int(0) --- testing: '3.4a' * '123 abc' --- -float(418.2) +int(0) --- testing: '3.4a' * '123abc ' --- -float(418.2) +int(0) --- testing: '3.4a' * '3.4a' --- -float(11.559999999999999) +int(0) --- testing: '3.4a' * 'a5.9' --- -float(0) +int(0) --- testing: 'a5.9' * '0' --- int(0) --- testing: 'a5.9' * '65' --- @@ -401,7 +401,7 @@ int(0) --- testing: 'a5.9' * '123e5' --- float(0) --- testing: 'a5.9' * '123e5xyz' --- -float(0) +int(0) --- testing: 'a5.9' * ' 123abc' --- int(0) --- testing: 'a5.9' * '123 abc' --- @@ -409,6 +409,6 @@ int(0) --- testing: 'a5.9' * '123abc ' --- int(0) --- testing: 'a5.9' * '3.4a' --- -float(0) +int(0) --- testing: 'a5.9' * 'a5.9' --- int(0) diff --git a/tests/lang/operators/negate_variationStr.phpt b/tests/lang/operators/negate_variationStr.phpt index 3b70349026c02..1aded5702c297 100644 --- a/tests/lang/operators/negate_variationStr.phpt +++ b/tests/lang/operators/negate_variationStr.phpt @@ -32,30 +32,30 @@ Warning: A non-numeric value encountered in %s on line %d int(0) --- testing: '123abc' --- -Notice: A non well formed numeric value encountered in %s on line %d -int(-123) +Warning: A non-numeric value encountered in %s on line %d +int(0) --- testing: '123e5' --- float(-12300000) --- testing: '123e5xyz' --- -Notice: A non well formed numeric value encountered in %s on line %d -float(-12300000) +Warning: A non-numeric value encountered in %s on line %d +int(0) --- testing: ' 123abc' --- -Notice: A non well formed numeric value encountered in %s on line %d -int(-123) +Warning: A non-numeric value encountered in %s on line %d +int(0) --- testing: '123 abc' --- -Notice: A non well formed numeric value encountered in %s on line %d -int(-123) +Warning: A non-numeric value encountered in %s on line %d +int(0) --- testing: '123abc ' --- -Notice: A non well formed numeric value encountered in %s on line %d -int(-123) +Warning: A non-numeric value encountered in %s on line %d +int(0) --- testing: '3.4a' --- -Notice: A non well formed numeric value encountered in %s on line %d -float(-3.4) +Warning: A non-numeric value encountered in %s on line %d +int(0) --- testing: 'a5.9' --- Warning: A non-numeric value encountered in %s on line %d diff --git a/tests/lang/operators/subtract_variationStr.phpt b/tests/lang/operators/subtract_variationStr.phpt index 2c4667c114122..a6e35a4698176 100644 --- a/tests/lang/operators/subtract_variationStr.phpt +++ b/tests/lang/operators/subtract_variationStr.phpt @@ -33,19 +33,19 @@ float(7.7) --- testing: '0' - 'abc' --- int(0) --- testing: '0' - '123abc' --- -int(-123) +int(0) --- testing: '0' - '123e5' --- float(-12300000) --- testing: '0' - '123e5xyz' --- -float(-12300000) +int(0) --- testing: '0' - ' 123abc' --- -int(-123) +int(0) --- testing: '0' - '123 abc' --- -int(-123) +int(0) --- testing: '0' - '123abc ' --- -int(-123) +int(0) --- testing: '0' - '3.4a' --- -float(-3.4) +int(0) --- testing: '0' - 'a5.9' --- int(0) --- testing: '65' - '0' --- @@ -61,19 +61,19 @@ float(72.7) --- testing: '65' - 'abc' --- int(65) --- testing: '65' - '123abc' --- -int(-58) +int(65) --- testing: '65' - '123e5' --- float(-12299935) --- testing: '65' - '123e5xyz' --- -float(-12299935) +int(65) --- testing: '65' - ' 123abc' --- -int(-58) +int(65) --- testing: '65' - '123 abc' --- -int(-58) +int(65) --- testing: '65' - '123abc ' --- -int(-58) +int(65) --- testing: '65' - '3.4a' --- -float(61.6) +int(65) --- testing: '65' - 'a5.9' --- int(65) --- testing: '-44' - '0' --- @@ -89,19 +89,19 @@ float(-36.3) --- testing: '-44' - 'abc' --- int(-44) --- testing: '-44' - '123abc' --- -int(-167) +int(-44) --- testing: '-44' - '123e5' --- float(-12300044) --- testing: '-44' - '123e5xyz' --- -float(-12300044) +int(-44) --- testing: '-44' - ' 123abc' --- -int(-167) +int(-44) --- testing: '-44' - '123 abc' --- -int(-167) +int(-44) --- testing: '-44' - '123abc ' --- -int(-167) +int(-44) --- testing: '-44' - '3.4a' --- -float(-47.4) +int(-44) --- testing: '-44' - 'a5.9' --- int(-44) --- testing: '1.2' - '0' --- @@ -117,19 +117,19 @@ float(8.9) --- testing: '1.2' - 'abc' --- float(1.2) --- testing: '1.2' - '123abc' --- -float(-121.8) +float(1.2) --- testing: '1.2' - '123e5' --- float(-12299998.8) --- testing: '1.2' - '123e5xyz' --- -float(-12299998.8) +float(1.2) --- testing: '1.2' - ' 123abc' --- -float(-121.8) +float(1.2) --- testing: '1.2' - '123 abc' --- -float(-121.8) +float(1.2) --- testing: '1.2' - '123abc ' --- -float(-121.8) +float(1.2) --- testing: '1.2' - '3.4a' --- -float(-2.2) +float(1.2) --- testing: '1.2' - 'a5.9' --- float(1.2) --- testing: '-7.7' - '0' --- @@ -145,19 +145,19 @@ float(0) --- testing: '-7.7' - 'abc' --- float(-7.7) --- testing: '-7.7' - '123abc' --- -float(-130.7) +float(-7.7) --- testing: '-7.7' - '123e5' --- float(-12300007.7) --- testing: '-7.7' - '123e5xyz' --- -float(-12300007.7) +float(-7.7) --- testing: '-7.7' - ' 123abc' --- -float(-130.7) +float(-7.7) --- testing: '-7.7' - '123 abc' --- -float(-130.7) +float(-7.7) --- testing: '-7.7' - '123abc ' --- -float(-130.7) +float(-7.7) --- testing: '-7.7' - '3.4a' --- -float(-11.1) +float(-7.7) --- testing: '-7.7' - 'a5.9' --- float(-7.7) --- testing: 'abc' - '0' --- @@ -173,39 +173,39 @@ float(7.7) --- testing: 'abc' - 'abc' --- int(0) --- testing: 'abc' - '123abc' --- -int(-123) +int(0) --- testing: 'abc' - '123e5' --- float(-12300000) --- testing: 'abc' - '123e5xyz' --- -float(-12300000) +int(0) --- testing: 'abc' - ' 123abc' --- -int(-123) +int(0) --- testing: 'abc' - '123 abc' --- -int(-123) +int(0) --- testing: 'abc' - '123abc ' --- -int(-123) +int(0) --- testing: 'abc' - '3.4a' --- -float(-3.4) +int(0) --- testing: 'abc' - 'a5.9' --- int(0) --- testing: '123abc' - '0' --- -int(123) +int(0) --- testing: '123abc' - '65' --- -int(58) +int(-65) --- testing: '123abc' - '-44' --- -int(167) +int(44) --- testing: '123abc' - '1.2' --- -float(121.8) +float(-1.2) --- testing: '123abc' - '-7.7' --- -float(130.7) +float(7.7) --- testing: '123abc' - 'abc' --- -int(123) +int(0) --- testing: '123abc' - '123abc' --- int(0) --- testing: '123abc' - '123e5' --- -float(-12299877) +float(-12300000) --- testing: '123abc' - '123e5xyz' --- -float(-12299877) +int(0) --- testing: '123abc' - ' 123abc' --- int(0) --- testing: '123abc' - '123 abc' --- @@ -213,9 +213,9 @@ int(0) --- testing: '123abc' - '123abc ' --- int(0) --- testing: '123abc' - '3.4a' --- -float(119.6) +int(0) --- testing: '123abc' - 'a5.9' --- -int(123) +int(0) --- testing: '123e5' - '0' --- float(12300000) --- testing: '123e5' - '65' --- @@ -229,67 +229,67 @@ float(12300007.7) --- testing: '123e5' - 'abc' --- float(12300000) --- testing: '123e5' - '123abc' --- -float(12299877) +float(12300000) --- testing: '123e5' - '123e5' --- float(0) --- testing: '123e5' - '123e5xyz' --- -float(0) +float(12300000) --- testing: '123e5' - ' 123abc' --- -float(12299877) +float(12300000) --- testing: '123e5' - '123 abc' --- -float(12299877) +float(12300000) --- testing: '123e5' - '123abc ' --- -float(12299877) +float(12300000) --- testing: '123e5' - '3.4a' --- -float(12299996.6) +float(12300000) --- testing: '123e5' - 'a5.9' --- float(12300000) --- testing: '123e5xyz' - '0' --- -float(12300000) +int(0) --- testing: '123e5xyz' - '65' --- -float(12299935) +int(-65) --- testing: '123e5xyz' - '-44' --- -float(12300044) +int(44) --- testing: '123e5xyz' - '1.2' --- -float(12299998.8) +float(-1.2) --- testing: '123e5xyz' - '-7.7' --- -float(12300007.7) +float(7.7) --- testing: '123e5xyz' - 'abc' --- -float(12300000) +int(0) --- testing: '123e5xyz' - '123abc' --- -float(12299877) +int(0) --- testing: '123e5xyz' - '123e5' --- -float(0) +float(-12300000) --- testing: '123e5xyz' - '123e5xyz' --- -float(0) +int(0) --- testing: '123e5xyz' - ' 123abc' --- -float(12299877) +int(0) --- testing: '123e5xyz' - '123 abc' --- -float(12299877) +int(0) --- testing: '123e5xyz' - '123abc ' --- -float(12299877) +int(0) --- testing: '123e5xyz' - '3.4a' --- -float(12299996.6) +int(0) --- testing: '123e5xyz' - 'a5.9' --- -float(12300000) +int(0) --- testing: ' 123abc' - '0' --- -int(123) +int(0) --- testing: ' 123abc' - '65' --- -int(58) +int(-65) --- testing: ' 123abc' - '-44' --- -int(167) +int(44) --- testing: ' 123abc' - '1.2' --- -float(121.8) +float(-1.2) --- testing: ' 123abc' - '-7.7' --- -float(130.7) +float(7.7) --- testing: ' 123abc' - 'abc' --- -int(123) +int(0) --- testing: ' 123abc' - '123abc' --- int(0) --- testing: ' 123abc' - '123e5' --- -float(-12299877) +float(-12300000) --- testing: ' 123abc' - '123e5xyz' --- -float(-12299877) +int(0) --- testing: ' 123abc' - ' 123abc' --- int(0) --- testing: ' 123abc' - '123 abc' --- @@ -297,27 +297,27 @@ int(0) --- testing: ' 123abc' - '123abc ' --- int(0) --- testing: ' 123abc' - '3.4a' --- -float(119.6) +int(0) --- testing: ' 123abc' - 'a5.9' --- -int(123) +int(0) --- testing: '123 abc' - '0' --- -int(123) +int(0) --- testing: '123 abc' - '65' --- -int(58) +int(-65) --- testing: '123 abc' - '-44' --- -int(167) +int(44) --- testing: '123 abc' - '1.2' --- -float(121.8) +float(-1.2) --- testing: '123 abc' - '-7.7' --- -float(130.7) +float(7.7) --- testing: '123 abc' - 'abc' --- -int(123) +int(0) --- testing: '123 abc' - '123abc' --- int(0) --- testing: '123 abc' - '123e5' --- -float(-12299877) +float(-12300000) --- testing: '123 abc' - '123e5xyz' --- -float(-12299877) +int(0) --- testing: '123 abc' - ' 123abc' --- int(0) --- testing: '123 abc' - '123 abc' --- @@ -325,27 +325,27 @@ int(0) --- testing: '123 abc' - '123abc ' --- int(0) --- testing: '123 abc' - '3.4a' --- -float(119.6) +int(0) --- testing: '123 abc' - 'a5.9' --- -int(123) +int(0) --- testing: '123abc ' - '0' --- -int(123) +int(0) --- testing: '123abc ' - '65' --- -int(58) +int(-65) --- testing: '123abc ' - '-44' --- -int(167) +int(44) --- testing: '123abc ' - '1.2' --- -float(121.8) +float(-1.2) --- testing: '123abc ' - '-7.7' --- -float(130.7) +float(7.7) --- testing: '123abc ' - 'abc' --- -int(123) +int(0) --- testing: '123abc ' - '123abc' --- int(0) --- testing: '123abc ' - '123e5' --- -float(-12299877) +float(-12300000) --- testing: '123abc ' - '123e5xyz' --- -float(-12299877) +int(0) --- testing: '123abc ' - ' 123abc' --- int(0) --- testing: '123abc ' - '123 abc' --- @@ -353,37 +353,37 @@ int(0) --- testing: '123abc ' - '123abc ' --- int(0) --- testing: '123abc ' - '3.4a' --- -float(119.6) +int(0) --- testing: '123abc ' - 'a5.9' --- -int(123) +int(0) --- testing: '3.4a' - '0' --- -float(3.4) +int(0) --- testing: '3.4a' - '65' --- -float(-61.6) +int(-65) --- testing: '3.4a' - '-44' --- -float(47.4) +int(44) --- testing: '3.4a' - '1.2' --- -float(2.2) +float(-1.2) --- testing: '3.4a' - '-7.7' --- -float(11.1) +float(7.7) --- testing: '3.4a' - 'abc' --- -float(3.4) +int(0) --- testing: '3.4a' - '123abc' --- -float(-119.6) +int(0) --- testing: '3.4a' - '123e5' --- -float(-12299996.6) +float(-12300000) --- testing: '3.4a' - '123e5xyz' --- -float(-12299996.6) +int(0) --- testing: '3.4a' - ' 123abc' --- -float(-119.6) +int(0) --- testing: '3.4a' - '123 abc' --- -float(-119.6) +int(0) --- testing: '3.4a' - '123abc ' --- -float(-119.6) +int(0) --- testing: '3.4a' - '3.4a' --- -float(0) +int(0) --- testing: '3.4a' - 'a5.9' --- -float(3.4) +int(0) --- testing: 'a5.9' - '0' --- int(0) --- testing: 'a5.9' - '65' --- @@ -397,18 +397,18 @@ float(7.7) --- testing: 'a5.9' - 'abc' --- int(0) --- testing: 'a5.9' - '123abc' --- -int(-123) +int(0) --- testing: 'a5.9' - '123e5' --- float(-12300000) --- testing: 'a5.9' - '123e5xyz' --- -float(-12300000) +int(0) --- testing: 'a5.9' - ' 123abc' --- -int(-123) +int(0) --- testing: 'a5.9' - '123 abc' --- -int(-123) +int(0) --- testing: 'a5.9' - '123abc ' --- -int(-123) +int(0) --- testing: 'a5.9' - '3.4a' --- -float(-3.4) +int(0) --- testing: 'a5.9' - 'a5.9' --- int(0) From c5f413706c70ec01b63c71f2d3a8d4a809d97dd6 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Fri, 10 Jul 2020 16:54:29 +0200 Subject: [PATCH 03/14] Saner numeric string handling for string offsets --- Zend/tests/bug24773.phpt | 2 +- Zend/tests/bug31098.phpt | 25 +++-- Zend/tests/bug53432.phpt | 10 +- Zend/tests/bug64578.phpt | 4 +- Zend/tests/bug73792.phpt | 4 +- Zend/tests/bug76534.phpt | 4 +- Zend/tests/const_dereference_002.phpt | 6 +- Zend/tests/indexing_001.phpt | 14 +-- Zend/tests/numeric_strings/string_offset.phpt | 92 +++++++++---------- Zend/tests/offset_assign.phpt | 6 +- Zend/tests/offset_string.phpt | 20 ++-- Zend/zend_execute.c | 31 +++++-- ext/opcache/jit/zend_jit_helpers.c | 31 +++++-- ext/opcache/tests/jit/fetch_dim_r_003.phpt | 24 +++-- ext/opcache/tests/jit/fetch_dim_r_004.phpt | 18 ++-- tests/lang/bug19943.phpt | 4 +- tests/lang/bug29566.phpt | 4 +- tests/strings/offsets_chaining_5.phpt | 10 +- tests/strings/offsets_general.phpt | 12 ++- 19 files changed, 178 insertions(+), 143 deletions(-) diff --git a/Zend/tests/bug24773.phpt b/Zend/tests/bug24773.phpt index 1a73b3df1b245..a5718e2ba0c63 100644 --- a/Zend/tests/bug24773.phpt +++ b/Zend/tests/bug24773.phpt @@ -6,7 +6,7 @@ Bug #24773 (unset() of integers treated as arrays causes a crash) unset($array["lvl1"]["lvl2"]["b"]); ?> --EXPECTF-- -Fatal error: Uncaught Error: Cannot use string offset as an array in %s:%d +Fatal error: Uncaught TypeError: Illegal offset type in %s:%d Stack trace: #0 {main} thrown in %s on line %d diff --git a/Zend/tests/bug31098.phpt b/Zend/tests/bug31098.phpt index f9ea43a93a910..e8d0576f1982d 100644 --- a/Zend/tests/bug31098.phpt +++ b/Zend/tests/bug31098.phpt @@ -17,16 +17,28 @@ var_dump(isset($a['b'])); $simpleString = "Bogus String Text"; echo isset($simpleString->wrong)?"bug\n":"ok\n"; -echo isset($simpleString["wrong"])?"bug\n":"ok\n"; +try { + echo isset($simpleString["wrong"])?"bug\n":"ok\n"; +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} echo isset($simpleString[-20])?"bug\n":"ok\n"; echo isset($simpleString[0])?"ok\n":"bug\n"; echo isset($simpleString["0"])?"ok\n":"bug\n"; echo isset($simpleString["16"])?"ok\n":"bug\n"; echo isset($simpleString["17"])?"bug\n":"ok\n"; echo $simpleString->wrong === null?"ok\n":"bug\n"; -echo $simpleString["wrong"] === "B"?"ok\n":"bug\n"; +try { + echo $simpleString["wrong"] === "B"?"ok\n":"bug\n"; +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} echo $simpleString["0"] === "B"?"ok\n":"bug\n"; -$simpleString["wrong"] = "f"; +try { + $simpleString["wrong"] = "f"; +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} echo $simpleString["0"] === "f"?"ok\n":"bug\n"; ?> --EXPECTF-- @@ -46,10 +58,7 @@ ok Warning: Attempt to read property "wrong" on string in %s on line %d ok - -Warning: Illegal string offset "wrong" in %s on line %d -ok +Illegal offset type ok - -Warning: Illegal string offset "wrong" in %s on line %d +Illegal offset type ok diff --git a/Zend/tests/bug53432.phpt b/Zend/tests/bug53432.phpt index 68ce0e358327a..af468902f2e4b 100644 --- a/Zend/tests/bug53432.phpt +++ b/Zend/tests/bug53432.phpt @@ -16,7 +16,11 @@ var_dump($str[-1] = 'a'); var_dump($str); $str = ''; -var_dump($str['foo'] = 'a'); +try { + var_dump($str['foo'] = 'a'); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} var_dump($str); $str = ''; @@ -53,9 +57,7 @@ string(6) " a" Warning: Illegal string offset -1 in %s on line %d NULL string(0) "" - -Warning: Illegal string offset "foo" in %s on line %d -string(1) "a" +Illegal offset type string(1) "a" Error: [] operator not supported for strings string(0) "" diff --git a/Zend/tests/bug64578.phpt b/Zend/tests/bug64578.phpt index e16f8ea4baa84..d0d69995ad0ef 100644 --- a/Zend/tests/bug64578.phpt +++ b/Zend/tests/bug64578.phpt @@ -5,10 +5,10 @@ Bug #64578 (debug_backtrace in set_error_handler corrupts zend heap: segfault) set_error_handler(function($no, $err) { var_dump($err); }); -function x($s) { $s['a'] = 1; }; +function x($s) { $s['2a'] = 1; }; $y = '1'; x($y); print_r($y); --EXPECT-- -string(25) "Illegal string offset "a"" +string(26) "Illegal string offset "2a"" 1 diff --git a/Zend/tests/bug73792.phpt b/Zend/tests/bug73792.phpt index dfcd9bb499884..39e45f1367fda 100644 --- a/Zend/tests/bug73792.phpt +++ b/Zend/tests/bug73792.phpt @@ -4,7 +4,7 @@ Bug #73792 (invalid foreach loop hangs script) --EXPECTF-- -Warning: Illegal string offset "bbb" in %s on line %d +Warning: Illegal string offset "2bbb" in %s on line %d Fatal error: Uncaught Error: Cannot iterate on string offsets by reference in %sbug73792.php:4 Stack trace: diff --git a/Zend/tests/bug76534.phpt b/Zend/tests/bug76534.phpt index b0149e47a4223..f544d964c4140 100644 --- a/Zend/tests/bug76534.phpt +++ b/Zend/tests/bug76534.phpt @@ -7,10 +7,10 @@ set_error_handler(function ($severity, $message, $file, $line) { }); $x = "foo"; -$y = &$x["bar"]; +$y = &$x["2bar"]; ?> --EXPECTF-- -Fatal error: Uncaught Exception: Illegal string offset "bar" in %s:%d +Fatal error: Uncaught Exception: Illegal string offset "2bar" in %s:%d Stack trace: #0 %sbug76534.php(%d): {closure}(2, 'Illegal string ...', '%s', %d) #1 {main} diff --git a/Zend/tests/const_dereference_002.phpt b/Zend/tests/const_dereference_002.phpt index 5d3c6e584248b..d7195dd2825d7 100644 --- a/Zend/tests/const_dereference_002.phpt +++ b/Zend/tests/const_dereference_002.phpt @@ -6,12 +6,12 @@ error_reporting(E_ALL); var_dump("foobar"[3]); var_dump("foobar"[2][0]); -var_dump("foobar"["foo"]["bar"]); +var_dump("foobar"["0foo"]["0bar"]); --EXPECTF-- string(1) "b" string(1) "o" -Warning: Illegal string offset "foo" in %s on line %d +Warning: Illegal string offset "0foo" in %s on line %d -Warning: Illegal string offset "bar" in %s on line %d +Warning: Illegal string offset "0bar" in %s on line %d string(1) "f" diff --git a/Zend/tests/indexing_001.phpt b/Zend/tests/indexing_001.phpt index 156df07f0c8f9..300ce3e848a9e 100644 --- a/Zend/tests/indexing_001.phpt +++ b/Zend/tests/indexing_001.phpt @@ -75,19 +75,13 @@ array(1) { } } -Warning: Illegal string offset "foo" in %s on line %d - Warning: Array to string conversion in %s on line %d - -Warning: Only the first byte will be assigned to the string offset in %s on line %d -string(1) "A" - -Warning: Illegal string offset "foo" in %s on line %d +Illegal offset type +string(0) "" Warning: Array to string conversion in %s on line %d - -Warning: Only the first byte will be assigned to the string offset in %s on line %d -string(1) "A" +Illegal offset type +string(1) " " Cannot use a scalar value as an array float(0.1) array(1) { diff --git a/Zend/tests/numeric_strings/string_offset.phpt b/Zend/tests/numeric_strings/string_offset.phpt index f53766f56e385..c1661f72dcc26 100644 --- a/Zend/tests/numeric_strings/string_offset.phpt +++ b/Zend/tests/numeric_strings/string_offset.phpt @@ -5,74 +5,68 @@ Using different sorts of numerical strings as a string offset $str = "The world is fun"; -var_dump($str["7"]); -var_dump($str["7.5"]); -var_dump($str[" 7"]); -var_dump($str[" 7.5"]); -var_dump($str[" 7 "]); -var_dump($str[" 7.5 "]); -var_dump($str["7 "]); -var_dump($str["7.5 "]); -var_dump($str["7str"]); -var_dump($str["7.5str"]); -var_dump($str[" 7str"]); -var_dump($str[" 7.5str"]); -var_dump($str[" 7 str"]); -var_dump($str[" 7.5 str"]); -var_dump($str["7 str"]); -var_dump($str["7.5 str"]); -var_dump($str["0xC"]); -var_dump($str["0b10"]); -var_dump($str["07"]); +$keys = [ + "7", + "7.5", + " 7", + " 7.5", + " 7 ", + " 7.5 ", + "7 ", + "7.5 ", + "7str", + "7.5str", + " 7str", + " 7.5str", + " 7 str", + " 7.5 str", + "7 str", + "7.5 str", + "0xC", + "0b10", + "07", +]; + +foreach ($keys as $key) { + try { + var_dump($str[$key]); + } catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; + } +} echo "Done\n"; ?> --EXPECTF-- string(1) "l" - -Warning: Illegal string offset "7.5" in %s on line 6 -string(1) "l" -string(1) "l" - -Warning: Illegal string offset " 7.5" in %s on line 8 -string(1) "l" -string(1) "l" - -Warning: Illegal string offset " 7.5 " in %s on line 10 -string(1) "l" +Illegal offset type string(1) "l" - -Warning: Illegal string offset "7.5 " in %s on line 12 -string(1) "l" - -Warning: Illegal string offset "7str" in %s on line 13 -string(1) "l" - -Warning: Illegal string offset "7.5str" in %s on line 14 -string(1) "l" - -Warning: Illegal string offset " 7str" in %s on line 15 +Illegal offset type string(1) "l" - -Warning: Illegal string offset " 7.5str" in %s on line 16 +Illegal offset type string(1) "l" +Illegal offset type -Warning: Illegal string offset " 7 str" in %s on line 17 +Warning: Illegal string offset "7str" in %s on line %d string(1) "l" +Illegal offset type -Warning: Illegal string offset " 7.5 str" in %s on line 18 +Warning: Illegal string offset " 7str" in %s on line %d string(1) "l" +Illegal offset type -Warning: Illegal string offset "7 str" in %s on line 19 +Warning: Illegal string offset " 7 str" in %s on line %d string(1) "l" +Illegal offset type -Warning: Illegal string offset "7.5 str" in %s on line 20 +Warning: Illegal string offset "7 str" in %s on line %d string(1) "l" +Illegal offset type -Warning: Illegal string offset "0xC" in %s on line 21 +Warning: Illegal string offset "0xC" in %s on line %d string(1) "T" -Warning: Illegal string offset "0b10" in %s on line 22 +Warning: Illegal string offset "0b10" in %s on line %d string(1) "T" string(1) "l" Done diff --git a/Zend/tests/offset_assign.phpt b/Zend/tests/offset_assign.phpt index d4c56b30c8b44..d2e33cafbf0ee 100644 --- a/Zend/tests/offset_assign.phpt +++ b/Zend/tests/offset_assign.phpt @@ -1,14 +1,14 @@ --TEST-- -Crash on $x['x']['y'] += 1 when $x is string +Crash on $x['2x']['y'] += 1 when $x is string --FILE-- --EXPECTF-- -Warning: Illegal string offset "x" in %s on line %d +Warning: Illegal string offset "2x" in %s on line %d Fatal error: Uncaught Error: Cannot use string offset as an array in %soffset_assign.php:%d Stack trace: diff --git a/Zend/tests/offset_string.phpt b/Zend/tests/offset_string.phpt index e21d3d0453d06..9c0a2c542145b 100644 --- a/Zend/tests/offset_string.phpt +++ b/Zend/tests/offset_string.phpt @@ -8,9 +8,17 @@ $str = "Sitting on a corner all alone, staring from the bottom of his soul"; var_dump($str[1]); var_dump($str[0.0836]); var_dump($str[NULL]); -var_dump($str["run away"]); +try { + var_dump($str["run away"]); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} var_dump($str["13"]); -var_dump($str["14.5"]); +try { + var_dump($str["14.5"]); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} var_dump($str["15 and then some"]); var_dump($str[TRUE]); @@ -47,13 +55,9 @@ string(1) "S" Warning: String offset cast occurred in %s on line %d string(1) "S" - -Warning: Illegal string offset "run away" in %s on line %d -string(1) "S" +Illegal offset type string(1) "c" - -Warning: Illegal string offset "14.5" in %s on line %d -string(1) "o" +Illegal offset type Warning: Illegal string offset "15 and then some" in %s on line %d string(1) "r" diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 699656fa693fb..d1ed0c759132b 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -1340,13 +1340,19 @@ static zend_never_inline zend_long zend_check_string_offset(zval *dim, int type if (UNEXPECTED(Z_TYPE_P(dim) != IS_LONG)) { switch(Z_TYPE_P(dim)) { case IS_STRING: - if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, false)) { - break; - } - if (type != BP_VAR_UNSET) { - zend_error(E_WARNING, "Illegal string offset \"%s\"", Z_STRVAL_P(dim)); + { + /* allow errors in string offset for BC reasons */ + if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), &offset, NULL, true)) { + /* emit Illegal string warning on leading numerical string */ + if (0 == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, false) + && type != BP_VAR_UNSET) { + zend_error(E_WARNING, "Illegal string offset \"%s\"", Z_STRVAL_P(dim)); + } + return offset; } + zend_illegal_offset(); break; + } case IS_UNDEF: ZVAL_UNDEFINED_OP2(); case IS_DOUBLE: @@ -2325,17 +2331,23 @@ static zend_always_inline void zend_fetch_dimension_address_read(zval *result, z try_string_offset: if (UNEXPECTED(Z_TYPE_P(dim) != IS_LONG)) { switch (Z_TYPE_P(dim)) { - /* case IS_LONG: */ case IS_STRING: - if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, false)) { - break; + { + /* allow errors in string offset for BC reasons */ + if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), &offset, NULL, true)) { + /* emit Illegal string warning on leading numerical string */ + if (0 == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, false)) { + zend_error(E_WARNING, "Illegal string offset \"%s\"", Z_STRVAL_P(dim)); + } + goto out; } if (type == BP_VAR_IS) { ZVAL_NULL(result); return; } - zend_error(E_WARNING, "Illegal string offset \"%s\"", Z_STRVAL_P(dim)); + zend_illegal_offset(); break; + } case IS_UNDEF: ZVAL_UNDEFINED_OP2(); case IS_DOUBLE: @@ -2358,6 +2370,7 @@ static zend_always_inline void zend_fetch_dimension_address_read(zval *result, z } else { offset = Z_LVAL_P(dim); } + out: if (UNEXPECTED(Z_STRLEN_P(container) < ((offset < 0) ? -(size_t)offset : ((size_t)offset + 1)))) { if (type != BP_VAR_IS) { diff --git a/ext/opcache/jit/zend_jit_helpers.c b/ext/opcache/jit/zend_jit_helpers.c index 2f9a6fe675bf6..435405d6ed7bf 100644 --- a/ext/opcache/jit/zend_jit_helpers.c +++ b/ext/opcache/jit/zend_jit_helpers.c @@ -677,13 +677,19 @@ static void ZEND_FASTCALL zend_jit_fetch_dim_str_r_helper(zval *container, zval try_string_offset: if (UNEXPECTED(Z_TYPE_P(dim) != IS_LONG)) { switch (Z_TYPE_P(dim)) { - /* case IS_LONG: */ case IS_STRING: - if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, false)) { - break; + { + /* allow errors in string offset for BC reasons */ + if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), &offset, NULL, true)) { + /* emit Illegal string warning on leading numerical string */ + if (0 == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, false)) { + zend_error(E_WARNING, "Illegal string offset \"%s\"", Z_STRVAL_P(dim)); + } + goto out; } - zend_error(E_WARNING, "Illegal string offset \"%s\"", Z_STRVAL_P(dim)); + zend_type_error("Illegal offset type"); break; + } case IS_UNDEF: zend_jit_undefined_op_helper(EG(current_execute_data)->opline->op2.var); case IS_DOUBLE: @@ -704,6 +710,7 @@ static void ZEND_FASTCALL zend_jit_fetch_dim_str_r_helper(zval *container, zval } else { offset = Z_LVAL_P(dim); } + out: if (UNEXPECTED(Z_STRLEN_P(container) < ((offset < 0) ? -(size_t)offset : ((size_t)offset + 1)))) { zend_error(E_WARNING, "Uninitialized string offset " ZEND_LONG_FMT, offset); @@ -818,13 +825,19 @@ static zend_never_inline zend_long zend_check_string_offset(zval *dim, int type) if (UNEXPECTED(Z_TYPE_P(dim) != IS_LONG)) { switch(Z_TYPE_P(dim)) { case IS_STRING: - if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, false)) { - break; - } - if (type != BP_VAR_UNSET) { - zend_error(E_WARNING, "Illegal string offset \"%s\"", Z_STRVAL_P(dim)); + { + /* allow errors in string offset for BC reasons */ + if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), &offset, NULL, true)) { + /* emit Illegal string warning on leading numerical string */ + if (0 == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, false) + && type != BP_VAR_UNSET) { + zend_error(E_WARNING, "Illegal string offset \"%s\"", Z_STRVAL_P(dim)); + } + return offset; } + zend_type_error("Illegal offset type"); break; + } case IS_UNDEF: zend_jit_undefined_op_helper(EG(current_execute_data)->opline->op2.var); case IS_DOUBLE: diff --git a/ext/opcache/tests/jit/fetch_dim_r_003.phpt b/ext/opcache/tests/jit/fetch_dim_r_003.phpt index da614915d7f7d..7044281d6b31d 100644 --- a/ext/opcache/tests/jit/fetch_dim_r_003.phpt +++ b/ext/opcache/tests/jit/fetch_dim_r_003.phpt @@ -20,10 +20,18 @@ function foo() { var_dump($a[false]); var_dump($a[true]); var_dump($a[null]); - var_dump($a["ab"]); + try { + var_dump($a["ab"]); + } catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; + } $x = "a"; $y = "b"; - var_dump($a[$x . $y]); + try { + var_dump($a[$x . $y]); + } catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; + } var_dump($a["2x"]); $x = "2"; $y = "x"; @@ -47,15 +55,11 @@ string(1) "B" Warning: String offset cast occurred in %s on line %d string(1) "A" +Illegal offset type +Illegal offset type -Warning: Illegal string offset "ab" in %sfetch_dim_r_003.php on line 12 -string(1) "A" - -Warning: Illegal string offset "ab" in %sfetch_dim_r_003.php on line 15 -string(1) "A" - -Warning: Illegal string offset "2x" in %sfetch_dim_r_003.php on line 16 +Warning: Illegal string offset "2x" in %sfetch_dim_r_003.php on line 24 string(1) "C" -Warning: Illegal string offset "2x" in %sfetch_dim_r_003.php on line 19 +Warning: Illegal string offset "2x" in %sfetch_dim_r_003.php on line 27 string(1) "C" diff --git a/ext/opcache/tests/jit/fetch_dim_r_004.phpt b/ext/opcache/tests/jit/fetch_dim_r_004.phpt index 5660a4dec1fbb..8902b0b625725 100644 --- a/ext/opcache/tests/jit/fetch_dim_r_004.phpt +++ b/ext/opcache/tests/jit/fetch_dim_r_004.phpt @@ -12,7 +12,11 @@ opcache.jit_buffer_size=1M getMessage() . \PHP_EOL; + } } foo(0); foo(2); @@ -47,15 +51,11 @@ string(1) "B" Warning: String offset cast occurred in %s on line %d string(1) "A" +Illegal offset type +Illegal offset type -Warning: Illegal string offset "ab" in %sfetch_dim_r_004.php on line 4 -string(1) "A" - -Warning: Illegal string offset "ab" in %sfetch_dim_r_004.php on line 4 -string(1) "A" - -Warning: Illegal string offset "2x" in %sfetch_dim_r_004.php on line 4 +Warning: Illegal string offset "2x" in %sfetch_dim_r_004.php on line 5 string(1) "C" -Warning: Illegal string offset "2x" in %sfetch_dim_r_004.php on line 4 +Warning: Illegal string offset "2x" in %sfetch_dim_r_004.php on line 5 string(1) "C" diff --git a/tests/lang/bug19943.phpt b/tests/lang/bug19943.phpt index 2266e09165965..10d2740319729 100644 --- a/tests/lang/bug19943.phpt +++ b/tests/lang/bug19943.phpt @@ -5,11 +5,11 @@ Bug #19943 (memleaks) $ar = array(); for ($count = 0; $count < 10; $count++) { $ar[$count] = "$count"; - @$ar[$count]['idx'] = "$count"; + @$ar[$count]['0idx'] = "$count"; } for ($count = 0; $count < 10; $count++) { - echo $ar[$count]." -- ".@$ar[$count]['idx']."\n"; + echo $ar[$count]." -- ".@$ar[$count]['0idx']."\n"; } $a = "0123456789"; $a[9] = $a[0]; diff --git a/tests/lang/bug29566.phpt b/tests/lang/bug29566.phpt index c80d1af28f938..9548e47875f0f 100644 --- a/tests/lang/bug29566.phpt +++ b/tests/lang/bug29566.phpt @@ -7,10 +7,10 @@ $var="This is a string"; $dummy=""; unset($dummy); -foreach($var['nosuchkey'] as $v) { +foreach($var['0nosuchkey'] as $v) { } ?> --EXPECTF-- -Warning: Illegal string offset "nosuchkey" in %s on line %d +Warning: Illegal string offset "0nosuchkey" in %s on line %d Warning: foreach() argument must be of type array|object, string given in %sbug29566.php on line %d diff --git a/tests/strings/offsets_chaining_5.phpt b/tests/strings/offsets_chaining_5.phpt index 42cb1f272187d..49f062463f1e6 100644 --- a/tests/strings/offsets_chaining_5.phpt +++ b/tests/strings/offsets_chaining_5.phpt @@ -6,20 +6,20 @@ $array = array('expected_array' => "foobar"); var_dump(isset($array['expected_array'])); var_dump($array['expected_array']); var_dump(isset($array['expected_array']['foo'])); -var_dump($array['expected_array']['foo']); +var_dump($array['expected_array']['0foo']); var_dump(isset($array['expected_array']['foo']['bar'])); -var_dump($array['expected_array']['foo']['bar']); +var_dump($array['expected_array']['0foo']['0bar']); ?> --EXPECTF-- bool(true) string(6) "foobar" bool(false) -Warning: Illegal string offset "foo" in %s on line %d +Warning: Illegal string offset "0foo" in %s on line %d string(1) "f" bool(false) -Warning: Illegal string offset "foo" in %s on line %d +Warning: Illegal string offset "0foo" in %s on line %d -Warning: Illegal string offset "bar" in %s on line %d +Warning: Illegal string offset "0bar" in %s on line %d string(1) "f" diff --git a/tests/strings/offsets_general.phpt b/tests/strings/offsets_general.phpt index 64d51457d770b..e19afb1e0d199 100644 --- a/tests/strings/offsets_general.phpt +++ b/tests/strings/offsets_general.phpt @@ -9,17 +9,19 @@ var_dump($string[0]); var_dump($string[1]); var_dump(isset($string[0])); var_dump(isset($string[0][0])); -var_dump($string["foo"]); +try { + var_dump($string["foo"]); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} var_dump(isset($string["foo"]["bar"])); ?> ---EXPECTF-- +--EXPECT-- string(1) "B" string(1) "f" string(1) "o" bool(true) bool(true) - -Warning: Illegal string offset "foo" in %s on line %d -string(1) "f" +Illegal offset type bool(false) From c9aff4f0bcc7ab22a124ecdb581baffcb86c6679 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Fri, 10 Jul 2020 16:55:32 +0200 Subject: [PATCH 04/14] Change warning type for well formed numeric float strings used as string offset --- Zend/tests/numeric_strings/string_offset.phpt | 16 ++++++--- Zend/tests/offset_string.phpt | 4 ++- Zend/zend_execute.c | 18 ++++++++-- ext/opcache/jit/zend_jit_helpers.c | 18 ++++++++-- ext/opcache/tests/jit/fetch_dim_r_003.phpt | 36 +++++++++++++++++-- ext/opcache/tests/jit/fetch_dim_r_004.phpt | 28 +++++++++++++-- 6 files changed, 107 insertions(+), 13 deletions(-) diff --git a/Zend/tests/numeric_strings/string_offset.phpt b/Zend/tests/numeric_strings/string_offset.phpt index c1661f72dcc26..ba917f2bb23c5 100644 --- a/Zend/tests/numeric_strings/string_offset.phpt +++ b/Zend/tests/numeric_strings/string_offset.phpt @@ -39,13 +39,21 @@ echo "Done\n"; ?> --EXPECTF-- string(1) "l" -Illegal offset type + +Warning: String offset cast occurred in %s on line %d string(1) "l" -Illegal offset type string(1) "l" -Illegal offset type + +Warning: String offset cast occurred in %s on line %d +string(1) "l" +string(1) "l" + +Warning: String offset cast occurred in %s on line %d +string(1) "l" +string(1) "l" + +Warning: String offset cast occurred in %s on line %d string(1) "l" -Illegal offset type Warning: Illegal string offset "7str" in %s on line %d string(1) "l" diff --git a/Zend/tests/offset_string.phpt b/Zend/tests/offset_string.phpt index 9c0a2c542145b..1dc7910f365e5 100644 --- a/Zend/tests/offset_string.phpt +++ b/Zend/tests/offset_string.phpt @@ -57,7 +57,9 @@ Warning: String offset cast occurred in %s on line %d string(1) "S" Illegal offset type string(1) "c" -Illegal offset type + +Warning: String offset cast occurred in %s on line %d +string(1) "o" Warning: Illegal string offset "15 and then some" in %s on line %d string(1) "r" diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index d1ed0c759132b..e992354ad0786 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -1342,7 +1342,8 @@ static zend_never_inline zend_long zend_check_string_offset(zval *dim, int type case IS_STRING: { /* allow errors in string offset for BC reasons */ - if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), &offset, NULL, true)) { + zend_uchar numeric_string_type = is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), &offset, NULL, true); + if (IS_LONG == numeric_string_type) { /* emit Illegal string warning on leading numerical string */ if (0 == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, false) && type != BP_VAR_UNSET) { @@ -1350,6 +1351,12 @@ static zend_never_inline zend_long zend_check_string_offset(zval *dim, int type } return offset; } + if (IS_DOUBLE == numeric_string_type) { + if (IS_DOUBLE == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, false)) { + zend_error(E_WARNING, "String offset cast occurred"); + break; + } + } zend_illegal_offset(); break; } @@ -2334,13 +2341,20 @@ static zend_always_inline void zend_fetch_dimension_address_read(zval *result, z case IS_STRING: { /* allow errors in string offset for BC reasons */ - if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), &offset, NULL, true)) { + zend_uchar numeric_string_type = is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), &offset, NULL, true); + if (IS_LONG == numeric_string_type) { /* emit Illegal string warning on leading numerical string */ if (0 == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, false)) { zend_error(E_WARNING, "Illegal string offset \"%s\"", Z_STRVAL_P(dim)); } goto out; } + if (IS_DOUBLE == numeric_string_type) { + if (IS_DOUBLE == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, false)) { + zend_error(E_WARNING, "String offset cast occurred"); + break; + } + } if (type == BP_VAR_IS) { ZVAL_NULL(result); return; diff --git a/ext/opcache/jit/zend_jit_helpers.c b/ext/opcache/jit/zend_jit_helpers.c index 435405d6ed7bf..7072580dd8fd1 100644 --- a/ext/opcache/jit/zend_jit_helpers.c +++ b/ext/opcache/jit/zend_jit_helpers.c @@ -680,13 +680,20 @@ static void ZEND_FASTCALL zend_jit_fetch_dim_str_r_helper(zval *container, zval case IS_STRING: { /* allow errors in string offset for BC reasons */ - if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), &offset, NULL, true)) { + zend_uchar numeric_string_type = is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), &offset, NULL, true); + if (IS_LONG == numeric_string_type) { /* emit Illegal string warning on leading numerical string */ if (0 == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, false)) { zend_error(E_WARNING, "Illegal string offset \"%s\"", Z_STRVAL_P(dim)); } goto out; } + if (IS_DOUBLE == numeric_string_type) { + if (IS_DOUBLE == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, false)) { + zend_error(E_WARNING, "String offset cast occurred"); + break; + } + } zend_type_error("Illegal offset type"); break; } @@ -827,7 +834,8 @@ static zend_never_inline zend_long zend_check_string_offset(zval *dim, int type) case IS_STRING: { /* allow errors in string offset for BC reasons */ - if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), &offset, NULL, true)) { + zend_uchar numeric_string_type = is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), &offset, NULL, true); + if (IS_LONG == numeric_string_type) { /* emit Illegal string warning on leading numerical string */ if (0 == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, false) && type != BP_VAR_UNSET) { @@ -835,6 +843,12 @@ static zend_never_inline zend_long zend_check_string_offset(zval *dim, int type) } return offset; } + if (IS_DOUBLE == numeric_string_type) { + if (IS_DOUBLE == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, false)) { + zend_error(E_WARNING, "String offset cast occurred"); + break; + } + } zend_type_error("Illegal offset type"); break; } diff --git a/ext/opcache/tests/jit/fetch_dim_r_003.phpt b/ext/opcache/tests/jit/fetch_dim_r_003.phpt index 7044281d6b31d..a14301989d8f7 100644 --- a/ext/opcache/tests/jit/fetch_dim_r_003.phpt +++ b/ext/opcache/tests/jit/fetch_dim_r_003.phpt @@ -36,6 +36,30 @@ function foo() { $x = "2"; $y = "x"; var_dump($a[$x . $y]); + try { + var_dump($a["5.5"]); + } catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; + } + $x = "5."; + $y = "5"; + try { + var_dump($a[$x . $y]); + } catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; + } + try { + var_dump($a["5.5cx"]); + } catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; + } + try { + $x = "5.5"; + $y = "c"; + var_dump($a[$x . $y]); + } catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; + } } foo(); --EXPECTF-- @@ -58,8 +82,16 @@ string(1) "A" Illegal offset type Illegal offset type -Warning: Illegal string offset "2x" in %sfetch_dim_r_003.php on line 24 +Warning: Illegal string offset "2x" in %s on line %d string(1) "C" -Warning: Illegal string offset "2x" in %sfetch_dim_r_003.php on line 27 +Warning: Illegal string offset "2x" in %s on line %d string(1) "C" + +Warning: String offset cast occurred in %s on line %d +string(1) "F" + +Warning: String offset cast occurred in %s on line %d +string(1) "F" +Illegal offset type +Illegal offset type diff --git a/ext/opcache/tests/jit/fetch_dim_r_004.phpt b/ext/opcache/tests/jit/fetch_dim_r_004.phpt index 8902b0b625725..0cc9a6a25bf02 100644 --- a/ext/opcache/tests/jit/fetch_dim_r_004.phpt +++ b/ext/opcache/tests/jit/fetch_dim_r_004.phpt @@ -34,6 +34,22 @@ foo("2x"); $x=2; $y="x"; foo($x.$y); +foo("5.5"); +$x = "5."; +$y = "5"; +foo($x.$y); +try { + foo("5.5c"); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} +try { + $x = "5.5"; + $y = "c"; + foo($x.$y); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} --EXPECTF-- string(1) "A" string(1) "C" @@ -54,8 +70,16 @@ string(1) "A" Illegal offset type Illegal offset type -Warning: Illegal string offset "2x" in %sfetch_dim_r_004.php on line 5 +Warning: Illegal string offset "2x" in %s on line %d string(1) "C" -Warning: Illegal string offset "2x" in %sfetch_dim_r_004.php on line 5 +Warning: Illegal string offset "2x" in %s on line %d string(1) "C" + +Warning: String offset cast occurred in %s on line %d +string(1) "F" + +Warning: String offset cast occurred in %s on line %d +string(1) "F" +Illegal offset type +Illegal offset type From bc145caf96d1526a555cb4c36a0c2e929b14c2fc Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Mon, 13 Jul 2020 17:33:49 +0200 Subject: [PATCH 05/14] Promote arithmetic/bitwise ops warnings to TypeError --- Zend/tests/add_006.phpt | 28 +- Zend/tests/bug39018_2.phpt | 7 +- Zend/tests/constant_expressions_dynamic.phpt | 2 +- Zend/tests/int_conversion_exponents.phpt | 8 +- ...c_string_must_generate_warning_assign.phpt | 243 +++--- ...numeric_strings_must_generate_warning.phpt | 210 +++--- Zend/tests/operator_unsupported_types.phpt | 60 +- Zend/tests/self_and.phpt | 14 +- Zend/tests/self_mod.phpt | 14 +- Zend/tests/self_or.phpt | 14 +- Zend/tests/self_xor.phpt | 14 +- Zend/tests/shift_001.phpt | 14 +- Zend/tests/shift_002.phpt | 14 +- Zend/zend_operators.c | 27 +- ext/opcache/tests/bug71843.phpt | 7 +- ext/reflection/tests/bug76536.phpt | 2 +- .../tests/general_functions/floatval.phpt | 8 +- .../floatval_variation1.phpt | 8 +- ext/standard/tests/math/pow_variation1.phpt | 22 +- .../tests/math/pow_variation1_64bit.phpt | 24 +- ext/standard/tests/math/pow_variation2.phpt | 24 +- ext/standard/tests/strings/bug55871.phpt | 4 +- tests/lang/bug28800.phpt | 30 +- tests/lang/operators/add_variationStr.phpt | 333 ++++---- .../bitwiseShiftLeft_variationStr.phpt | 250 +++--- .../bitwiseShiftLeft_variationStr_64bit.phpt | 252 +++---- .../bitwiseShiftRight_variationStr.phpt | 250 +++--- tests/lang/operators/divide_variationStr.phpt | 714 +++++++++--------- .../lang/operators/modulus_variationStr.phpt | 322 ++++---- .../lang/operators/multiply_variationStr.phpt | 317 ++++---- tests/lang/operators/negate_variationStr.phpt | 29 +- .../lang/operators/subtract_variationStr.phpt | 301 ++++---- 32 files changed, 1763 insertions(+), 1803 deletions(-) diff --git a/Zend/tests/add_006.phpt b/Zend/tests/add_006.phpt index dac971093e028..09945f3fce6c1 100644 --- a/Zend/tests/add_006.phpt +++ b/Zend/tests/add_006.phpt @@ -11,9 +11,12 @@ $s2 = "876222numeric"; $s3 = "48474874"; $s4 = "25.68"; -$c = $i + $s1; -var_dump($c); - +try { + $c = $i + $s1; + var_dump($c); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} $c = $i + $s2; var_dump($c); @@ -23,8 +26,12 @@ var_dump($c); $c = $i + $s4; var_dump($c); -$c = $s1 + $i; -var_dump($c); +try { + $c = $s1 + $i; + var_dump($c); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} $c = $s2 + $i; var_dump($c); @@ -38,19 +45,16 @@ var_dump($c); echo "Done\n"; ?> --EXPECTF-- -Warning: A non-numeric value encountered in %s on line %d -int(75636) +Unsupported operand types: int + string Warning: A non-numeric value encountered in %s on line %d -int(75636) +int(951858) int(48550510) float(75661.68) +Unsupported operand types: string + int Warning: A non-numeric value encountered in %s on line %d -int(75636) - -Warning: A non-numeric value encountered in %s on line %d -int(75636) +int(951858) int(48550510) float(75661.68) Done diff --git a/Zend/tests/bug39018_2.phpt b/Zend/tests/bug39018_2.phpt index 81831d51e06f3..5d45f0700bfa9 100644 --- a/Zend/tests/bug39018_2.phpt +++ b/Zend/tests/bug39018_2.phpt @@ -8,11 +8,8 @@ error_reporting(E_ALL); $foo = 'test'; $x = @$foo[6]; -print @($foo[100] + $foo[130]); - -print "\nDone\n"; +var_dump(@($foo[100] . $foo[130])); ?> --EXPECT-- -0 -Done +string(0) "" diff --git a/Zend/tests/constant_expressions_dynamic.phpt b/Zend/tests/constant_expressions_dynamic.phpt index 79f8c772e37a3..fff9f74e524d1 100644 --- a/Zend/tests/constant_expressions_dynamic.phpt +++ b/Zend/tests/constant_expressions_dynamic.phpt @@ -5,7 +5,7 @@ Dynamic Constant Expressions const C_0 = 0; const C_1 = 1; -const C_foo = "foo"; +const C_foo = "0foo"; const C_arr = [0 => 0, "foo" => "foo"]; const T_1 = C_1 | 2; diff --git a/Zend/tests/int_conversion_exponents.phpt b/Zend/tests/int_conversion_exponents.phpt index fce19aa59ac75..1e4ce72cee0ad 100644 --- a/Zend/tests/int_conversion_exponents.phpt +++ b/Zend/tests/int_conversion_exponents.phpt @@ -40,13 +40,13 @@ int(1234500000) int(-1234500000) Warning: A non-numeric value encountered in %s on line %d -int(0) +int(1234500000) Warning: A non-numeric value encountered in %s on line %d -int(0) +int(-1234500000) Warning: A non-numeric value encountered in %s on line %d -int(0) +int(1234500000) Warning: A non-numeric value encountered in %s on line %d -int(0) +int(-1234500000) diff --git a/Zend/tests/numeric_strings/invalid_numeric_string_must_generate_warning_assign.phpt b/Zend/tests/numeric_strings/invalid_numeric_string_must_generate_warning_assign.phpt index b2c92cea3dcaf..4a1100296c01c 100644 --- a/Zend/tests/numeric_strings/invalid_numeric_string_must_generate_warning_assign.phpt +++ b/Zend/tests/numeric_strings/invalid_numeric_string_must_generate_warning_assign.phpt @@ -1,5 +1,5 @@ --TEST-- -Invalid numeric string E_WARNINGs, combined assignment operations +Invalid numeric string TypeErrors and E_WARNINGs, combined assignment operations --FILE-- getMessage() . \PHP_EOL; +} echo "---", PHP_EOL; $a = foxcache("5 amet,"); $a -= "7 consectetur"; var_dump($a); -$a = foxcache("adipiscing"); -$a -= "elit,"; -var_dump($a); +try { + $a = foxcache("adipiscing"); + $a -= "elit,"; + var_dump($a); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} echo "---", PHP_EOL; $a = foxcache("11 sed"); $a *= "13 do"; var_dump($a); -$a = foxcache("eiusmod"); -$a *= "tempor"; -var_dump($a); +try { + $a = foxcache("eiusmod"); + $a *= "tempor"; + var_dump($a); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} echo "---", PHP_EOL; $a = foxcache("17 incididunt"); $a /= "19 ut"; var_dump($a); -$a = foxcache("labore"); -$a /= "et"; -var_dump($a); +try { + $a = foxcache("labore"); + $a /= "et"; + var_dump($a); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} echo "---", PHP_EOL; $a = foxcache("23 dolore"); $a **= "29 magna"; var_dump($a); -$a = foxcache("aliqua."); -$a **= "Ut"; -var_dump($a); -echo "---", PHP_EOL; try { - $a = foxcache("31 enim"); - $a %= "37 ad"; + $a = foxcache("aliqua."); + $a **= "Ut"; var_dump($a); -} catch (DivisionByZeroError $e) { +} catch (\TypeError $e) { echo $e->getMessage() . \PHP_EOL; } +echo "---", PHP_EOL; +$a = foxcache("31 enim"); +$a %= "37 ad"; +var_dump($a); try { $a = foxcache("minim"); $a %= "veniam,"; var_dump($a); -} catch (DivisionByZeroError $e) { - echo $e->getMessage() . \PHP_EOL; +} catch (\TypeError $e) { + echo get_class($e) . ': ' . $e->getMessage() . \PHP_EOL; } echo "---", PHP_EOL; $a = foxcache("41 minim"); $a <<= "43 veniam,"; -var_dump($a); -$a = foxcache("quis"); -$a <<= "nostrud"; +try { + var_dump($a); + $a = foxcache("quis"); + $a <<= "nostrud"; +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} var_dump($a); echo "---", PHP_EOL; $a = foxcache("47 exercitation"); $a >>= "53 ullamco"; var_dump($a); -$a = foxcache("laboris"); -$a >>= "nisi"; -var_dump($a); +try { + $a = foxcache("laboris"); + $a >>= "nisi"; + var_dump($a); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} echo "---", PHP_EOL; $a = foxcache("59 ut"); $a |= 61; @@ -78,12 +102,20 @@ var_dump($a); $a = foxcache(67); $a |= "71 aliquip"; var_dump($a); -$a = foxcache("ex"); -$a |= 73; -var_dump($a); -$a = foxcache(79); -$a |= "ea"; -var_dump($a); +try { + $a = foxcache("ex"); + $a |= 73; + var_dump($a); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} +try { + $a = foxcache(79); + $a |= "ea"; + var_dump($a); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} echo "---", PHP_EOL; $a = foxcache("83 commodo"); $a &= 89; @@ -91,12 +123,20 @@ var_dump($a); $a = foxcache(97); $a &= "101 consequat."; var_dump($a); -$a = foxcache("Duis"); -$a &= 103; -var_dump($a); -$a = foxcache(107); -$a &= "aute"; -var_dump($a); +try { + $a = foxcache("Duis"); + $a &= 103; + var_dump($a); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} +try { + $a = foxcache(107); + $a &= "aute"; + var_dump($a); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} echo "---", PHP_EOL; $a = foxcache("109 irure"); $a ^= 113; @@ -104,140 +144,101 @@ var_dump($a); $a = foxcache(127); $a ^= "131 dolor"; var_dump($a); -$a = foxcache("in"); -$a ^= 137; -var_dump($a); -$a = foxcache(139); -$a ^= "reprehenderit"; -var_dump($a); +try { + $a = foxcache("in"); + $a ^= 137; + var_dump($a); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} +try { + $a = foxcache(139); + $a ^= "reprehenderit"; + var_dump($a); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} ?> --EXPECTF-- Warning: A non-numeric value encountered in %s on line %d Warning: A non-numeric value encountered in %s on line %d -int(0) - -Warning: A non-numeric value encountered in %s on line %d - -Warning: A non-numeric value encountered in %s on line %d -int(0) +int(5) +Unsupported operand types: string + string --- Warning: A non-numeric value encountered in %s on line %d Warning: A non-numeric value encountered in %s on line %d -int(0) - -Warning: A non-numeric value encountered in %s on line %d - -Warning: A non-numeric value encountered in %s on line %d -int(0) +int(-2) +Unsupported operand types: string - string --- Warning: A non-numeric value encountered in %s on line %d Warning: A non-numeric value encountered in %s on line %d -int(0) - -Warning: A non-numeric value encountered in %s on line %d - -Warning: A non-numeric value encountered in %s on line %d -int(0) +int(143) +Unsupported operand types: string * string --- Warning: A non-numeric value encountered in %s on line %d Warning: A non-numeric value encountered in %s on line %d - -Warning: Division by zero in %s on line %d -float(NAN) - -Warning: A non-numeric value encountered in %s on line %d - -Warning: A non-numeric value encountered in %s on line %d - -Warning: Division by zero in %s on line %d -float(NAN) +float(0.8947368421052632) +Unsupported operand types: string / string --- Warning: A non-numeric value encountered in %s on line %d Warning: A non-numeric value encountered in %s on line %d -int(1) - -Warning: A non-numeric value encountered in %s on line %d - -Warning: A non-numeric value encountered in %s on line %d -int(1) +float(3.0910586430935376E+39) +Unsupported operand types: string ** string --- Warning: A non-numeric value encountered in %s on line %d Warning: A non-numeric value encountered in %s on line %d -Modulo by zero - -Warning: A non-numeric value encountered in %s on line %d - -Warning: A non-numeric value encountered in %s on line %d -Modulo by zero +int(31) +TypeError: Unsupported operand types: string % string --- Warning: A non-numeric value encountered in %s on line %d Warning: A non-numeric value encountered in %s on line %d -int(0) - -Warning: A non-numeric value encountered in %s on line %d - -Warning: A non-numeric value encountered in %s on line %d -int(0) +int(360639813910528) +Unsupported operand types: string << string +string(4) "quis" --- Warning: A non-numeric value encountered in %s on line %d Warning: A non-numeric value encountered in %s on line %d int(0) - -Warning: A non-numeric value encountered in %s on line %d - -Warning: A non-numeric value encountered in %s on line %d -int(0) +Unsupported operand types: string >> string --- Warning: A non-numeric value encountered in %s on line %d -int(61) +int(63) Warning: A non-numeric value encountered in %s on line %d -int(67) - -Warning: A non-numeric value encountered in %s on line %d -int(73) - -Warning: A non-numeric value encountered in %s on line %d -int(79) +int(71) +Unsupported operand types: string | int +Unsupported operand types: int | string --- Warning: A non-numeric value encountered in %s on line %d -int(0) - -Warning: A non-numeric value encountered in %s on line %d -int(0) +int(81) Warning: A non-numeric value encountered in %s on line %d -int(0) - -Warning: A non-numeric value encountered in %s on line %d -int(0) +int(97) +Unsupported operand types: string & int +Unsupported operand types: int & string --- Warning: A non-numeric value encountered in %s on line %d -int(113) - -Warning: A non-numeric value encountered in %s on line %d -int(127) - -Warning: A non-numeric value encountered in %s on line %d -int(137) +int(28) Warning: A non-numeric value encountered in %s on line %d -int(139) +int(252) +Unsupported operand types: string ^ int +Unsupported operand types: int ^ string diff --git a/Zend/tests/numeric_strings/invalid_numeric_strings_must_generate_warning.phpt b/Zend/tests/numeric_strings/invalid_numeric_strings_must_generate_warning.phpt index c6a5364e59f52..f24298245faa6 100644 --- a/Zend/tests/numeric_strings/invalid_numeric_strings_must_generate_warning.phpt +++ b/Zend/tests/numeric_strings/invalid_numeric_strings_must_generate_warning.phpt @@ -1,198 +1,206 @@ --TEST-- -Invalid numeric string E_WARNINGs +Invalid numeric string TypeErrors and E_WARNINGs --FILE-- getMessage() . \PHP_EOL; +} echo "---", PHP_EOL; var_dump("5 amet," - "7 consectetur"); -var_dump("adipiscing" - "elit,"); +try { + var_dump("adipiscing" - "elit,"); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} echo "---", PHP_EOL; var_dump("11 sed" * "13 do"); -var_dump("eiusmod" * "tempor"); +try { + var_dump("eiusmod" * "tempor"); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} echo "---", PHP_EOL; var_dump("17 incididunt" / "19 ut"); -var_dump("labore" / "et"); +try { + var_dump("labore" / "et"); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} echo "---", PHP_EOL; var_dump("23 dolore" ** "29 magna"); -var_dump("aliqua." ** "Ut"); -echo "---", PHP_EOL; try { - var_dump("31 enim" % "37 ad"); -} catch (DivisionByZeroError $e) { + var_dump("aliqua." ** "Ut"); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; } +echo "---", PHP_EOL; +var_dump("31 enim" % "37 ad"); try { var_dump("minim" % "veniam,"); -} catch (DivisionByZeroError $e) { +} catch (\TypeError $e) { + echo get_class($e) . ': ' . $e->getMessage() . \PHP_EOL; } echo "---", PHP_EOL; var_dump("41 minim" << "43 veniam,"); -var_dump("quis" << "nostrud"); +try { + var_dump("quis" << "nostrud"); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} echo "---", PHP_EOL; var_dump("47 exercitation" >> "53 ullamco"); -var_dump("laboris" >> "nisi"); +try { + var_dump("laboris" >> "nisi"); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} echo "---", PHP_EOL; var_dump("59 ut" | 61); var_dump(67 | "71 aliquip"); -var_dump("ex" | 73); -var_dump(79 | "ea"); +try { + var_dump("ex" | 73); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} +try { + var_dump(79 | "ea"); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} echo "---", PHP_EOL; var_dump("83 commodo" & 89); var_dump(97 & "101 consequat."); -var_dump("Duis" & 103); -var_dump(107 & "aute"); +try { + var_dump("Duis" & 103); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} +try { + var_dump(107 & "aute"); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} echo "---", PHP_EOL; var_dump("109 irure" ^ 113); var_dump(127 ^ "131 dolor"); -var_dump("in" ^ 137); -var_dump(139 ^ "reprehenderit"); +try { + var_dump("in" ^ 137); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} +try { + var_dump(139 ^ "reprehenderit"); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} echo "---", PHP_EOL; var_dump(+"149 in"); -var_dump(+"voluptate"); +try { + var_dump(+"voluptate"); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} echo "---", PHP_EOL; var_dump(-"151 velit"); -var_dump(-"esse"); +try { + var_dump(-"esse"); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} ?> --EXPECTF-- Warning: A non-numeric value encountered in %s on line %d Warning: A non-numeric value encountered in %s on line %d -int(0) - -Warning: A non-numeric value encountered in %s on line %d - -Warning: A non-numeric value encountered in %s on line %d -int(0) +int(5) +Unsupported operand types: string + string --- Warning: A non-numeric value encountered in %s on line %d Warning: A non-numeric value encountered in %s on line %d -int(0) - -Warning: A non-numeric value encountered in %s on line %d - -Warning: A non-numeric value encountered in %s on line %d -int(0) +int(-2) +Unsupported operand types: string - string --- Warning: A non-numeric value encountered in %s on line %d Warning: A non-numeric value encountered in %s on line %d -int(0) - -Warning: A non-numeric value encountered in %s on line %d - -Warning: A non-numeric value encountered in %s on line %d -int(0) +int(143) +Unsupported operand types: string * string --- Warning: A non-numeric value encountered in %s on line %d Warning: A non-numeric value encountered in %s on line %d - -Warning: Division by zero in %s on line %d -float(NAN) - -Warning: A non-numeric value encountered in %s on line %d - -Warning: A non-numeric value encountered in %s on line %d - -Warning: Division by zero in %s on line %d -float(NAN) +float(0.8947368421052632) +Unsupported operand types: string / string --- Warning: A non-numeric value encountered in %s on line %d Warning: A non-numeric value encountered in %s on line %d -int(1) - -Warning: A non-numeric value encountered in %s on line %d - -Warning: A non-numeric value encountered in %s on line %d -int(1) +float(3.0910586430935376E+39) +Unsupported operand types: string ** string --- Warning: A non-numeric value encountered in %s on line %d Warning: A non-numeric value encountered in %s on line %d - -Warning: A non-numeric value encountered in %s on line %d - -Warning: A non-numeric value encountered in %s on line %d +int(31) +TypeError: Unsupported operand types: string % string --- Warning: A non-numeric value encountered in %s on line %d Warning: A non-numeric value encountered in %s on line %d -int(0) - -Warning: A non-numeric value encountered in %s on line %d - -Warning: A non-numeric value encountered in %s on line %d -int(0) +int(360639813910528) +Unsupported operand types: string << string --- Warning: A non-numeric value encountered in %s on line %d Warning: A non-numeric value encountered in %s on line %d int(0) - -Warning: A non-numeric value encountered in %s on line %d - -Warning: A non-numeric value encountered in %s on line %d -int(0) +Unsupported operand types: string >> string --- Warning: A non-numeric value encountered in %s on line %d -int(61) +int(63) Warning: A non-numeric value encountered in %s on line %d -int(67) - -Warning: A non-numeric value encountered in %s on line %d -int(73) - -Warning: A non-numeric value encountered in %s on line %d -int(79) +int(71) +Unsupported operand types: string | int +Unsupported operand types: int | string --- Warning: A non-numeric value encountered in %s on line %d -int(0) - -Warning: A non-numeric value encountered in %s on line %d -int(0) - -Warning: A non-numeric value encountered in %s on line %d -int(0) +int(81) Warning: A non-numeric value encountered in %s on line %d -int(0) +int(97) +Unsupported operand types: string & int +Unsupported operand types: int & string --- Warning: A non-numeric value encountered in %s on line %d -int(113) +int(28) Warning: A non-numeric value encountered in %s on line %d -int(127) - -Warning: A non-numeric value encountered in %s on line %d -int(137) - -Warning: A non-numeric value encountered in %s on line %d -int(139) +int(252) +Unsupported operand types: string ^ int +Unsupported operand types: int ^ string --- Warning: A non-numeric value encountered in %s on line %d -int(0) - -Warning: A non-numeric value encountered in %s on line %d -int(0) +int(149) +Unsupported operand types: int * string --- Warning: A non-numeric value encountered in %s on line %d -int(0) - -Warning: A non-numeric value encountered in %s on line %d -int(0) +int(-151) +Unsupported operand types: int * string diff --git a/Zend/tests/operator_unsupported_types.phpt b/Zend/tests/operator_unsupported_types.phpt index 4b27f722d7a71..9293d1b9a6b30 100644 --- a/Zend/tests/operator_unsupported_types.phpt +++ b/Zend/tests/operator_unsupported_types.phpt @@ -32,7 +32,7 @@ $legalValues = [ '2', '3.5', '"123"', - '"foo"', // Semi-legal. + '"foo"', // Semi-legal ]; set_error_handler(function($errno, $errstr) { @@ -147,7 +147,6 @@ Unsupported operand types: float + array Unsupported operand types: array + string Unsupported operand types: string + array Unsupported operand types: array + string -Warning: A non-numeric value encountered Unsupported operand types: string + array Unsupported operand types: stdClass + null Unsupported operand types: null + stdClass @@ -162,7 +161,6 @@ Unsupported operand types: float + stdClass Unsupported operand types: stdClass + string Unsupported operand types: string + stdClass Unsupported operand types: stdClass + string -Warning: A non-numeric value encountered Unsupported operand types: string + stdClass Unsupported operand types: resource + null Unsupported operand types: null + resource @@ -177,7 +175,6 @@ Unsupported operand types: float + resource Unsupported operand types: resource + string Unsupported operand types: string + resource Unsupported operand types: resource + string -Warning: A non-numeric value encountered Unsupported operand types: string + resource Unsupported operand types: array - array Unsupported operand types: array - stdClass @@ -201,7 +198,6 @@ Unsupported operand types: float - array Unsupported operand types: array - string Unsupported operand types: string - array Unsupported operand types: array - string -Warning: A non-numeric value encountered Unsupported operand types: string - array Unsupported operand types: stdClass - null Unsupported operand types: null - stdClass @@ -216,7 +212,6 @@ Unsupported operand types: float - stdClass Unsupported operand types: stdClass - string Unsupported operand types: string - stdClass Unsupported operand types: stdClass - string -Warning: A non-numeric value encountered Unsupported operand types: string - stdClass Unsupported operand types: resource - null Unsupported operand types: null - resource @@ -231,7 +226,6 @@ Unsupported operand types: float - resource Unsupported operand types: resource - string Unsupported operand types: string - resource Unsupported operand types: resource - string -Warning: A non-numeric value encountered Unsupported operand types: string - resource Unsupported operand types: array * array Unsupported operand types: stdClass * array @@ -255,7 +249,6 @@ Unsupported operand types: float * array Unsupported operand types: array * string Unsupported operand types: string * array Unsupported operand types: array * string -Warning: A non-numeric value encountered Unsupported operand types: string * array Unsupported operand types: stdClass * null Unsupported operand types: stdClass * null @@ -307,7 +300,6 @@ Unsupported operand types: float / array Unsupported operand types: array / string Unsupported operand types: string / array Unsupported operand types: array / string -Warning: A non-numeric value encountered Unsupported operand types: string / array Unsupported operand types: stdClass / null Unsupported operand types: null / stdClass @@ -322,7 +314,6 @@ Unsupported operand types: float / stdClass Unsupported operand types: stdClass / string Unsupported operand types: string / stdClass Unsupported operand types: stdClass / string -Warning: A non-numeric value encountered Unsupported operand types: string / stdClass Unsupported operand types: resource / null Unsupported operand types: null / resource @@ -337,7 +328,6 @@ Unsupported operand types: float / resource Unsupported operand types: resource / string Unsupported operand types: string / resource Unsupported operand types: resource / string -Warning: A non-numeric value encountered Unsupported operand types: string / resource Unsupported operand types: array % array Unsupported operand types: array % stdClass @@ -361,7 +351,6 @@ Unsupported operand types: float % array Unsupported operand types: array % string Unsupported operand types: string % array Unsupported operand types: array % string -Warning: A non-numeric value encountered Unsupported operand types: string % array Unsupported operand types: stdClass % null Unsupported operand types: null % stdClass @@ -376,7 +365,6 @@ Unsupported operand types: float % stdClass Unsupported operand types: stdClass % string Unsupported operand types: string % stdClass Unsupported operand types: stdClass % string -Warning: A non-numeric value encountered Unsupported operand types: string % stdClass Unsupported operand types: resource % null Unsupported operand types: null % resource @@ -391,7 +379,6 @@ Unsupported operand types: float % resource Unsupported operand types: resource % string Unsupported operand types: string % resource Unsupported operand types: resource % string -Warning: A non-numeric value encountered Unsupported operand types: string % resource Unsupported operand types: array ** array Unsupported operand types: array ** stdClass @@ -415,7 +402,6 @@ Unsupported operand types: float ** array Unsupported operand types: array ** string Unsupported operand types: string ** array Unsupported operand types: array ** string -Warning: A non-numeric value encountered Unsupported operand types: string ** array Unsupported operand types: stdClass ** null Unsupported operand types: null ** stdClass @@ -430,7 +416,6 @@ Unsupported operand types: float ** stdClass Unsupported operand types: stdClass ** string Unsupported operand types: string ** stdClass Unsupported operand types: stdClass ** string -Warning: A non-numeric value encountered Unsupported operand types: string ** stdClass Unsupported operand types: resource ** null Unsupported operand types: null ** resource @@ -445,7 +430,6 @@ Unsupported operand types: float ** resource Unsupported operand types: resource ** string Unsupported operand types: string ** resource Unsupported operand types: resource ** string -Warning: A non-numeric value encountered Unsupported operand types: string ** resource Unsupported operand types: array << array Unsupported operand types: array << stdClass @@ -469,7 +453,6 @@ Unsupported operand types: float << array Unsupported operand types: array << string Unsupported operand types: string << array Unsupported operand types: array << string -Warning: A non-numeric value encountered Unsupported operand types: string << array Unsupported operand types: stdClass << null Unsupported operand types: null << stdClass @@ -484,7 +467,6 @@ Unsupported operand types: float << stdClass Unsupported operand types: stdClass << string Unsupported operand types: string << stdClass Unsupported operand types: stdClass << string -Warning: A non-numeric value encountered Unsupported operand types: string << stdClass Unsupported operand types: resource << null Unsupported operand types: null << resource @@ -499,7 +481,6 @@ Unsupported operand types: float << resource Unsupported operand types: resource << string Unsupported operand types: string << resource Unsupported operand types: resource << string -Warning: A non-numeric value encountered Unsupported operand types: string << resource Unsupported operand types: array >> array Unsupported operand types: array >> stdClass @@ -523,7 +504,6 @@ Unsupported operand types: float >> array Unsupported operand types: array >> string Unsupported operand types: string >> array Unsupported operand types: array >> string -Warning: A non-numeric value encountered Unsupported operand types: string >> array Unsupported operand types: stdClass >> null Unsupported operand types: null >> stdClass @@ -538,7 +518,6 @@ Unsupported operand types: float >> stdClass Unsupported operand types: stdClass >> string Unsupported operand types: string >> stdClass Unsupported operand types: stdClass >> string -Warning: A non-numeric value encountered Unsupported operand types: string >> stdClass Unsupported operand types: resource >> null Unsupported operand types: null >> resource @@ -553,7 +532,6 @@ Unsupported operand types: float >> resource Unsupported operand types: resource >> string Unsupported operand types: string >> resource Unsupported operand types: resource >> string -Warning: A non-numeric value encountered Unsupported operand types: string >> resource Unsupported operand types: array & array Unsupported operand types: stdClass & array @@ -577,7 +555,6 @@ Unsupported operand types: float & array Unsupported operand types: array & string Unsupported operand types: string & array Unsupported operand types: array & string -Warning: A non-numeric value encountered Unsupported operand types: string & array Unsupported operand types: stdClass & null Unsupported operand types: stdClass & null @@ -629,7 +606,6 @@ Unsupported operand types: float | array Unsupported operand types: array | string Unsupported operand types: string | array Unsupported operand types: array | string -Warning: A non-numeric value encountered Unsupported operand types: string | array Unsupported operand types: stdClass | null Unsupported operand types: stdClass | null @@ -681,7 +657,6 @@ Unsupported operand types: float ^ array Unsupported operand types: array ^ string Unsupported operand types: string ^ array Unsupported operand types: array ^ string -Warning: A non-numeric value encountered Unsupported operand types: string ^ array Unsupported operand types: stdClass ^ null Unsupported operand types: stdClass ^ null @@ -858,7 +833,6 @@ Unsupported operand types: float + array Unsupported operand types: array + string Unsupported operand types: string + array Unsupported operand types: array + string -Warning: A non-numeric value encountered Unsupported operand types: string + array Unsupported operand types: stdClass + null Unsupported operand types: null + stdClass @@ -873,7 +847,6 @@ Unsupported operand types: float + stdClass Unsupported operand types: stdClass + string Unsupported operand types: string + stdClass Unsupported operand types: stdClass + string -Warning: A non-numeric value encountered Unsupported operand types: string + stdClass Unsupported operand types: resource + null Unsupported operand types: null + resource @@ -888,7 +861,6 @@ Unsupported operand types: float + resource Unsupported operand types: resource + string Unsupported operand types: string + resource Unsupported operand types: resource + string -Warning: A non-numeric value encountered Unsupported operand types: string + resource Unsupported operand types: array - array Unsupported operand types: array - stdClass @@ -912,7 +884,6 @@ Unsupported operand types: float - array Unsupported operand types: array - string Unsupported operand types: string - array Unsupported operand types: array - string -Warning: A non-numeric value encountered Unsupported operand types: string - array Unsupported operand types: stdClass - null Unsupported operand types: null - stdClass @@ -927,7 +898,6 @@ Unsupported operand types: float - stdClass Unsupported operand types: stdClass - string Unsupported operand types: string - stdClass Unsupported operand types: stdClass - string -Warning: A non-numeric value encountered Unsupported operand types: string - stdClass Unsupported operand types: resource - null Unsupported operand types: null - resource @@ -942,7 +912,6 @@ Unsupported operand types: float - resource Unsupported operand types: resource - string Unsupported operand types: string - resource Unsupported operand types: resource - string -Warning: A non-numeric value encountered Unsupported operand types: string - resource Unsupported operand types: array * array Unsupported operand types: array * stdClass @@ -966,7 +935,6 @@ Unsupported operand types: float * array Unsupported operand types: array * string Unsupported operand types: string * array Unsupported operand types: array * string -Warning: A non-numeric value encountered Unsupported operand types: string * array Unsupported operand types: stdClass * null Unsupported operand types: null * stdClass @@ -981,7 +949,6 @@ Unsupported operand types: float * stdClass Unsupported operand types: stdClass * string Unsupported operand types: string * stdClass Unsupported operand types: stdClass * string -Warning: A non-numeric value encountered Unsupported operand types: string * stdClass Unsupported operand types: resource * null Unsupported operand types: null * resource @@ -996,7 +963,6 @@ Unsupported operand types: float * resource Unsupported operand types: resource * string Unsupported operand types: string * resource Unsupported operand types: resource * string -Warning: A non-numeric value encountered Unsupported operand types: string * resource Unsupported operand types: array / array Unsupported operand types: array / stdClass @@ -1020,7 +986,6 @@ Unsupported operand types: float / array Unsupported operand types: array / string Unsupported operand types: string / array Unsupported operand types: array / string -Warning: A non-numeric value encountered Unsupported operand types: string / array Unsupported operand types: stdClass / null Unsupported operand types: null / stdClass @@ -1035,7 +1000,6 @@ Unsupported operand types: float / stdClass Unsupported operand types: stdClass / string Unsupported operand types: string / stdClass Unsupported operand types: stdClass / string -Warning: A non-numeric value encountered Unsupported operand types: string / stdClass Unsupported operand types: resource / null Unsupported operand types: null / resource @@ -1050,7 +1014,6 @@ Unsupported operand types: float / resource Unsupported operand types: resource / string Unsupported operand types: string / resource Unsupported operand types: resource / string -Warning: A non-numeric value encountered Unsupported operand types: string / resource Unsupported operand types: array % array Unsupported operand types: array % stdClass @@ -1074,7 +1037,6 @@ Unsupported operand types: float % array Unsupported operand types: array % string Unsupported operand types: string % array Unsupported operand types: array % string -Warning: A non-numeric value encountered Unsupported operand types: string % array Unsupported operand types: stdClass % null Unsupported operand types: null % stdClass @@ -1089,7 +1051,6 @@ Unsupported operand types: float % stdClass Unsupported operand types: stdClass % string Unsupported operand types: string % stdClass Unsupported operand types: stdClass % string -Warning: A non-numeric value encountered Unsupported operand types: string % stdClass Unsupported operand types: resource % null Unsupported operand types: null % resource @@ -1104,7 +1065,6 @@ Unsupported operand types: float % resource Unsupported operand types: resource % string Unsupported operand types: string % resource Unsupported operand types: resource % string -Warning: A non-numeric value encountered Unsupported operand types: string % resource Unsupported operand types: array ** array Unsupported operand types: array ** stdClass @@ -1128,7 +1088,6 @@ Unsupported operand types: float ** array Unsupported operand types: array ** string Unsupported operand types: string ** array Unsupported operand types: array ** string -Warning: A non-numeric value encountered Unsupported operand types: string ** array Unsupported operand types: stdClass ** null Unsupported operand types: null ** stdClass @@ -1143,7 +1102,6 @@ Unsupported operand types: float ** stdClass Unsupported operand types: stdClass ** string Unsupported operand types: string ** stdClass Unsupported operand types: stdClass ** string -Warning: A non-numeric value encountered Unsupported operand types: string ** stdClass Unsupported operand types: resource ** null Unsupported operand types: null ** resource @@ -1158,7 +1116,6 @@ Unsupported operand types: float ** resource Unsupported operand types: resource ** string Unsupported operand types: string ** resource Unsupported operand types: resource ** string -Warning: A non-numeric value encountered Unsupported operand types: string ** resource Unsupported operand types: array << array Unsupported operand types: array << stdClass @@ -1182,7 +1139,6 @@ Unsupported operand types: float << array Unsupported operand types: array << string Unsupported operand types: string << array Unsupported operand types: array << string -Warning: A non-numeric value encountered Unsupported operand types: string << array Unsupported operand types: stdClass << null Unsupported operand types: null << stdClass @@ -1197,7 +1153,6 @@ Unsupported operand types: float << stdClass Unsupported operand types: stdClass << string Unsupported operand types: string << stdClass Unsupported operand types: stdClass << string -Warning: A non-numeric value encountered Unsupported operand types: string << stdClass Unsupported operand types: resource << null Unsupported operand types: null << resource @@ -1212,7 +1167,6 @@ Unsupported operand types: float << resource Unsupported operand types: resource << string Unsupported operand types: string << resource Unsupported operand types: resource << string -Warning: A non-numeric value encountered Unsupported operand types: string << resource Unsupported operand types: array >> array Unsupported operand types: array >> stdClass @@ -1236,7 +1190,6 @@ Unsupported operand types: float >> array Unsupported operand types: array >> string Unsupported operand types: string >> array Unsupported operand types: array >> string -Warning: A non-numeric value encountered Unsupported operand types: string >> array Unsupported operand types: stdClass >> null Unsupported operand types: null >> stdClass @@ -1251,7 +1204,6 @@ Unsupported operand types: float >> stdClass Unsupported operand types: stdClass >> string Unsupported operand types: string >> stdClass Unsupported operand types: stdClass >> string -Warning: A non-numeric value encountered Unsupported operand types: string >> stdClass Unsupported operand types: resource >> null Unsupported operand types: null >> resource @@ -1266,7 +1218,6 @@ Unsupported operand types: float >> resource Unsupported operand types: resource >> string Unsupported operand types: string >> resource Unsupported operand types: resource >> string -Warning: A non-numeric value encountered Unsupported operand types: string >> resource Unsupported operand types: array & array Unsupported operand types: array & stdClass @@ -1290,7 +1241,6 @@ Unsupported operand types: float & array Unsupported operand types: array & string Unsupported operand types: string & array Unsupported operand types: array & string -Warning: A non-numeric value encountered Unsupported operand types: string & array Unsupported operand types: stdClass & null Unsupported operand types: null & stdClass @@ -1305,7 +1255,6 @@ Unsupported operand types: float & stdClass Unsupported operand types: stdClass & string Unsupported operand types: string & stdClass Unsupported operand types: stdClass & string -Warning: A non-numeric value encountered Unsupported operand types: string & stdClass Unsupported operand types: resource & null Unsupported operand types: null & resource @@ -1320,7 +1269,6 @@ Unsupported operand types: float & resource Unsupported operand types: resource & string Unsupported operand types: string & resource Unsupported operand types: resource & string -Warning: A non-numeric value encountered Unsupported operand types: string & resource Unsupported operand types: array | array Unsupported operand types: array | stdClass @@ -1344,7 +1292,6 @@ Unsupported operand types: float | array Unsupported operand types: array | string Unsupported operand types: string | array Unsupported operand types: array | string -Warning: A non-numeric value encountered Unsupported operand types: string | array Unsupported operand types: stdClass | null Unsupported operand types: null | stdClass @@ -1359,7 +1306,6 @@ Unsupported operand types: float | stdClass Unsupported operand types: stdClass | string Unsupported operand types: string | stdClass Unsupported operand types: stdClass | string -Warning: A non-numeric value encountered Unsupported operand types: string | stdClass Unsupported operand types: resource | null Unsupported operand types: null | resource @@ -1374,7 +1320,6 @@ Unsupported operand types: float | resource Unsupported operand types: resource | string Unsupported operand types: string | resource Unsupported operand types: resource | string -Warning: A non-numeric value encountered Unsupported operand types: string | resource Unsupported operand types: array ^ array Unsupported operand types: array ^ stdClass @@ -1398,7 +1343,6 @@ Unsupported operand types: float ^ array Unsupported operand types: array ^ string Unsupported operand types: string ^ array Unsupported operand types: array ^ string -Warning: A non-numeric value encountered Unsupported operand types: string ^ array Unsupported operand types: stdClass ^ null Unsupported operand types: null ^ stdClass @@ -1413,7 +1357,6 @@ Unsupported operand types: float ^ stdClass Unsupported operand types: stdClass ^ string Unsupported operand types: string ^ stdClass Unsupported operand types: stdClass ^ string -Warning: A non-numeric value encountered Unsupported operand types: string ^ stdClass Unsupported operand types: resource ^ null Unsupported operand types: null ^ resource @@ -1428,7 +1371,6 @@ Unsupported operand types: float ^ resource Unsupported operand types: resource ^ string Unsupported operand types: string ^ resource Unsupported operand types: resource ^ string -Warning: A non-numeric value encountered Unsupported operand types: string ^ resource Warning: Array to string conversion Warning: Array to string conversion diff --git a/Zend/tests/self_and.phpt b/Zend/tests/self_and.phpt index ffb5aff82f9c0..f3662c575c48a 100644 --- a/Zend/tests/self_and.phpt +++ b/Zend/tests/self_and.phpt @@ -12,8 +12,12 @@ $s4 = str_repeat("f", 2); $s &= 22; var_dump($s); -$s1 &= 11; -var_dump($s1); +try { + $s1 &= 11; + var_dump($s1); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} $s2 &= 33; var_dump($s2); @@ -28,12 +32,10 @@ echo "Done\n"; ?> --EXPECTF-- int(18) +Unsupported operand types: string & int Warning: A non-numeric value encountered in %s on line %d -int(0) - -Warning: A non-numeric value encountered in %s on line %d -int(0) +int(33) string(1) " " string(2) " " Done diff --git a/Zend/tests/self_mod.phpt b/Zend/tests/self_mod.phpt index edb2d6f873902..7d469f8002399 100644 --- a/Zend/tests/self_mod.phpt +++ b/Zend/tests/self_mod.phpt @@ -10,8 +10,12 @@ $s2 = "45345some"; $s %= 22; var_dump($s); -$s1 %= 11; -var_dump($s1); +try { + $s1 %= 11; + var_dump($s1); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} $s2 %= 33; var_dump($s2); @@ -20,10 +24,8 @@ echo "Done\n"; ?> --EXPECTF-- int(13) +Unsupported operand types: string % int Warning: A non-numeric value encountered in %s on line %d -int(0) - -Warning: A non-numeric value encountered in %s on line %d -int(0) +int(3) Done diff --git a/Zend/tests/self_or.phpt b/Zend/tests/self_or.phpt index c67feac351a2e..61f1f4203b080 100644 --- a/Zend/tests/self_or.phpt +++ b/Zend/tests/self_or.phpt @@ -12,8 +12,12 @@ $s4 = str_repeat("f", 2); $s |= 22; var_dump($s); -$s1 |= 11; -var_dump($s1); +try { + $s1 |= 11; + var_dump($s1); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} $s2 |= 33; var_dump($s2); @@ -28,12 +32,10 @@ echo "Done\n"; ?> --EXPECTF-- int(127) +Unsupported operand types: string | int Warning: A non-numeric value encountered in %s on line %d -int(11) - -Warning: A non-numeric value encountered in %s on line %d -int(33) +int(45345) string(1) "f" string(2) "ff" Done diff --git a/Zend/tests/self_xor.phpt b/Zend/tests/self_xor.phpt index 66efd529dec0b..4bff3f6d508e2 100644 --- a/Zend/tests/self_xor.phpt +++ b/Zend/tests/self_xor.phpt @@ -12,8 +12,12 @@ $s4 = str_repeat("f", 2); $s ^= 22; var_dump($s); -$s1 ^= 11; -var_dump($s1); +try { + $s1 ^= 11; + var_dump($s1); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} $s2 ^= 33; var_dump($s2); @@ -28,12 +32,10 @@ echo "Done\n"; ?> --EXPECTF-- int(109) +Unsupported operand types: string ^ int Warning: A non-numeric value encountered in %s on line %d -int(11) - -Warning: A non-numeric value encountered in %s on line %d -int(33) +int(45312) string(1) "F" string(2) "FF" Done diff --git a/Zend/tests/shift_001.phpt b/Zend/tests/shift_001.phpt index 5def47bbc4efd..f441cf2dcf8ba 100644 --- a/Zend/tests/shift_001.phpt +++ b/Zend/tests/shift_001.phpt @@ -10,8 +10,12 @@ $s2 = "45345some"; $s <<= 2; var_dump($s); -$s1 <<= 1; -var_dump($s1); +try { + $s1 <<= 1; + var_dump($s1); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} $s2 <<= 3; var_dump($s2); @@ -20,10 +24,8 @@ echo "Done\n"; ?> --EXPECTF-- int(492) +Unsupported operand types: string << int Warning: A non-numeric value encountered in %s on line %d -int(0) - -Warning: A non-numeric value encountered in %s on line %d -int(0) +int(362760) Done diff --git a/Zend/tests/shift_002.phpt b/Zend/tests/shift_002.phpt index 427bdb5365e03..0bdc9b3eeb3ce 100644 --- a/Zend/tests/shift_002.phpt +++ b/Zend/tests/shift_002.phpt @@ -10,8 +10,12 @@ $s2 = "45345some"; $s >>= 2; var_dump($s); -$s1 >>= 1; -var_dump($s1); +try { + $s1 >>= 1; + var_dump($s1); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} $s2 >>= 3; var_dump($s2); @@ -20,10 +24,8 @@ echo "Done\n"; ?> --EXPECTF-- int(30) +Unsupported operand types: string >> int Warning: A non-numeric value encountered in %s on line %d -int(0) - -Warning: A non-numeric value encountered in %s on line %d -int(0) +int(5668) Done diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index cd3668cf06a87..b079bbb3d9b8f 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -245,7 +245,13 @@ static zend_never_inline int ZEND_FASTCALL _zendi_try_convert_scalar_to_number(z case IS_STRING: if ((Z_TYPE_INFO_P(holder) = is_numeric_string(Z_STRVAL_P(op), Z_STRLEN_P(op), &Z_LVAL_P(holder), &Z_DVAL_P(holder), false)) == 0) { - ZVAL_LONG(holder, 0); + /* Not strictly numeric + * For BC reasons warn on leading numeric strings */ + if ((Z_TYPE_INFO_P(holder) = is_numeric_string(Z_STRVAL_P(op), Z_STRLEN_P(op), + &Z_LVAL_P(holder), &Z_DVAL_P(holder), /* allow errors */ true)) == 0) { + /* Will lead to invalid OP type error */ + return FAILURE; + } zend_error(E_WARNING, "A non-numeric value encountered"); if (UNEXPECTED(EG(exception))) { return FAILURE; @@ -295,11 +301,28 @@ static zend_never_inline zend_long ZEND_FASTCALL zendi_try_get_long(zval *op, ze zend_long lval; double dval; if (0 == (type = is_numeric_string(Z_STRVAL_P(op), Z_STRLEN_P(op), &lval, &dval, false))) { + /* Not strictly numeric + * For BC reasons warn on leading numeric strings */ + if (0 == (type = is_numeric_string(Z_STRVAL_P(op), Z_STRLEN_P(op), &lval, &dval, + /* allow errors */ true))) { + /* Will lead to invalid OP type error */ + *failed = 1; + return 0; + } zend_error(E_WARNING, "A non-numeric value encountered"); if (UNEXPECTED(EG(exception))) { *failed = 1; } - return 0; + if (type == IS_LONG) { + return lval; + } else { + /* Previously we used strtol here, not is_numeric_string, + * and strtol gives you LONG_MAX/_MIN on overflow. + * We use use saturating conversion to emulate strtol()'s + * behaviour. + */ + return zend_dval_to_lval_cap(dval); + } } else if (EXPECTED(type == IS_LONG)) { return lval; } else { diff --git a/ext/opcache/tests/bug71843.phpt b/ext/opcache/tests/bug71843.phpt index 0a193425dd4f4..28b36f7371dc8 100644 --- a/ext/opcache/tests/bug71843.phpt +++ b/ext/opcache/tests/bug71843.phpt @@ -11,12 +11,9 @@ opcache.optimization_level=0xFFFFBFFF define('E', 'E'); define('R', 'R'); define('See', 'See'); -0 & ~E & ~R; +"0" & ~E & ~R; 6 && ~See ?> okey ---EXPECTF-- -Warning: A non-numeric value encountered in %s on line %d - -Warning: A non-numeric value encountered in %s on line %d +--EXPECT-- okey diff --git a/ext/reflection/tests/bug76536.phpt b/ext/reflection/tests/bug76536.phpt index aa32781e16a1a..d6b22ada21868 100644 --- a/ext/reflection/tests/bug76536.phpt +++ b/ext/reflection/tests/bug76536.phpt @@ -2,7 +2,7 @@ Bug #76536 (PHP crashes with core dump when throwing exception in error handler) --FILE-- ---EXPECTF-- +--EXPECT-- *** Testing pow() : usage variations *** -- Iteration 1 -- @@ -141,32 +141,22 @@ int(1) int(0) -- Iteration 17 -- - -Warning: A non-numeric value encountered in %s on line %d -int(0) +Unsupported operand types: string ** int -- Iteration 18 -- - -Warning: A non-numeric value encountered in %s on line %d -int(0) +Unsupported operand types: string ** int -- Iteration 19 -- Unsupported operand types: array ** int -- Iteration 20 -- - -Warning: A non-numeric value encountered in %s on line %d -int(0) +Unsupported operand types: string ** int -- Iteration 21 -- - -Warning: A non-numeric value encountered in %s on line %d -int(0) +Unsupported operand types: string ** int -- Iteration 22 -- - -Warning: A non-numeric value encountered in %s on line %d -int(0) +Unsupported operand types: string ** int -- Iteration 23 -- Unsupported operand types: classA ** int @@ -178,4 +168,4 @@ int(0) int(0) -- Iteration 26 -- -%s +Unsupported operand types: resource ** int diff --git a/ext/standard/tests/math/pow_variation2.phpt b/ext/standard/tests/math/pow_variation2.phpt index c5fc862de466b..9351dbd4ce738 100644 --- a/ext/standard/tests/math/pow_variation2.phpt +++ b/ext/standard/tests/math/pow_variation2.phpt @@ -85,7 +85,7 @@ foreach($inputs as $input) { }; fclose($fp); ?> ---EXPECTF-- +--EXPECT-- *** Testing pow() : usage variations *** -- Iteration 1 -- @@ -137,32 +137,22 @@ float(20.3) float(1) -- Iteration 17 -- - -Warning: A non-numeric value encountered in %s on line %d -float(1) +Unsupported operand types: float ** string -- Iteration 18 -- - -Warning: A non-numeric value encountered in %s on line %d -float(1) +Unsupported operand types: float ** string -- Iteration 19 -- Unsupported operand types: float ** array -- Iteration 20 -- - -Warning: A non-numeric value encountered in %s on line %d -float(1) +Unsupported operand types: float ** string -- Iteration 21 -- - -Warning: A non-numeric value encountered in %s on line %d -float(1) +Unsupported operand types: float ** string -- Iteration 22 -- - -Warning: A non-numeric value encountered in %s on line %d -float(1) +Unsupported operand types: float ** string -- Iteration 23 -- Unsupported operand types: float ** classA @@ -174,4 +164,4 @@ float(1) float(1) -- Iteration 26 -- -%s +Unsupported operand types: float ** resource diff --git a/ext/standard/tests/strings/bug55871.phpt b/ext/standard/tests/strings/bug55871.phpt index 60a857ec67a64..47e52e9bf7248 100644 --- a/ext/standard/tests/strings/bug55871.phpt +++ b/ext/standard/tests/strings/bug55871.phpt @@ -26,7 +26,7 @@ class test3 { $my_var = str_repeat('A', 40); $out = substr_replace(array(&$my_var), array(new test1), 40, 0); var_dump($out, $my_var); -$my_var = str_repeat('A', 40); +$my_var = '0' . str_repeat('A', 39); $out = substr_replace(array(&$my_var), array(new test2), 40, 0); var_dump($out, $my_var); $my_var = str_repeat('A', 40); @@ -45,7 +45,7 @@ array(1) { Warning: A non-numeric value encountered in %s on line %d array(1) { [0]=> - string(40) "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + string(40) "0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" } int(134512640) array(1) { diff --git a/tests/lang/bug28800.phpt b/tests/lang/bug28800.phpt index 2845ca7c88d79..487c57d24e4aa 100644 --- a/tests/lang/bug28800.phpt +++ b/tests/lang/bug28800.phpt @@ -4,24 +4,18 @@ Bug #28800 (Incorrect string to number conversion for strings starting with 'inf getMessage() . \PHP_EOL; + } } ?> ---EXPECTF-- -Warning: A non-numeric value encountered in %s on line %d -0 +--EXPECT-- +Unsupported operand types: string + int +Unsupported operand types: string + int +Unsupported operand types: string + int +Unsupported operand types: string + int +Unsupported operand types: string + int +Unsupported operand types: string + int -Warning: A non-numeric value encountered in %s on line %d -0 - -Warning: A non-numeric value encountered in %s on line %d -0 - -Warning: A non-numeric value encountered in %s on line %d -0 - -Warning: A non-numeric value encountered in %s on line %d -0 - -Warning: A non-numeric value encountered in %s on line %d -0 diff --git a/tests/lang/operators/add_variationStr.phpt b/tests/lang/operators/add_variationStr.phpt index e09c15fde64f4..9f8f19dadbdd7 100644 --- a/tests/lang/operators/add_variationStr.phpt +++ b/tests/lang/operators/add_variationStr.phpt @@ -11,13 +11,16 @@ $strVals = array( error_reporting(E_ERROR); foreach ($strVals as $strVal) { - foreach($strVals as $otherVal) { - echo "--- testing: '$strVal' + '$otherVal' ---\n"; - var_dump($strVal+$otherVal); - } + foreach($strVals as $otherVal) { + echo "--- testing: '$strVal' + '$otherVal' ---\n"; + try { + var_dump($strVal+$otherVal); + } catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; + } + } } - ?> --EXPECT-- --- testing: '0' + '0' --- @@ -31,23 +34,23 @@ float(1.2) --- testing: '0' + '-7.7' --- float(-7.7) --- testing: '0' + 'abc' --- -int(0) +Unsupported operand types: string + string --- testing: '0' + '123abc' --- -int(0) +int(123) --- testing: '0' + '123e5' --- float(12300000) --- testing: '0' + '123e5xyz' --- -int(0) +float(12300000) --- testing: '0' + ' 123abc' --- -int(0) +int(123) --- testing: '0' + '123 abc' --- -int(0) +int(123) --- testing: '0' + '123abc ' --- -int(0) +int(123) --- testing: '0' + '3.4a' --- -int(0) +float(3.4) --- testing: '0' + 'a5.9' --- -int(0) +Unsupported operand types: string + string --- testing: '65' + '0' --- int(65) --- testing: '65' + '65' --- @@ -59,23 +62,23 @@ float(66.2) --- testing: '65' + '-7.7' --- float(57.3) --- testing: '65' + 'abc' --- -int(65) +Unsupported operand types: string + string --- testing: '65' + '123abc' --- -int(65) +int(188) --- testing: '65' + '123e5' --- float(12300065) --- testing: '65' + '123e5xyz' --- -int(65) +float(12300065) --- testing: '65' + ' 123abc' --- -int(65) +int(188) --- testing: '65' + '123 abc' --- -int(65) +int(188) --- testing: '65' + '123abc ' --- -int(65) +int(188) --- testing: '65' + '3.4a' --- -int(65) +float(68.4) --- testing: '65' + 'a5.9' --- -int(65) +Unsupported operand types: string + string --- testing: '-44' + '0' --- int(-44) --- testing: '-44' + '65' --- @@ -87,23 +90,23 @@ float(-42.8) --- testing: '-44' + '-7.7' --- float(-51.7) --- testing: '-44' + 'abc' --- -int(-44) +Unsupported operand types: string + string --- testing: '-44' + '123abc' --- -int(-44) +int(79) --- testing: '-44' + '123e5' --- float(12299956) --- testing: '-44' + '123e5xyz' --- -int(-44) +float(12299956) --- testing: '-44' + ' 123abc' --- -int(-44) +int(79) --- testing: '-44' + '123 abc' --- -int(-44) +int(79) --- testing: '-44' + '123abc ' --- -int(-44) +int(79) --- testing: '-44' + '3.4a' --- -int(-44) +float(-40.6) --- testing: '-44' + 'a5.9' --- -int(-44) +Unsupported operand types: string + string --- testing: '1.2' + '0' --- float(1.2) --- testing: '1.2' + '65' --- @@ -115,23 +118,23 @@ float(2.4) --- testing: '1.2' + '-7.7' --- float(-6.5) --- testing: '1.2' + 'abc' --- -float(1.2) +Unsupported operand types: string + string --- testing: '1.2' + '123abc' --- -float(1.2) +float(124.2) --- testing: '1.2' + '123e5' --- float(12300001.2) --- testing: '1.2' + '123e5xyz' --- -float(1.2) +float(12300001.2) --- testing: '1.2' + ' 123abc' --- -float(1.2) +float(124.2) --- testing: '1.2' + '123 abc' --- -float(1.2) +float(124.2) --- testing: '1.2' + '123abc ' --- -float(1.2) +float(124.2) --- testing: '1.2' + '3.4a' --- -float(1.2) +float(4.6) --- testing: '1.2' + 'a5.9' --- -float(1.2) +Unsupported operand types: string + string --- testing: '-7.7' + '0' --- float(-7.7) --- testing: '-7.7' + '65' --- @@ -143,79 +146,79 @@ float(-6.5) --- testing: '-7.7' + '-7.7' --- float(-15.4) --- testing: '-7.7' + 'abc' --- -float(-7.7) +Unsupported operand types: string + string --- testing: '-7.7' + '123abc' --- -float(-7.7) +float(115.3) --- testing: '-7.7' + '123e5' --- float(12299992.3) --- testing: '-7.7' + '123e5xyz' --- -float(-7.7) +float(12299992.3) --- testing: '-7.7' + ' 123abc' --- -float(-7.7) +float(115.3) --- testing: '-7.7' + '123 abc' --- -float(-7.7) +float(115.3) --- testing: '-7.7' + '123abc ' --- -float(-7.7) +float(115.3) --- testing: '-7.7' + '3.4a' --- -float(-7.7) +float(-4.300000000000001) --- testing: '-7.7' + 'a5.9' --- -float(-7.7) +Unsupported operand types: string + string --- testing: 'abc' + '0' --- -int(0) +Unsupported operand types: string + string --- testing: 'abc' + '65' --- -int(65) +Unsupported operand types: string + string --- testing: 'abc' + '-44' --- -int(-44) +Unsupported operand types: string + string --- testing: 'abc' + '1.2' --- -float(1.2) +Unsupported operand types: string + string --- testing: 'abc' + '-7.7' --- -float(-7.7) +Unsupported operand types: string + string --- testing: 'abc' + 'abc' --- -int(0) +Unsupported operand types: string + string --- testing: 'abc' + '123abc' --- -int(0) +Unsupported operand types: string + string --- testing: 'abc' + '123e5' --- -float(12300000) +Unsupported operand types: string + string --- testing: 'abc' + '123e5xyz' --- -int(0) +Unsupported operand types: string + string --- testing: 'abc' + ' 123abc' --- -int(0) +Unsupported operand types: string + string --- testing: 'abc' + '123 abc' --- -int(0) +Unsupported operand types: string + string --- testing: 'abc' + '123abc ' --- -int(0) +Unsupported operand types: string + string --- testing: 'abc' + '3.4a' --- -int(0) +Unsupported operand types: string + string --- testing: 'abc' + 'a5.9' --- -int(0) +Unsupported operand types: string + string --- testing: '123abc' + '0' --- -int(0) +int(123) --- testing: '123abc' + '65' --- -int(65) +int(188) --- testing: '123abc' + '-44' --- -int(-44) +int(79) --- testing: '123abc' + '1.2' --- -float(1.2) +float(124.2) --- testing: '123abc' + '-7.7' --- -float(-7.7) +float(115.3) --- testing: '123abc' + 'abc' --- -int(0) +Unsupported operand types: string + string --- testing: '123abc' + '123abc' --- -int(0) +int(246) --- testing: '123abc' + '123e5' --- -float(12300000) +float(12300123) --- testing: '123abc' + '123e5xyz' --- -int(0) +float(12300123) --- testing: '123abc' + ' 123abc' --- -int(0) +int(246) --- testing: '123abc' + '123 abc' --- -int(0) +int(246) --- testing: '123abc' + '123abc ' --- -int(0) +int(246) --- testing: '123abc' + '3.4a' --- -int(0) +float(126.4) --- testing: '123abc' + 'a5.9' --- -int(0) +Unsupported operand types: string + string --- testing: '123e5' + '0' --- float(12300000) --- testing: '123e5' + '65' --- @@ -227,188 +230,188 @@ float(12300001.2) --- testing: '123e5' + '-7.7' --- float(12299992.3) --- testing: '123e5' + 'abc' --- -float(12300000) +Unsupported operand types: string + string --- testing: '123e5' + '123abc' --- -float(12300000) +float(12300123) --- testing: '123e5' + '123e5' --- float(24600000) --- testing: '123e5' + '123e5xyz' --- -float(12300000) +float(24600000) --- testing: '123e5' + ' 123abc' --- -float(12300000) +float(12300123) --- testing: '123e5' + '123 abc' --- -float(12300000) +float(12300123) --- testing: '123e5' + '123abc ' --- -float(12300000) +float(12300123) --- testing: '123e5' + '3.4a' --- -float(12300000) +float(12300003.4) --- testing: '123e5' + 'a5.9' --- -float(12300000) +Unsupported operand types: string + string --- testing: '123e5xyz' + '0' --- -int(0) +float(12300000) --- testing: '123e5xyz' + '65' --- -int(65) +float(12300065) --- testing: '123e5xyz' + '-44' --- -int(-44) +float(12299956) --- testing: '123e5xyz' + '1.2' --- -float(1.2) +float(12300001.2) --- testing: '123e5xyz' + '-7.7' --- -float(-7.7) +float(12299992.3) --- testing: '123e5xyz' + 'abc' --- -int(0) +Unsupported operand types: string + string --- testing: '123e5xyz' + '123abc' --- -int(0) +float(12300123) --- testing: '123e5xyz' + '123e5' --- -float(12300000) +float(24600000) --- testing: '123e5xyz' + '123e5xyz' --- -int(0) +float(24600000) --- testing: '123e5xyz' + ' 123abc' --- -int(0) +float(12300123) --- testing: '123e5xyz' + '123 abc' --- -int(0) +float(12300123) --- testing: '123e5xyz' + '123abc ' --- -int(0) +float(12300123) --- testing: '123e5xyz' + '3.4a' --- -int(0) +float(12300003.4) --- testing: '123e5xyz' + 'a5.9' --- -int(0) +Unsupported operand types: string + string --- testing: ' 123abc' + '0' --- -int(0) +int(123) --- testing: ' 123abc' + '65' --- -int(65) +int(188) --- testing: ' 123abc' + '-44' --- -int(-44) +int(79) --- testing: ' 123abc' + '1.2' --- -float(1.2) +float(124.2) --- testing: ' 123abc' + '-7.7' --- -float(-7.7) +float(115.3) --- testing: ' 123abc' + 'abc' --- -int(0) +Unsupported operand types: string + string --- testing: ' 123abc' + '123abc' --- -int(0) +int(246) --- testing: ' 123abc' + '123e5' --- -float(12300000) +float(12300123) --- testing: ' 123abc' + '123e5xyz' --- -int(0) +float(12300123) --- testing: ' 123abc' + ' 123abc' --- -int(0) +int(246) --- testing: ' 123abc' + '123 abc' --- -int(0) +int(246) --- testing: ' 123abc' + '123abc ' --- -int(0) +int(246) --- testing: ' 123abc' + '3.4a' --- -int(0) +float(126.4) --- testing: ' 123abc' + 'a5.9' --- -int(0) +Unsupported operand types: string + string --- testing: '123 abc' + '0' --- -int(0) +int(123) --- testing: '123 abc' + '65' --- -int(65) +int(188) --- testing: '123 abc' + '-44' --- -int(-44) +int(79) --- testing: '123 abc' + '1.2' --- -float(1.2) +float(124.2) --- testing: '123 abc' + '-7.7' --- -float(-7.7) +float(115.3) --- testing: '123 abc' + 'abc' --- -int(0) +Unsupported operand types: string + string --- testing: '123 abc' + '123abc' --- -int(0) +int(246) --- testing: '123 abc' + '123e5' --- -float(12300000) +float(12300123) --- testing: '123 abc' + '123e5xyz' --- -int(0) +float(12300123) --- testing: '123 abc' + ' 123abc' --- -int(0) +int(246) --- testing: '123 abc' + '123 abc' --- -int(0) +int(246) --- testing: '123 abc' + '123abc ' --- -int(0) +int(246) --- testing: '123 abc' + '3.4a' --- -int(0) +float(126.4) --- testing: '123 abc' + 'a5.9' --- -int(0) +Unsupported operand types: string + string --- testing: '123abc ' + '0' --- -int(0) +int(123) --- testing: '123abc ' + '65' --- -int(65) +int(188) --- testing: '123abc ' + '-44' --- -int(-44) +int(79) --- testing: '123abc ' + '1.2' --- -float(1.2) +float(124.2) --- testing: '123abc ' + '-7.7' --- -float(-7.7) +float(115.3) --- testing: '123abc ' + 'abc' --- -int(0) +Unsupported operand types: string + string --- testing: '123abc ' + '123abc' --- -int(0) +int(246) --- testing: '123abc ' + '123e5' --- -float(12300000) +float(12300123) --- testing: '123abc ' + '123e5xyz' --- -int(0) +float(12300123) --- testing: '123abc ' + ' 123abc' --- -int(0) +int(246) --- testing: '123abc ' + '123 abc' --- -int(0) +int(246) --- testing: '123abc ' + '123abc ' --- -int(0) +int(246) --- testing: '123abc ' + '3.4a' --- -int(0) +float(126.4) --- testing: '123abc ' + 'a5.9' --- -int(0) +Unsupported operand types: string + string --- testing: '3.4a' + '0' --- -int(0) +float(3.4) --- testing: '3.4a' + '65' --- -int(65) +float(68.4) --- testing: '3.4a' + '-44' --- -int(-44) +float(-40.6) --- testing: '3.4a' + '1.2' --- -float(1.2) +float(4.6) --- testing: '3.4a' + '-7.7' --- -float(-7.7) +float(-4.300000000000001) --- testing: '3.4a' + 'abc' --- -int(0) +Unsupported operand types: string + string --- testing: '3.4a' + '123abc' --- -int(0) +float(126.4) --- testing: '3.4a' + '123e5' --- -float(12300000) +float(12300003.4) --- testing: '3.4a' + '123e5xyz' --- -int(0) +float(12300003.4) --- testing: '3.4a' + ' 123abc' --- -int(0) +float(126.4) --- testing: '3.4a' + '123 abc' --- -int(0) +float(126.4) --- testing: '3.4a' + '123abc ' --- -int(0) +float(126.4) --- testing: '3.4a' + '3.4a' --- -int(0) +float(6.8) --- testing: '3.4a' + 'a5.9' --- -int(0) +Unsupported operand types: string + string --- testing: 'a5.9' + '0' --- -int(0) +Unsupported operand types: string + string --- testing: 'a5.9' + '65' --- -int(65) +Unsupported operand types: string + string --- testing: 'a5.9' + '-44' --- -int(-44) +Unsupported operand types: string + string --- testing: 'a5.9' + '1.2' --- -float(1.2) +Unsupported operand types: string + string --- testing: 'a5.9' + '-7.7' --- -float(-7.7) +Unsupported operand types: string + string --- testing: 'a5.9' + 'abc' --- -int(0) +Unsupported operand types: string + string --- testing: 'a5.9' + '123abc' --- -int(0) +Unsupported operand types: string + string --- testing: 'a5.9' + '123e5' --- -float(12300000) +Unsupported operand types: string + string --- testing: 'a5.9' + '123e5xyz' --- -int(0) +Unsupported operand types: string + string --- testing: 'a5.9' + ' 123abc' --- -int(0) +Unsupported operand types: string + string --- testing: 'a5.9' + '123 abc' --- -int(0) +Unsupported operand types: string + string --- testing: 'a5.9' + '123abc ' --- -int(0) +Unsupported operand types: string + string --- testing: 'a5.9' + '3.4a' --- -int(0) +Unsupported operand types: string + string --- testing: 'a5.9' + 'a5.9' --- -int(0) +Unsupported operand types: string + string diff --git a/tests/lang/operators/bitwiseShiftLeft_variationStr.phpt b/tests/lang/operators/bitwiseShiftLeft_variationStr.phpt index 3c094a7d61106..cf227ddf8f8f6 100644 --- a/tests/lang/operators/bitwiseShiftLeft_variationStr.phpt +++ b/tests/lang/operators/bitwiseShiftLeft_variationStr.phpt @@ -16,7 +16,7 @@ foreach ($strVals as $strVal) { try { var_dump($strVal<<$otherVal); } catch (Throwable $e) { - echo "Exception: " . $e->getMessage() . "\n"; + echo get_class($e) . ': ' . $e->getMessage() . "\n"; } } } @@ -28,13 +28,13 @@ int(0) --- testing: '0' << '65' --- int(0) --- testing: '0' << '-44' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '0' << '1.2' --- int(0) --- testing: '0' << '-7.7' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '0' << 'abc' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: '0' << '123abc' --- int(0) --- testing: '0' << '123e5' --- @@ -50,159 +50,159 @@ int(0) --- testing: '0' << '3.4a' --- int(0) --- testing: '0' << 'a5.9' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: '65' << '0' --- int(65) --- testing: '65' << '65' --- int(0) --- testing: '65' << '-44' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '65' << '1.2' --- int(130) --- testing: '65' << '-7.7' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '65' << 'abc' --- -int(65) +TypeError: Unsupported operand types: string << string --- testing: '65' << '123abc' --- -int(65) +int(0) --- testing: '65' << '123e5' --- int(0) --- testing: '65' << '123e5xyz' --- -int(65) +int(0) --- testing: '65' << ' 123abc' --- -int(65) +int(0) --- testing: '65' << '123 abc' --- -int(65) +int(0) --- testing: '65' << '123abc ' --- -int(65) +int(0) --- testing: '65' << '3.4a' --- -int(65) +int(520) --- testing: '65' << 'a5.9' --- -int(65) +TypeError: Unsupported operand types: string << string --- testing: '-44' << '0' --- int(-44) --- testing: '-44' << '65' --- int(0) --- testing: '-44' << '-44' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '-44' << '1.2' --- int(-88) --- testing: '-44' << '-7.7' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '-44' << 'abc' --- -int(-44) +TypeError: Unsupported operand types: string << string --- testing: '-44' << '123abc' --- -int(-44) +int(0) --- testing: '-44' << '123e5' --- int(0) --- testing: '-44' << '123e5xyz' --- -int(-44) +int(0) --- testing: '-44' << ' 123abc' --- -int(-44) +int(0) --- testing: '-44' << '123 abc' --- -int(-44) +int(0) --- testing: '-44' << '123abc ' --- -int(-44) +int(0) --- testing: '-44' << '3.4a' --- -int(-44) +int(-352) --- testing: '-44' << 'a5.9' --- -int(-44) +TypeError: Unsupported operand types: string << string --- testing: '1.2' << '0' --- int(1) --- testing: '1.2' << '65' --- int(0) --- testing: '1.2' << '-44' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '1.2' << '1.2' --- int(2) --- testing: '1.2' << '-7.7' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '1.2' << 'abc' --- -int(1) +TypeError: Unsupported operand types: string << string --- testing: '1.2' << '123abc' --- -int(1) +int(0) --- testing: '1.2' << '123e5' --- int(0) --- testing: '1.2' << '123e5xyz' --- -int(1) +int(0) --- testing: '1.2' << ' 123abc' --- -int(1) +int(0) --- testing: '1.2' << '123 abc' --- -int(1) +int(0) --- testing: '1.2' << '123abc ' --- -int(1) +int(0) --- testing: '1.2' << '3.4a' --- -int(1) +int(8) --- testing: '1.2' << 'a5.9' --- -int(1) +TypeError: Unsupported operand types: string << string --- testing: '-7.7' << '0' --- int(-7) --- testing: '-7.7' << '65' --- int(0) --- testing: '-7.7' << '-44' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '-7.7' << '1.2' --- int(-14) --- testing: '-7.7' << '-7.7' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '-7.7' << 'abc' --- -int(-7) +TypeError: Unsupported operand types: string << string --- testing: '-7.7' << '123abc' --- -int(-7) +int(0) --- testing: '-7.7' << '123e5' --- int(0) --- testing: '-7.7' << '123e5xyz' --- -int(-7) +int(0) --- testing: '-7.7' << ' 123abc' --- -int(-7) +int(0) --- testing: '-7.7' << '123 abc' --- -int(-7) +int(0) --- testing: '-7.7' << '123abc ' --- -int(-7) +int(0) --- testing: '-7.7' << '3.4a' --- -int(-7) +int(-56) --- testing: '-7.7' << 'a5.9' --- -int(-7) +TypeError: Unsupported operand types: string << string --- testing: 'abc' << '0' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'abc' << '65' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'abc' << '-44' --- -Exception: Bit shift by negative number +TypeError: Unsupported operand types: string << string --- testing: 'abc' << '1.2' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'abc' << '-7.7' --- -Exception: Bit shift by negative number +TypeError: Unsupported operand types: string << string --- testing: 'abc' << 'abc' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'abc' << '123abc' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'abc' << '123e5' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'abc' << '123e5xyz' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'abc' << ' 123abc' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'abc' << '123 abc' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'abc' << '123abc ' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'abc' << '3.4a' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'abc' << 'a5.9' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: '123abc' << '0' --- -int(0) +int(123) --- testing: '123abc' << '65' --- int(0) --- testing: '123abc' << '-44' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '123abc' << '1.2' --- -int(0) +int(246) --- testing: '123abc' << '-7.7' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '123abc' << 'abc' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: '123abc' << '123abc' --- int(0) --- testing: '123abc' << '123e5' --- @@ -216,49 +216,49 @@ int(0) --- testing: '123abc' << '123abc ' --- int(0) --- testing: '123abc' << '3.4a' --- -int(0) +int(984) --- testing: '123abc' << 'a5.9' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: '123e5' << '0' --- int(12300000) --- testing: '123e5' << '65' --- int(0) --- testing: '123e5' << '-44' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '123e5' << '1.2' --- int(24600000) --- testing: '123e5' << '-7.7' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '123e5' << 'abc' --- -int(12300000) +TypeError: Unsupported operand types: string << string --- testing: '123e5' << '123abc' --- -int(12300000) +int(0) --- testing: '123e5' << '123e5' --- int(0) --- testing: '123e5' << '123e5xyz' --- -int(12300000) +int(0) --- testing: '123e5' << ' 123abc' --- -int(12300000) +int(0) --- testing: '123e5' << '123 abc' --- -int(12300000) +int(0) --- testing: '123e5' << '123abc ' --- -int(12300000) +int(0) --- testing: '123e5' << '3.4a' --- -int(12300000) +int(98400000) --- testing: '123e5' << 'a5.9' --- -int(12300000) +TypeError: Unsupported operand types: string << string --- testing: '123e5xyz' << '0' --- -int(0) +int(12300000) --- testing: '123e5xyz' << '65' --- int(0) --- testing: '123e5xyz' << '-44' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '123e5xyz' << '1.2' --- -int(0) +int(24600000) --- testing: '123e5xyz' << '-7.7' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '123e5xyz' << 'abc' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: '123e5xyz' << '123abc' --- int(0) --- testing: '123e5xyz' << '123e5' --- @@ -272,21 +272,21 @@ int(0) --- testing: '123e5xyz' << '123abc ' --- int(0) --- testing: '123e5xyz' << '3.4a' --- -int(0) +int(98400000) --- testing: '123e5xyz' << 'a5.9' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: ' 123abc' << '0' --- -int(0) +int(123) --- testing: ' 123abc' << '65' --- int(0) --- testing: ' 123abc' << '-44' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: ' 123abc' << '1.2' --- -int(0) +int(246) --- testing: ' 123abc' << '-7.7' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: ' 123abc' << 'abc' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: ' 123abc' << '123abc' --- int(0) --- testing: ' 123abc' << '123e5' --- @@ -300,21 +300,21 @@ int(0) --- testing: ' 123abc' << '123abc ' --- int(0) --- testing: ' 123abc' << '3.4a' --- -int(0) +int(984) --- testing: ' 123abc' << 'a5.9' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: '123 abc' << '0' --- -int(0) +int(123) --- testing: '123 abc' << '65' --- int(0) --- testing: '123 abc' << '-44' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '123 abc' << '1.2' --- -int(0) +int(246) --- testing: '123 abc' << '-7.7' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '123 abc' << 'abc' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: '123 abc' << '123abc' --- int(0) --- testing: '123 abc' << '123e5' --- @@ -328,21 +328,21 @@ int(0) --- testing: '123 abc' << '123abc ' --- int(0) --- testing: '123 abc' << '3.4a' --- -int(0) +int(984) --- testing: '123 abc' << 'a5.9' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: '123abc ' << '0' --- -int(0) +int(123) --- testing: '123abc ' << '65' --- int(0) --- testing: '123abc ' << '-44' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '123abc ' << '1.2' --- -int(0) +int(246) --- testing: '123abc ' << '-7.7' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '123abc ' << 'abc' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: '123abc ' << '123abc' --- int(0) --- testing: '123abc ' << '123e5' --- @@ -356,21 +356,21 @@ int(0) --- testing: '123abc ' << '123abc ' --- int(0) --- testing: '123abc ' << '3.4a' --- -int(0) +int(984) --- testing: '123abc ' << 'a5.9' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: '3.4a' << '0' --- -int(0) +int(3) --- testing: '3.4a' << '65' --- int(0) --- testing: '3.4a' << '-44' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '3.4a' << '1.2' --- -int(0) +int(6) --- testing: '3.4a' << '-7.7' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '3.4a' << 'abc' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: '3.4a' << '123abc' --- int(0) --- testing: '3.4a' << '123e5' --- @@ -384,34 +384,34 @@ int(0) --- testing: '3.4a' << '123abc ' --- int(0) --- testing: '3.4a' << '3.4a' --- -int(0) +int(24) --- testing: '3.4a' << 'a5.9' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'a5.9' << '0' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'a5.9' << '65' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'a5.9' << '-44' --- -Exception: Bit shift by negative number +TypeError: Unsupported operand types: string << string --- testing: 'a5.9' << '1.2' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'a5.9' << '-7.7' --- -Exception: Bit shift by negative number +TypeError: Unsupported operand types: string << string --- testing: 'a5.9' << 'abc' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'a5.9' << '123abc' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'a5.9' << '123e5' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'a5.9' << '123e5xyz' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'a5.9' << ' 123abc' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'a5.9' << '123 abc' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'a5.9' << '123abc ' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'a5.9' << '3.4a' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'a5.9' << 'a5.9' --- -int(0) +TypeError: Unsupported operand types: string << string diff --git a/tests/lang/operators/bitwiseShiftLeft_variationStr_64bit.phpt b/tests/lang/operators/bitwiseShiftLeft_variationStr_64bit.phpt index 709ff1b906e89..c3e7af98928a1 100644 --- a/tests/lang/operators/bitwiseShiftLeft_variationStr_64bit.phpt +++ b/tests/lang/operators/bitwiseShiftLeft_variationStr_64bit.phpt @@ -19,8 +19,8 @@ foreach ($strVals as $strVal) { echo "--- testing: '$strVal' << '$otherVal' ---\n"; try { var_dump($strVal<<$otherVal); - } catch (ArithmeticError $e) { - echo "Exception: " . $e->getMessage() . "\n"; + } catch (\Throwable $e) { + echo get_class($e) . ': ' . $e->getMessage() . "\n"; } } } @@ -33,13 +33,13 @@ int(0) --- testing: '0' << '65' --- int(0) --- testing: '0' << '-44' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '0' << '1.2' --- int(0) --- testing: '0' << '-7.7' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '0' << 'abc' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: '0' << '123abc' --- int(0) --- testing: '0' << '123e5' --- @@ -55,159 +55,159 @@ int(0) --- testing: '0' << '3.4a' --- int(0) --- testing: '0' << 'a5.9' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: '65' << '0' --- int(65) --- testing: '65' << '65' --- int(0) --- testing: '65' << '-44' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '65' << '1.2' --- int(130) --- testing: '65' << '-7.7' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '65' << 'abc' --- -int(65) +TypeError: Unsupported operand types: string << string --- testing: '65' << '123abc' --- -int(65) +int(0) --- testing: '65' << '123e5' --- int(0) --- testing: '65' << '123e5xyz' --- -int(65) +int(0) --- testing: '65' << ' 123abc' --- -int(65) +int(0) --- testing: '65' << '123 abc' --- -int(65) +int(0) --- testing: '65' << '123abc ' --- -int(65) +int(0) --- testing: '65' << '3.4a' --- -int(65) +int(520) --- testing: '65' << 'a5.9' --- -int(65) +TypeError: Unsupported operand types: string << string --- testing: '-44' << '0' --- int(-44) --- testing: '-44' << '65' --- int(0) --- testing: '-44' << '-44' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '-44' << '1.2' --- int(-88) --- testing: '-44' << '-7.7' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '-44' << 'abc' --- -int(-44) +TypeError: Unsupported operand types: string << string --- testing: '-44' << '123abc' --- -int(-44) +int(0) --- testing: '-44' << '123e5' --- int(0) --- testing: '-44' << '123e5xyz' --- -int(-44) +int(0) --- testing: '-44' << ' 123abc' --- -int(-44) +int(0) --- testing: '-44' << '123 abc' --- -int(-44) +int(0) --- testing: '-44' << '123abc ' --- -int(-44) +int(0) --- testing: '-44' << '3.4a' --- -int(-44) +int(-352) --- testing: '-44' << 'a5.9' --- -int(-44) +TypeError: Unsupported operand types: string << string --- testing: '1.2' << '0' --- int(1) --- testing: '1.2' << '65' --- int(0) --- testing: '1.2' << '-44' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '1.2' << '1.2' --- int(2) --- testing: '1.2' << '-7.7' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '1.2' << 'abc' --- -int(1) +TypeError: Unsupported operand types: string << string --- testing: '1.2' << '123abc' --- -int(1) +int(0) --- testing: '1.2' << '123e5' --- int(0) --- testing: '1.2' << '123e5xyz' --- -int(1) +int(0) --- testing: '1.2' << ' 123abc' --- -int(1) +int(0) --- testing: '1.2' << '123 abc' --- -int(1) +int(0) --- testing: '1.2' << '123abc ' --- -int(1) +int(0) --- testing: '1.2' << '3.4a' --- -int(1) +int(8) --- testing: '1.2' << 'a5.9' --- -int(1) +TypeError: Unsupported operand types: string << string --- testing: '-7.7' << '0' --- int(-7) --- testing: '-7.7' << '65' --- int(0) --- testing: '-7.7' << '-44' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '-7.7' << '1.2' --- int(-14) --- testing: '-7.7' << '-7.7' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '-7.7' << 'abc' --- -int(-7) +TypeError: Unsupported operand types: string << string --- testing: '-7.7' << '123abc' --- -int(-7) +int(0) --- testing: '-7.7' << '123e5' --- int(0) --- testing: '-7.7' << '123e5xyz' --- -int(-7) +int(0) --- testing: '-7.7' << ' 123abc' --- -int(-7) +int(0) --- testing: '-7.7' << '123 abc' --- -int(-7) +int(0) --- testing: '-7.7' << '123abc ' --- -int(-7) +int(0) --- testing: '-7.7' << '3.4a' --- -int(-7) +int(-56) --- testing: '-7.7' << 'a5.9' --- -int(-7) +TypeError: Unsupported operand types: string << string --- testing: 'abc' << '0' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'abc' << '65' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'abc' << '-44' --- -Exception: Bit shift by negative number +TypeError: Unsupported operand types: string << string --- testing: 'abc' << '1.2' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'abc' << '-7.7' --- -Exception: Bit shift by negative number +TypeError: Unsupported operand types: string << string --- testing: 'abc' << 'abc' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'abc' << '123abc' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'abc' << '123e5' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'abc' << '123e5xyz' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'abc' << ' 123abc' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'abc' << '123 abc' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'abc' << '123abc ' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'abc' << '3.4a' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'abc' << 'a5.9' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: '123abc' << '0' --- -int(0) +int(123) --- testing: '123abc' << '65' --- int(0) --- testing: '123abc' << '-44' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '123abc' << '1.2' --- -int(0) +int(246) --- testing: '123abc' << '-7.7' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '123abc' << 'abc' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: '123abc' << '123abc' --- int(0) --- testing: '123abc' << '123e5' --- @@ -221,49 +221,49 @@ int(0) --- testing: '123abc' << '123abc ' --- int(0) --- testing: '123abc' << '3.4a' --- -int(0) +int(984) --- testing: '123abc' << 'a5.9' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: '123e5' << '0' --- int(12300000) --- testing: '123e5' << '65' --- int(0) --- testing: '123e5' << '-44' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '123e5' << '1.2' --- int(24600000) --- testing: '123e5' << '-7.7' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '123e5' << 'abc' --- -int(12300000) +TypeError: Unsupported operand types: string << string --- testing: '123e5' << '123abc' --- -int(12300000) +int(0) --- testing: '123e5' << '123e5' --- int(0) --- testing: '123e5' << '123e5xyz' --- -int(12300000) +int(0) --- testing: '123e5' << ' 123abc' --- -int(12300000) +int(0) --- testing: '123e5' << '123 abc' --- -int(12300000) +int(0) --- testing: '123e5' << '123abc ' --- -int(12300000) +int(0) --- testing: '123e5' << '3.4a' --- -int(12300000) +int(98400000) --- testing: '123e5' << 'a5.9' --- -int(12300000) +TypeError: Unsupported operand types: string << string --- testing: '123e5xyz' << '0' --- -int(0) +int(12300000) --- testing: '123e5xyz' << '65' --- int(0) --- testing: '123e5xyz' << '-44' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '123e5xyz' << '1.2' --- -int(0) +int(24600000) --- testing: '123e5xyz' << '-7.7' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '123e5xyz' << 'abc' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: '123e5xyz' << '123abc' --- int(0) --- testing: '123e5xyz' << '123e5' --- @@ -277,21 +277,21 @@ int(0) --- testing: '123e5xyz' << '123abc ' --- int(0) --- testing: '123e5xyz' << '3.4a' --- -int(0) +int(98400000) --- testing: '123e5xyz' << 'a5.9' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: ' 123abc' << '0' --- -int(0) +int(123) --- testing: ' 123abc' << '65' --- int(0) --- testing: ' 123abc' << '-44' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: ' 123abc' << '1.2' --- -int(0) +int(246) --- testing: ' 123abc' << '-7.7' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: ' 123abc' << 'abc' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: ' 123abc' << '123abc' --- int(0) --- testing: ' 123abc' << '123e5' --- @@ -305,21 +305,21 @@ int(0) --- testing: ' 123abc' << '123abc ' --- int(0) --- testing: ' 123abc' << '3.4a' --- -int(0) +int(984) --- testing: ' 123abc' << 'a5.9' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: '123 abc' << '0' --- -int(0) +int(123) --- testing: '123 abc' << '65' --- int(0) --- testing: '123 abc' << '-44' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '123 abc' << '1.2' --- -int(0) +int(246) --- testing: '123 abc' << '-7.7' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '123 abc' << 'abc' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: '123 abc' << '123abc' --- int(0) --- testing: '123 abc' << '123e5' --- @@ -333,21 +333,21 @@ int(0) --- testing: '123 abc' << '123abc ' --- int(0) --- testing: '123 abc' << '3.4a' --- -int(0) +int(984) --- testing: '123 abc' << 'a5.9' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: '123abc ' << '0' --- -int(0) +int(123) --- testing: '123abc ' << '65' --- int(0) --- testing: '123abc ' << '-44' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '123abc ' << '1.2' --- -int(0) +int(246) --- testing: '123abc ' << '-7.7' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '123abc ' << 'abc' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: '123abc ' << '123abc' --- int(0) --- testing: '123abc ' << '123e5' --- @@ -361,21 +361,21 @@ int(0) --- testing: '123abc ' << '123abc ' --- int(0) --- testing: '123abc ' << '3.4a' --- -int(0) +int(984) --- testing: '123abc ' << 'a5.9' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: '3.4a' << '0' --- -int(0) +int(3) --- testing: '3.4a' << '65' --- int(0) --- testing: '3.4a' << '-44' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '3.4a' << '1.2' --- -int(0) +int(6) --- testing: '3.4a' << '-7.7' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '3.4a' << 'abc' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: '3.4a' << '123abc' --- int(0) --- testing: '3.4a' << '123e5' --- @@ -389,34 +389,34 @@ int(0) --- testing: '3.4a' << '123abc ' --- int(0) --- testing: '3.4a' << '3.4a' --- -int(0) +int(24) --- testing: '3.4a' << 'a5.9' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'a5.9' << '0' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'a5.9' << '65' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'a5.9' << '-44' --- -Exception: Bit shift by negative number +TypeError: Unsupported operand types: string << string --- testing: 'a5.9' << '1.2' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'a5.9' << '-7.7' --- -Exception: Bit shift by negative number +TypeError: Unsupported operand types: string << string --- testing: 'a5.9' << 'abc' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'a5.9' << '123abc' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'a5.9' << '123e5' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'a5.9' << '123e5xyz' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'a5.9' << ' 123abc' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'a5.9' << '123 abc' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'a5.9' << '123abc ' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'a5.9' << '3.4a' --- -int(0) +TypeError: Unsupported operand types: string << string --- testing: 'a5.9' << 'a5.9' --- -int(0) +TypeError: Unsupported operand types: string << string diff --git a/tests/lang/operators/bitwiseShiftRight_variationStr.phpt b/tests/lang/operators/bitwiseShiftRight_variationStr.phpt index 5e08979e84f2f..d1f124933c853 100644 --- a/tests/lang/operators/bitwiseShiftRight_variationStr.phpt +++ b/tests/lang/operators/bitwiseShiftRight_variationStr.phpt @@ -15,8 +15,8 @@ foreach ($strVals as $strVal) { echo "--- testing: '$strVal' >> '$otherVal' ---\n"; try { var_dump($strVal>>$otherVal); - } catch (ArithmeticError $e) { - echo "Exception: " . $e->getMessage() . "\n"; + } catch (\Throwable $e) { + echo get_class($e) . ': ' . $e->getMessage() . "\n"; } } } @@ -29,13 +29,13 @@ int(0) --- testing: '0' >> '65' --- int(0) --- testing: '0' >> '-44' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '0' >> '1.2' --- int(0) --- testing: '0' >> '-7.7' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '0' >> 'abc' --- -int(0) +TypeError: Unsupported operand types: string >> string --- testing: '0' >> '123abc' --- int(0) --- testing: '0' >> '123e5' --- @@ -51,159 +51,159 @@ int(0) --- testing: '0' >> '3.4a' --- int(0) --- testing: '0' >> 'a5.9' --- -int(0) +TypeError: Unsupported operand types: string >> string --- testing: '65' >> '0' --- int(65) --- testing: '65' >> '65' --- int(0) --- testing: '65' >> '-44' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '65' >> '1.2' --- int(32) --- testing: '65' >> '-7.7' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '65' >> 'abc' --- -int(65) +TypeError: Unsupported operand types: string >> string --- testing: '65' >> '123abc' --- -int(65) +int(0) --- testing: '65' >> '123e5' --- int(0) --- testing: '65' >> '123e5xyz' --- -int(65) +int(0) --- testing: '65' >> ' 123abc' --- -int(65) +int(0) --- testing: '65' >> '123 abc' --- -int(65) +int(0) --- testing: '65' >> '123abc ' --- -int(65) +int(0) --- testing: '65' >> '3.4a' --- -int(65) +int(8) --- testing: '65' >> 'a5.9' --- -int(65) +TypeError: Unsupported operand types: string >> string --- testing: '-44' >> '0' --- int(-44) --- testing: '-44' >> '65' --- int(-1) --- testing: '-44' >> '-44' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '-44' >> '1.2' --- int(-22) --- testing: '-44' >> '-7.7' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '-44' >> 'abc' --- -int(-44) +TypeError: Unsupported operand types: string >> string --- testing: '-44' >> '123abc' --- -int(-44) +int(-1) --- testing: '-44' >> '123e5' --- int(-1) --- testing: '-44' >> '123e5xyz' --- -int(-44) +int(-1) --- testing: '-44' >> ' 123abc' --- -int(-44) +int(-1) --- testing: '-44' >> '123 abc' --- -int(-44) +int(-1) --- testing: '-44' >> '123abc ' --- -int(-44) +int(-1) --- testing: '-44' >> '3.4a' --- -int(-44) +int(-6) --- testing: '-44' >> 'a5.9' --- -int(-44) +TypeError: Unsupported operand types: string >> string --- testing: '1.2' >> '0' --- int(1) --- testing: '1.2' >> '65' --- int(0) --- testing: '1.2' >> '-44' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '1.2' >> '1.2' --- int(0) --- testing: '1.2' >> '-7.7' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '1.2' >> 'abc' --- -int(1) +TypeError: Unsupported operand types: string >> string --- testing: '1.2' >> '123abc' --- -int(1) +int(0) --- testing: '1.2' >> '123e5' --- int(0) --- testing: '1.2' >> '123e5xyz' --- -int(1) +int(0) --- testing: '1.2' >> ' 123abc' --- -int(1) +int(0) --- testing: '1.2' >> '123 abc' --- -int(1) +int(0) --- testing: '1.2' >> '123abc ' --- -int(1) +int(0) --- testing: '1.2' >> '3.4a' --- -int(1) +int(0) --- testing: '1.2' >> 'a5.9' --- -int(1) +TypeError: Unsupported operand types: string >> string --- testing: '-7.7' >> '0' --- int(-7) --- testing: '-7.7' >> '65' --- int(-1) --- testing: '-7.7' >> '-44' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '-7.7' >> '1.2' --- int(-4) --- testing: '-7.7' >> '-7.7' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '-7.7' >> 'abc' --- -int(-7) +TypeError: Unsupported operand types: string >> string --- testing: '-7.7' >> '123abc' --- -int(-7) +int(-1) --- testing: '-7.7' >> '123e5' --- int(-1) --- testing: '-7.7' >> '123e5xyz' --- -int(-7) +int(-1) --- testing: '-7.7' >> ' 123abc' --- -int(-7) +int(-1) --- testing: '-7.7' >> '123 abc' --- -int(-7) +int(-1) --- testing: '-7.7' >> '123abc ' --- -int(-7) +int(-1) --- testing: '-7.7' >> '3.4a' --- -int(-7) +int(-1) --- testing: '-7.7' >> 'a5.9' --- -int(-7) +TypeError: Unsupported operand types: string >> string --- testing: 'abc' >> '0' --- -int(0) +TypeError: Unsupported operand types: string >> string --- testing: 'abc' >> '65' --- -int(0) +TypeError: Unsupported operand types: string >> string --- testing: 'abc' >> '-44' --- -Exception: Bit shift by negative number +TypeError: Unsupported operand types: string >> string --- testing: 'abc' >> '1.2' --- -int(0) +TypeError: Unsupported operand types: string >> string --- testing: 'abc' >> '-7.7' --- -Exception: Bit shift by negative number +TypeError: Unsupported operand types: string >> string --- testing: 'abc' >> 'abc' --- -int(0) +TypeError: Unsupported operand types: string >> string --- testing: 'abc' >> '123abc' --- -int(0) +TypeError: Unsupported operand types: string >> string --- testing: 'abc' >> '123e5' --- -int(0) +TypeError: Unsupported operand types: string >> string --- testing: 'abc' >> '123e5xyz' --- -int(0) +TypeError: Unsupported operand types: string >> string --- testing: 'abc' >> ' 123abc' --- -int(0) +TypeError: Unsupported operand types: string >> string --- testing: 'abc' >> '123 abc' --- -int(0) +TypeError: Unsupported operand types: string >> string --- testing: 'abc' >> '123abc ' --- -int(0) +TypeError: Unsupported operand types: string >> string --- testing: 'abc' >> '3.4a' --- -int(0) +TypeError: Unsupported operand types: string >> string --- testing: 'abc' >> 'a5.9' --- -int(0) +TypeError: Unsupported operand types: string >> string --- testing: '123abc' >> '0' --- -int(0) +int(123) --- testing: '123abc' >> '65' --- int(0) --- testing: '123abc' >> '-44' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '123abc' >> '1.2' --- -int(0) +int(61) --- testing: '123abc' >> '-7.7' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '123abc' >> 'abc' --- -int(0) +TypeError: Unsupported operand types: string >> string --- testing: '123abc' >> '123abc' --- int(0) --- testing: '123abc' >> '123e5' --- @@ -217,49 +217,49 @@ int(0) --- testing: '123abc' >> '123abc ' --- int(0) --- testing: '123abc' >> '3.4a' --- -int(0) +int(15) --- testing: '123abc' >> 'a5.9' --- -int(0) +TypeError: Unsupported operand types: string >> string --- testing: '123e5' >> '0' --- int(12300000) --- testing: '123e5' >> '65' --- int(0) --- testing: '123e5' >> '-44' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '123e5' >> '1.2' --- int(6150000) --- testing: '123e5' >> '-7.7' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '123e5' >> 'abc' --- -int(12300000) +TypeError: Unsupported operand types: string >> string --- testing: '123e5' >> '123abc' --- -int(12300000) +int(0) --- testing: '123e5' >> '123e5' --- int(0) --- testing: '123e5' >> '123e5xyz' --- -int(12300000) +int(0) --- testing: '123e5' >> ' 123abc' --- -int(12300000) +int(0) --- testing: '123e5' >> '123 abc' --- -int(12300000) +int(0) --- testing: '123e5' >> '123abc ' --- -int(12300000) +int(0) --- testing: '123e5' >> '3.4a' --- -int(12300000) +int(1537500) --- testing: '123e5' >> 'a5.9' --- -int(12300000) +TypeError: Unsupported operand types: string >> string --- testing: '123e5xyz' >> '0' --- -int(0) +int(12300000) --- testing: '123e5xyz' >> '65' --- int(0) --- testing: '123e5xyz' >> '-44' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '123e5xyz' >> '1.2' --- -int(0) +int(6150000) --- testing: '123e5xyz' >> '-7.7' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '123e5xyz' >> 'abc' --- -int(0) +TypeError: Unsupported operand types: string >> string --- testing: '123e5xyz' >> '123abc' --- int(0) --- testing: '123e5xyz' >> '123e5' --- @@ -273,21 +273,21 @@ int(0) --- testing: '123e5xyz' >> '123abc ' --- int(0) --- testing: '123e5xyz' >> '3.4a' --- -int(0) +int(1537500) --- testing: '123e5xyz' >> 'a5.9' --- -int(0) +TypeError: Unsupported operand types: string >> string --- testing: ' 123abc' >> '0' --- -int(0) +int(123) --- testing: ' 123abc' >> '65' --- int(0) --- testing: ' 123abc' >> '-44' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: ' 123abc' >> '1.2' --- -int(0) +int(61) --- testing: ' 123abc' >> '-7.7' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: ' 123abc' >> 'abc' --- -int(0) +TypeError: Unsupported operand types: string >> string --- testing: ' 123abc' >> '123abc' --- int(0) --- testing: ' 123abc' >> '123e5' --- @@ -301,21 +301,21 @@ int(0) --- testing: ' 123abc' >> '123abc ' --- int(0) --- testing: ' 123abc' >> '3.4a' --- -int(0) +int(15) --- testing: ' 123abc' >> 'a5.9' --- -int(0) +TypeError: Unsupported operand types: string >> string --- testing: '123 abc' >> '0' --- -int(0) +int(123) --- testing: '123 abc' >> '65' --- int(0) --- testing: '123 abc' >> '-44' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '123 abc' >> '1.2' --- -int(0) +int(61) --- testing: '123 abc' >> '-7.7' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '123 abc' >> 'abc' --- -int(0) +TypeError: Unsupported operand types: string >> string --- testing: '123 abc' >> '123abc' --- int(0) --- testing: '123 abc' >> '123e5' --- @@ -329,21 +329,21 @@ int(0) --- testing: '123 abc' >> '123abc ' --- int(0) --- testing: '123 abc' >> '3.4a' --- -int(0) +int(15) --- testing: '123 abc' >> 'a5.9' --- -int(0) +TypeError: Unsupported operand types: string >> string --- testing: '123abc ' >> '0' --- -int(0) +int(123) --- testing: '123abc ' >> '65' --- int(0) --- testing: '123abc ' >> '-44' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '123abc ' >> '1.2' --- -int(0) +int(61) --- testing: '123abc ' >> '-7.7' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '123abc ' >> 'abc' --- -int(0) +TypeError: Unsupported operand types: string >> string --- testing: '123abc ' >> '123abc' --- int(0) --- testing: '123abc ' >> '123e5' --- @@ -357,21 +357,21 @@ int(0) --- testing: '123abc ' >> '123abc ' --- int(0) --- testing: '123abc ' >> '3.4a' --- -int(0) +int(15) --- testing: '123abc ' >> 'a5.9' --- -int(0) +TypeError: Unsupported operand types: string >> string --- testing: '3.4a' >> '0' --- -int(0) +int(3) --- testing: '3.4a' >> '65' --- int(0) --- testing: '3.4a' >> '-44' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '3.4a' >> '1.2' --- -int(0) +int(1) --- testing: '3.4a' >> '-7.7' --- -Exception: Bit shift by negative number +ArithmeticError: Bit shift by negative number --- testing: '3.4a' >> 'abc' --- -int(0) +TypeError: Unsupported operand types: string >> string --- testing: '3.4a' >> '123abc' --- int(0) --- testing: '3.4a' >> '123e5' --- @@ -387,32 +387,32 @@ int(0) --- testing: '3.4a' >> '3.4a' --- int(0) --- testing: '3.4a' >> 'a5.9' --- -int(0) +TypeError: Unsupported operand types: string >> string --- testing: 'a5.9' >> '0' --- -int(0) +TypeError: Unsupported operand types: string >> string --- testing: 'a5.9' >> '65' --- -int(0) +TypeError: Unsupported operand types: string >> string --- testing: 'a5.9' >> '-44' --- -Exception: Bit shift by negative number +TypeError: Unsupported operand types: string >> string --- testing: 'a5.9' >> '1.2' --- -int(0) +TypeError: Unsupported operand types: string >> string --- testing: 'a5.9' >> '-7.7' --- -Exception: Bit shift by negative number +TypeError: Unsupported operand types: string >> string --- testing: 'a5.9' >> 'abc' --- -int(0) +TypeError: Unsupported operand types: string >> string --- testing: 'a5.9' >> '123abc' --- -int(0) +TypeError: Unsupported operand types: string >> string --- testing: 'a5.9' >> '123e5' --- -int(0) +TypeError: Unsupported operand types: string >> string --- testing: 'a5.9' >> '123e5xyz' --- -int(0) +TypeError: Unsupported operand types: string >> string --- testing: 'a5.9' >> ' 123abc' --- -int(0) +TypeError: Unsupported operand types: string >> string --- testing: 'a5.9' >> '123 abc' --- -int(0) +TypeError: Unsupported operand types: string >> string --- testing: 'a5.9' >> '123abc ' --- -int(0) +TypeError: Unsupported operand types: string >> string --- testing: 'a5.9' >> '3.4a' --- -int(0) +TypeError: Unsupported operand types: string >> string --- testing: 'a5.9' >> 'a5.9' --- -int(0) +TypeError: Unsupported operand types: string >> string diff --git a/tests/lang/operators/divide_variationStr.phpt b/tests/lang/operators/divide_variationStr.phpt index 7c0c0ff6be005..be7118edbda4f 100644 --- a/tests/lang/operators/divide_variationStr.phpt +++ b/tests/lang/operators/divide_variationStr.phpt @@ -11,404 +11,408 @@ $strVals = array( error_reporting(E_ERROR); foreach ($strVals as $strVal) { - foreach($strVals as $otherVal) { - echo "--- testing: '$strVal' / '$otherVal' ---\n"; - var_dump($strVal/$otherVal); - } + foreach($strVals as $otherVal) { + echo "--- testing: '$strVal'/'$otherVal' ---\n"; + try { + var_dump($strVal/$otherVal); + } catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; + } + } } ?> --EXPECT-- ---- testing: '0' / '0' --- +--- testing: '0'/'0' --- float(NAN) ---- testing: '0' / '65' --- +--- testing: '0'/'65' --- int(0) ---- testing: '0' / '-44' --- +--- testing: '0'/'-44' --- int(0) ---- testing: '0' / '1.2' --- +--- testing: '0'/'1.2' --- float(0) ---- testing: '0' / '-7.7' --- +--- testing: '0'/'-7.7' --- float(-0) ---- testing: '0' / 'abc' --- -float(NAN) ---- testing: '0' / '123abc' --- -float(NAN) ---- testing: '0' / '123e5' --- +--- testing: '0'/'abc' --- +Unsupported operand types: string / string +--- testing: '0'/'123abc' --- +int(0) +--- testing: '0'/'123e5' --- float(0) ---- testing: '0' / '123e5xyz' --- -float(NAN) ---- testing: '0' / ' 123abc' --- -float(NAN) ---- testing: '0' / '123 abc' --- -float(NAN) ---- testing: '0' / '123abc ' --- -float(NAN) ---- testing: '0' / '3.4a' --- -float(NAN) ---- testing: '0' / 'a5.9' --- -float(NAN) ---- testing: '65' / '0' --- +--- testing: '0'/'123e5xyz' --- +float(0) +--- testing: '0'/' 123abc' --- +int(0) +--- testing: '0'/'123 abc' --- +int(0) +--- testing: '0'/'123abc ' --- +int(0) +--- testing: '0'/'3.4a' --- +float(0) +--- testing: '0'/'a5.9' --- +Unsupported operand types: string / string +--- testing: '65'/'0' --- float(INF) ---- testing: '65' / '65' --- +--- testing: '65'/'65' --- int(1) ---- testing: '65' / '-44' --- +--- testing: '65'/'-44' --- float(-1.4772727272727273) ---- testing: '65' / '1.2' --- +--- testing: '65'/'1.2' --- float(54.16666666666667) ---- testing: '65' / '-7.7' --- +--- testing: '65'/'-7.7' --- float(-8.441558441558442) ---- testing: '65' / 'abc' --- -float(INF) ---- testing: '65' / '123abc' --- -float(INF) ---- testing: '65' / '123e5' --- +--- testing: '65'/'abc' --- +Unsupported operand types: string / string +--- testing: '65'/'123abc' --- +float(0.5284552845528455) +--- testing: '65'/'123e5' --- float(5.2845528455284555E-6) ---- testing: '65' / '123e5xyz' --- -float(INF) ---- testing: '65' / ' 123abc' --- -float(INF) ---- testing: '65' / '123 abc' --- -float(INF) ---- testing: '65' / '123abc ' --- -float(INF) ---- testing: '65' / '3.4a' --- -float(INF) ---- testing: '65' / 'a5.9' --- -float(INF) ---- testing: '-44' / '0' --- +--- testing: '65'/'123e5xyz' --- +float(5.2845528455284555E-6) +--- testing: '65'/' 123abc' --- +float(0.5284552845528455) +--- testing: '65'/'123 abc' --- +float(0.5284552845528455) +--- testing: '65'/'123abc ' --- +float(0.5284552845528455) +--- testing: '65'/'3.4a' --- +float(19.11764705882353) +--- testing: '65'/'a5.9' --- +Unsupported operand types: string / string +--- testing: '-44'/'0' --- float(-INF) ---- testing: '-44' / '65' --- +--- testing: '-44'/'65' --- float(-0.676923076923077) ---- testing: '-44' / '-44' --- +--- testing: '-44'/'-44' --- int(1) ---- testing: '-44' / '1.2' --- +--- testing: '-44'/'1.2' --- float(-36.66666666666667) ---- testing: '-44' / '-7.7' --- +--- testing: '-44'/'-7.7' --- float(5.714285714285714) ---- testing: '-44' / 'abc' --- -float(-INF) ---- testing: '-44' / '123abc' --- -float(-INF) ---- testing: '-44' / '123e5' --- +--- testing: '-44'/'abc' --- +Unsupported operand types: string / string +--- testing: '-44'/'123abc' --- +float(-0.35772357723577236) +--- testing: '-44'/'123e5' --- float(-3.5772357723577236E-6) ---- testing: '-44' / '123e5xyz' --- -float(-INF) ---- testing: '-44' / ' 123abc' --- -float(-INF) ---- testing: '-44' / '123 abc' --- -float(-INF) ---- testing: '-44' / '123abc ' --- -float(-INF) ---- testing: '-44' / '3.4a' --- -float(-INF) ---- testing: '-44' / 'a5.9' --- -float(-INF) ---- testing: '1.2' / '0' --- +--- testing: '-44'/'123e5xyz' --- +float(-3.5772357723577236E-6) +--- testing: '-44'/' 123abc' --- +float(-0.35772357723577236) +--- testing: '-44'/'123 abc' --- +float(-0.35772357723577236) +--- testing: '-44'/'123abc ' --- +float(-0.35772357723577236) +--- testing: '-44'/'3.4a' --- +float(-12.941176470588236) +--- testing: '-44'/'a5.9' --- +Unsupported operand types: string / string +--- testing: '1.2'/'0' --- float(INF) ---- testing: '1.2' / '65' --- +--- testing: '1.2'/'65' --- float(0.01846153846153846) ---- testing: '1.2' / '-44' --- +--- testing: '1.2'/'-44' --- float(-0.02727272727272727) ---- testing: '1.2' / '1.2' --- +--- testing: '1.2'/'1.2' --- float(1) ---- testing: '1.2' / '-7.7' --- +--- testing: '1.2'/'-7.7' --- float(-0.15584415584415584) ---- testing: '1.2' / 'abc' --- -float(INF) ---- testing: '1.2' / '123abc' --- -float(INF) ---- testing: '1.2' / '123e5' --- +--- testing: '1.2'/'abc' --- +Unsupported operand types: string / string +--- testing: '1.2'/'123abc' --- +float(0.00975609756097561) +--- testing: '1.2'/'123e5' --- float(9.75609756097561E-8) ---- testing: '1.2' / '123e5xyz' --- -float(INF) ---- testing: '1.2' / ' 123abc' --- -float(INF) ---- testing: '1.2' / '123 abc' --- -float(INF) ---- testing: '1.2' / '123abc ' --- -float(INF) ---- testing: '1.2' / '3.4a' --- -float(INF) ---- testing: '1.2' / 'a5.9' --- -float(INF) ---- testing: '-7.7' / '0' --- +--- testing: '1.2'/'123e5xyz' --- +float(9.75609756097561E-8) +--- testing: '1.2'/' 123abc' --- +float(0.00975609756097561) +--- testing: '1.2'/'123 abc' --- +float(0.00975609756097561) +--- testing: '1.2'/'123abc ' --- +float(0.00975609756097561) +--- testing: '1.2'/'3.4a' --- +float(0.35294117647058826) +--- testing: '1.2'/'a5.9' --- +Unsupported operand types: string / string +--- testing: '-7.7'/'0' --- float(-INF) ---- testing: '-7.7' / '65' --- +--- testing: '-7.7'/'65' --- float(-0.11846153846153847) ---- testing: '-7.7' / '-44' --- +--- testing: '-7.7'/'-44' --- float(0.17500000000000002) ---- testing: '-7.7' / '1.2' --- +--- testing: '-7.7'/'1.2' --- float(-6.416666666666667) ---- testing: '-7.7' / '-7.7' --- +--- testing: '-7.7'/'-7.7' --- float(1) ---- testing: '-7.7' / 'abc' --- -float(-INF) ---- testing: '-7.7' / '123abc' --- -float(-INF) ---- testing: '-7.7' / '123e5' --- +--- testing: '-7.7'/'abc' --- +Unsupported operand types: string / string +--- testing: '-7.7'/'123abc' --- +float(-0.06260162601626017) +--- testing: '-7.7'/'123e5' --- float(-6.260162601626017E-7) ---- testing: '-7.7' / '123e5xyz' --- -float(-INF) ---- testing: '-7.7' / ' 123abc' --- -float(-INF) ---- testing: '-7.7' / '123 abc' --- -float(-INF) ---- testing: '-7.7' / '123abc ' --- -float(-INF) ---- testing: '-7.7' / '3.4a' --- -float(-INF) ---- testing: '-7.7' / 'a5.9' --- -float(-INF) ---- testing: 'abc' / '0' --- -float(NAN) ---- testing: 'abc' / '65' --- -int(0) ---- testing: 'abc' / '-44' --- -int(0) ---- testing: 'abc' / '1.2' --- -float(0) ---- testing: 'abc' / '-7.7' --- -float(-0) ---- testing: 'abc' / 'abc' --- -float(NAN) ---- testing: 'abc' / '123abc' --- -float(NAN) ---- testing: 'abc' / '123e5' --- -float(0) ---- testing: 'abc' / '123e5xyz' --- -float(NAN) ---- testing: 'abc' / ' 123abc' --- -float(NAN) ---- testing: 'abc' / '123 abc' --- -float(NAN) ---- testing: 'abc' / '123abc ' --- -float(NAN) ---- testing: 'abc' / '3.4a' --- -float(NAN) ---- testing: 'abc' / 'a5.9' --- -float(NAN) ---- testing: '123abc' / '0' --- -float(NAN) ---- testing: '123abc' / '65' --- -int(0) ---- testing: '123abc' / '-44' --- -int(0) ---- testing: '123abc' / '1.2' --- -float(0) ---- testing: '123abc' / '-7.7' --- -float(-0) ---- testing: '123abc' / 'abc' --- -float(NAN) ---- testing: '123abc' / '123abc' --- -float(NAN) ---- testing: '123abc' / '123e5' --- -float(0) ---- testing: '123abc' / '123e5xyz' --- -float(NAN) ---- testing: '123abc' / ' 123abc' --- -float(NAN) ---- testing: '123abc' / '123 abc' --- -float(NAN) ---- testing: '123abc' / '123abc ' --- -float(NAN) ---- testing: '123abc' / '3.4a' --- -float(NAN) ---- testing: '123abc' / 'a5.9' --- -float(NAN) ---- testing: '123e5' / '0' --- +--- testing: '-7.7'/'123e5xyz' --- +float(-6.260162601626017E-7) +--- testing: '-7.7'/' 123abc' --- +float(-0.06260162601626017) +--- testing: '-7.7'/'123 abc' --- +float(-0.06260162601626017) +--- testing: '-7.7'/'123abc ' --- +float(-0.06260162601626017) +--- testing: '-7.7'/'3.4a' --- +float(-2.264705882352941) +--- testing: '-7.7'/'a5.9' --- +Unsupported operand types: string / string +--- testing: 'abc'/'0' --- +Unsupported operand types: string / string +--- testing: 'abc'/'65' --- +Unsupported operand types: string / string +--- testing: 'abc'/'-44' --- +Unsupported operand types: string / string +--- testing: 'abc'/'1.2' --- +Unsupported operand types: string / string +--- testing: 'abc'/'-7.7' --- +Unsupported operand types: string / string +--- testing: 'abc'/'abc' --- +Unsupported operand types: string / string +--- testing: 'abc'/'123abc' --- +Unsupported operand types: string / string +--- testing: 'abc'/'123e5' --- +Unsupported operand types: string / string +--- testing: 'abc'/'123e5xyz' --- +Unsupported operand types: string / string +--- testing: 'abc'/' 123abc' --- +Unsupported operand types: string / string +--- testing: 'abc'/'123 abc' --- +Unsupported operand types: string / string +--- testing: 'abc'/'123abc ' --- +Unsupported operand types: string / string +--- testing: 'abc'/'3.4a' --- +Unsupported operand types: string / string +--- testing: 'abc'/'a5.9' --- +Unsupported operand types: string / string +--- testing: '123abc'/'0' --- float(INF) ---- testing: '123e5' / '65' --- +--- testing: '123abc'/'65' --- +float(1.8923076923076922) +--- testing: '123abc'/'-44' --- +float(-2.7954545454545454) +--- testing: '123abc'/'1.2' --- +float(102.5) +--- testing: '123abc'/'-7.7' --- +float(-15.974025974025974) +--- testing: '123abc'/'abc' --- +Unsupported operand types: string / string +--- testing: '123abc'/'123abc' --- +int(1) +--- testing: '123abc'/'123e5' --- +float(1.0E-5) +--- testing: '123abc'/'123e5xyz' --- +float(1.0E-5) +--- testing: '123abc'/' 123abc' --- +int(1) +--- testing: '123abc'/'123 abc' --- +int(1) +--- testing: '123abc'/'123abc ' --- +int(1) +--- testing: '123abc'/'3.4a' --- +float(36.1764705882353) +--- testing: '123abc'/'a5.9' --- +Unsupported operand types: string / string +--- testing: '123e5'/'0' --- +float(INF) +--- testing: '123e5'/'65' --- float(189230.76923076922) ---- testing: '123e5' / '-44' --- +--- testing: '123e5'/'-44' --- float(-279545.45454545453) ---- testing: '123e5' / '1.2' --- +--- testing: '123e5'/'1.2' --- float(10250000) ---- testing: '123e5' / '-7.7' --- +--- testing: '123e5'/'-7.7' --- float(-1597402.5974025973) ---- testing: '123e5' / 'abc' --- -float(INF) ---- testing: '123e5' / '123abc' --- -float(INF) ---- testing: '123e5' / '123e5' --- +--- testing: '123e5'/'abc' --- +Unsupported operand types: string / string +--- testing: '123e5'/'123abc' --- +float(100000) +--- testing: '123e5'/'123e5' --- float(1) ---- testing: '123e5' / '123e5xyz' --- -float(INF) ---- testing: '123e5' / ' 123abc' --- +--- testing: '123e5'/'123e5xyz' --- +float(1) +--- testing: '123e5'/' 123abc' --- +float(100000) +--- testing: '123e5'/'123 abc' --- +float(100000) +--- testing: '123e5'/'123abc ' --- +float(100000) +--- testing: '123e5'/'3.4a' --- +float(3617647.0588235296) +--- testing: '123e5'/'a5.9' --- +Unsupported operand types: string / string +--- testing: '123e5xyz'/'0' --- float(INF) ---- testing: '123e5' / '123 abc' --- +--- testing: '123e5xyz'/'65' --- +float(189230.76923076922) +--- testing: '123e5xyz'/'-44' --- +float(-279545.45454545453) +--- testing: '123e5xyz'/'1.2' --- +float(10250000) +--- testing: '123e5xyz'/'-7.7' --- +float(-1597402.5974025973) +--- testing: '123e5xyz'/'abc' --- +Unsupported operand types: string / string +--- testing: '123e5xyz'/'123abc' --- +float(100000) +--- testing: '123e5xyz'/'123e5' --- +float(1) +--- testing: '123e5xyz'/'123e5xyz' --- +float(1) +--- testing: '123e5xyz'/' 123abc' --- +float(100000) +--- testing: '123e5xyz'/'123 abc' --- +float(100000) +--- testing: '123e5xyz'/'123abc ' --- +float(100000) +--- testing: '123e5xyz'/'3.4a' --- +float(3617647.0588235296) +--- testing: '123e5xyz'/'a5.9' --- +Unsupported operand types: string / string +--- testing: ' 123abc'/'0' --- float(INF) ---- testing: '123e5' / '123abc ' --- +--- testing: ' 123abc'/'65' --- +float(1.8923076923076922) +--- testing: ' 123abc'/'-44' --- +float(-2.7954545454545454) +--- testing: ' 123abc'/'1.2' --- +float(102.5) +--- testing: ' 123abc'/'-7.7' --- +float(-15.974025974025974) +--- testing: ' 123abc'/'abc' --- +Unsupported operand types: string / string +--- testing: ' 123abc'/'123abc' --- +int(1) +--- testing: ' 123abc'/'123e5' --- +float(1.0E-5) +--- testing: ' 123abc'/'123e5xyz' --- +float(1.0E-5) +--- testing: ' 123abc'/' 123abc' --- +int(1) +--- testing: ' 123abc'/'123 abc' --- +int(1) +--- testing: ' 123abc'/'123abc ' --- +int(1) +--- testing: ' 123abc'/'3.4a' --- +float(36.1764705882353) +--- testing: ' 123abc'/'a5.9' --- +Unsupported operand types: string / string +--- testing: '123 abc'/'0' --- float(INF) ---- testing: '123e5' / '3.4a' --- +--- testing: '123 abc'/'65' --- +float(1.8923076923076922) +--- testing: '123 abc'/'-44' --- +float(-2.7954545454545454) +--- testing: '123 abc'/'1.2' --- +float(102.5) +--- testing: '123 abc'/'-7.7' --- +float(-15.974025974025974) +--- testing: '123 abc'/'abc' --- +Unsupported operand types: string / string +--- testing: '123 abc'/'123abc' --- +int(1) +--- testing: '123 abc'/'123e5' --- +float(1.0E-5) +--- testing: '123 abc'/'123e5xyz' --- +float(1.0E-5) +--- testing: '123 abc'/' 123abc' --- +int(1) +--- testing: '123 abc'/'123 abc' --- +int(1) +--- testing: '123 abc'/'123abc ' --- +int(1) +--- testing: '123 abc'/'3.4a' --- +float(36.1764705882353) +--- testing: '123 abc'/'a5.9' --- +Unsupported operand types: string / string +--- testing: '123abc '/'0' --- float(INF) ---- testing: '123e5' / 'a5.9' --- +--- testing: '123abc '/'65' --- +float(1.8923076923076922) +--- testing: '123abc '/'-44' --- +float(-2.7954545454545454) +--- testing: '123abc '/'1.2' --- +float(102.5) +--- testing: '123abc '/'-7.7' --- +float(-15.974025974025974) +--- testing: '123abc '/'abc' --- +Unsupported operand types: string / string +--- testing: '123abc '/'123abc' --- +int(1) +--- testing: '123abc '/'123e5' --- +float(1.0E-5) +--- testing: '123abc '/'123e5xyz' --- +float(1.0E-5) +--- testing: '123abc '/' 123abc' --- +int(1) +--- testing: '123abc '/'123 abc' --- +int(1) +--- testing: '123abc '/'123abc ' --- +int(1) +--- testing: '123abc '/'3.4a' --- +float(36.1764705882353) +--- testing: '123abc '/'a5.9' --- +Unsupported operand types: string / string +--- testing: '3.4a'/'0' --- float(INF) ---- testing: '123e5xyz' / '0' --- -float(NAN) ---- testing: '123e5xyz' / '65' --- -int(0) ---- testing: '123e5xyz' / '-44' --- -int(0) ---- testing: '123e5xyz' / '1.2' --- -float(0) ---- testing: '123e5xyz' / '-7.7' --- -float(-0) ---- testing: '123e5xyz' / 'abc' --- -float(NAN) ---- testing: '123e5xyz' / '123abc' --- -float(NAN) ---- testing: '123e5xyz' / '123e5' --- -float(0) ---- testing: '123e5xyz' / '123e5xyz' --- -float(NAN) ---- testing: '123e5xyz' / ' 123abc' --- -float(NAN) ---- testing: '123e5xyz' / '123 abc' --- -float(NAN) ---- testing: '123e5xyz' / '123abc ' --- -float(NAN) ---- testing: '123e5xyz' / '3.4a' --- -float(NAN) ---- testing: '123e5xyz' / 'a5.9' --- -float(NAN) ---- testing: ' 123abc' / '0' --- -float(NAN) ---- testing: ' 123abc' / '65' --- -int(0) ---- testing: ' 123abc' / '-44' --- -int(0) ---- testing: ' 123abc' / '1.2' --- -float(0) ---- testing: ' 123abc' / '-7.7' --- -float(-0) ---- testing: ' 123abc' / 'abc' --- -float(NAN) ---- testing: ' 123abc' / '123abc' --- -float(NAN) ---- testing: ' 123abc' / '123e5' --- -float(0) ---- testing: ' 123abc' / '123e5xyz' --- -float(NAN) ---- testing: ' 123abc' / ' 123abc' --- -float(NAN) ---- testing: ' 123abc' / '123 abc' --- -float(NAN) ---- testing: ' 123abc' / '123abc ' --- -float(NAN) ---- testing: ' 123abc' / '3.4a' --- -float(NAN) ---- testing: ' 123abc' / 'a5.9' --- -float(NAN) ---- testing: '123 abc' / '0' --- -float(NAN) ---- testing: '123 abc' / '65' --- -int(0) ---- testing: '123 abc' / '-44' --- -int(0) ---- testing: '123 abc' / '1.2' --- -float(0) ---- testing: '123 abc' / '-7.7' --- -float(-0) ---- testing: '123 abc' / 'abc' --- -float(NAN) ---- testing: '123 abc' / '123abc' --- -float(NAN) ---- testing: '123 abc' / '123e5' --- -float(0) ---- testing: '123 abc' / '123e5xyz' --- -float(NAN) ---- testing: '123 abc' / ' 123abc' --- -float(NAN) ---- testing: '123 abc' / '123 abc' --- -float(NAN) ---- testing: '123 abc' / '123abc ' --- -float(NAN) ---- testing: '123 abc' / '3.4a' --- -float(NAN) ---- testing: '123 abc' / 'a5.9' --- -float(NAN) ---- testing: '123abc ' / '0' --- -float(NAN) ---- testing: '123abc ' / '65' --- -int(0) ---- testing: '123abc ' / '-44' --- -int(0) ---- testing: '123abc ' / '1.2' --- -float(0) ---- testing: '123abc ' / '-7.7' --- -float(-0) ---- testing: '123abc ' / 'abc' --- -float(NAN) ---- testing: '123abc ' / '123abc' --- -float(NAN) ---- testing: '123abc ' / '123e5' --- -float(0) ---- testing: '123abc ' / '123e5xyz' --- -float(NAN) ---- testing: '123abc ' / ' 123abc' --- -float(NAN) ---- testing: '123abc ' / '123 abc' --- -float(NAN) ---- testing: '123abc ' / '123abc ' --- -float(NAN) ---- testing: '123abc ' / '3.4a' --- -float(NAN) ---- testing: '123abc ' / 'a5.9' --- -float(NAN) ---- testing: '3.4a' / '0' --- -float(NAN) ---- testing: '3.4a' / '65' --- -int(0) ---- testing: '3.4a' / '-44' --- -int(0) ---- testing: '3.4a' / '1.2' --- -float(0) ---- testing: '3.4a' / '-7.7' --- -float(-0) ---- testing: '3.4a' / 'abc' --- -float(NAN) ---- testing: '3.4a' / '123abc' --- -float(NAN) ---- testing: '3.4a' / '123e5' --- -float(0) ---- testing: '3.4a' / '123e5xyz' --- -float(NAN) ---- testing: '3.4a' / ' 123abc' --- -float(NAN) ---- testing: '3.4a' / '123 abc' --- -float(NAN) ---- testing: '3.4a' / '123abc ' --- -float(NAN) ---- testing: '3.4a' / '3.4a' --- -float(NAN) ---- testing: '3.4a' / 'a5.9' --- -float(NAN) ---- testing: 'a5.9' / '0' --- -float(NAN) ---- testing: 'a5.9' / '65' --- -int(0) ---- testing: 'a5.9' / '-44' --- -int(0) ---- testing: 'a5.9' / '1.2' --- -float(0) ---- testing: 'a5.9' / '-7.7' --- -float(-0) ---- testing: 'a5.9' / 'abc' --- -float(NAN) ---- testing: 'a5.9' / '123abc' --- -float(NAN) ---- testing: 'a5.9' / '123e5' --- -float(0) ---- testing: 'a5.9' / '123e5xyz' --- -float(NAN) ---- testing: 'a5.9' / ' 123abc' --- -float(NAN) ---- testing: 'a5.9' / '123 abc' --- -float(NAN) ---- testing: 'a5.9' / '123abc ' --- -float(NAN) ---- testing: 'a5.9' / '3.4a' --- -float(NAN) ---- testing: 'a5.9' / 'a5.9' --- -float(NAN) +--- testing: '3.4a'/'65' --- +float(0.052307692307692305) +--- testing: '3.4a'/'-44' --- +float(-0.07727272727272727) +--- testing: '3.4a'/'1.2' --- +float(2.8333333333333335) +--- testing: '3.4a'/'-7.7' --- +float(-0.44155844155844154) +--- testing: '3.4a'/'abc' --- +Unsupported operand types: string / string +--- testing: '3.4a'/'123abc' --- +float(0.027642276422764227) +--- testing: '3.4a'/'123e5' --- +float(2.764227642276423E-7) +--- testing: '3.4a'/'123e5xyz' --- +float(2.764227642276423E-7) +--- testing: '3.4a'/' 123abc' --- +float(0.027642276422764227) +--- testing: '3.4a'/'123 abc' --- +float(0.027642276422764227) +--- testing: '3.4a'/'123abc ' --- +float(0.027642276422764227) +--- testing: '3.4a'/'3.4a' --- +float(1) +--- testing: '3.4a'/'a5.9' --- +Unsupported operand types: string / string +--- testing: 'a5.9'/'0' --- +Unsupported operand types: string / string +--- testing: 'a5.9'/'65' --- +Unsupported operand types: string / string +--- testing: 'a5.9'/'-44' --- +Unsupported operand types: string / string +--- testing: 'a5.9'/'1.2' --- +Unsupported operand types: string / string +--- testing: 'a5.9'/'-7.7' --- +Unsupported operand types: string / string +--- testing: 'a5.9'/'abc' --- +Unsupported operand types: string / string +--- testing: 'a5.9'/'123abc' --- +Unsupported operand types: string / string +--- testing: 'a5.9'/'123e5' --- +Unsupported operand types: string / string +--- testing: 'a5.9'/'123e5xyz' --- +Unsupported operand types: string / string +--- testing: 'a5.9'/' 123abc' --- +Unsupported operand types: string / string +--- testing: 'a5.9'/'123 abc' --- +Unsupported operand types: string / string +--- testing: 'a5.9'/'123abc ' --- +Unsupported operand types: string / string +--- testing: 'a5.9'/'3.4a' --- +Unsupported operand types: string / string +--- testing: 'a5.9'/'a5.9' --- +Unsupported operand types: string / string diff --git a/tests/lang/operators/modulus_variationStr.phpt b/tests/lang/operators/modulus_variationStr.phpt index 8e43394c9e4ac..1f9aae88a4d87 100644 --- a/tests/lang/operators/modulus_variationStr.phpt +++ b/tests/lang/operators/modulus_variationStr.phpt @@ -15,8 +15,8 @@ foreach ($strVals as $strVal) { echo "--- testing: '$strVal' % '$otherVal' ---\n"; try { var_dump($strVal%$otherVal); - } catch (DivisionByZeroError $e) { - echo "Exception: " . $e->getMessage() . "\n"; + } catch (\Throwable $e) { + echo get_class($e) . ': ' . $e->getMessage() . "\n"; } } } @@ -25,7 +25,7 @@ foreach ($strVals as $strVal) { ?> --EXPECT-- --- testing: '0' % '0' --- -Exception: Modulo by zero +DivisionByZeroError: Modulo by zero --- testing: '0' % '65' --- int(0) --- testing: '0' % '-44' --- @@ -35,25 +35,25 @@ int(0) --- testing: '0' % '-7.7' --- int(0) --- testing: '0' % 'abc' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: '0' % '123abc' --- -Exception: Modulo by zero +int(0) --- testing: '0' % '123e5' --- int(0) --- testing: '0' % '123e5xyz' --- -Exception: Modulo by zero +int(0) --- testing: '0' % ' 123abc' --- -Exception: Modulo by zero +int(0) --- testing: '0' % '123 abc' --- -Exception: Modulo by zero +int(0) --- testing: '0' % '123abc ' --- -Exception: Modulo by zero +int(0) --- testing: '0' % '3.4a' --- -Exception: Modulo by zero +int(0) --- testing: '0' % 'a5.9' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: '65' % '0' --- -Exception: Modulo by zero +DivisionByZeroError: Modulo by zero --- testing: '65' % '65' --- int(0) --- testing: '65' % '-44' --- @@ -63,25 +63,25 @@ int(0) --- testing: '65' % '-7.7' --- int(2) --- testing: '65' % 'abc' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: '65' % '123abc' --- -Exception: Modulo by zero +int(65) --- testing: '65' % '123e5' --- int(65) --- testing: '65' % '123e5xyz' --- -Exception: Modulo by zero +int(65) --- testing: '65' % ' 123abc' --- -Exception: Modulo by zero +int(65) --- testing: '65' % '123 abc' --- -Exception: Modulo by zero +int(65) --- testing: '65' % '123abc ' --- -Exception: Modulo by zero +int(65) --- testing: '65' % '3.4a' --- -Exception: Modulo by zero +int(2) --- testing: '65' % 'a5.9' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: '-44' % '0' --- -Exception: Modulo by zero +DivisionByZeroError: Modulo by zero --- testing: '-44' % '65' --- int(-44) --- testing: '-44' % '-44' --- @@ -91,25 +91,25 @@ int(0) --- testing: '-44' % '-7.7' --- int(-2) --- testing: '-44' % 'abc' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: '-44' % '123abc' --- -Exception: Modulo by zero +int(-44) --- testing: '-44' % '123e5' --- int(-44) --- testing: '-44' % '123e5xyz' --- -Exception: Modulo by zero +int(-44) --- testing: '-44' % ' 123abc' --- -Exception: Modulo by zero +int(-44) --- testing: '-44' % '123 abc' --- -Exception: Modulo by zero +int(-44) --- testing: '-44' % '123abc ' --- -Exception: Modulo by zero +int(-44) --- testing: '-44' % '3.4a' --- -Exception: Modulo by zero +int(-2) --- testing: '-44' % 'a5.9' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: '1.2' % '0' --- -Exception: Modulo by zero +DivisionByZeroError: Modulo by zero --- testing: '1.2' % '65' --- int(1) --- testing: '1.2' % '-44' --- @@ -119,25 +119,25 @@ int(0) --- testing: '1.2' % '-7.7' --- int(1) --- testing: '1.2' % 'abc' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: '1.2' % '123abc' --- -Exception: Modulo by zero +int(1) --- testing: '1.2' % '123e5' --- int(1) --- testing: '1.2' % '123e5xyz' --- -Exception: Modulo by zero +int(1) --- testing: '1.2' % ' 123abc' --- -Exception: Modulo by zero +int(1) --- testing: '1.2' % '123 abc' --- -Exception: Modulo by zero +int(1) --- testing: '1.2' % '123abc ' --- -Exception: Modulo by zero +int(1) --- testing: '1.2' % '3.4a' --- -Exception: Modulo by zero +int(1) --- testing: '1.2' % 'a5.9' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: '-7.7' % '0' --- -Exception: Modulo by zero +DivisionByZeroError: Modulo by zero --- testing: '-7.7' % '65' --- int(-7) --- testing: '-7.7' % '-44' --- @@ -147,81 +147,81 @@ int(0) --- testing: '-7.7' % '-7.7' --- int(0) --- testing: '-7.7' % 'abc' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: '-7.7' % '123abc' --- -Exception: Modulo by zero +int(-7) --- testing: '-7.7' % '123e5' --- int(-7) --- testing: '-7.7' % '123e5xyz' --- -Exception: Modulo by zero +int(-7) --- testing: '-7.7' % ' 123abc' --- -Exception: Modulo by zero +int(-7) --- testing: '-7.7' % '123 abc' --- -Exception: Modulo by zero +int(-7) --- testing: '-7.7' % '123abc ' --- -Exception: Modulo by zero +int(-7) --- testing: '-7.7' % '3.4a' --- -Exception: Modulo by zero +int(-1) --- testing: '-7.7' % 'a5.9' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: 'abc' % '0' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: 'abc' % '65' --- -int(0) +TypeError: Unsupported operand types: string % string --- testing: 'abc' % '-44' --- -int(0) +TypeError: Unsupported operand types: string % string --- testing: 'abc' % '1.2' --- -int(0) +TypeError: Unsupported operand types: string % string --- testing: 'abc' % '-7.7' --- -int(0) +TypeError: Unsupported operand types: string % string --- testing: 'abc' % 'abc' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: 'abc' % '123abc' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: 'abc' % '123e5' --- -int(0) +TypeError: Unsupported operand types: string % string --- testing: 'abc' % '123e5xyz' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: 'abc' % ' 123abc' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: 'abc' % '123 abc' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: 'abc' % '123abc ' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: 'abc' % '3.4a' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: 'abc' % 'a5.9' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: '123abc' % '0' --- -Exception: Modulo by zero +DivisionByZeroError: Modulo by zero --- testing: '123abc' % '65' --- -int(0) +int(58) --- testing: '123abc' % '-44' --- -int(0) +int(35) --- testing: '123abc' % '1.2' --- int(0) --- testing: '123abc' % '-7.7' --- -int(0) +int(4) --- testing: '123abc' % 'abc' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: '123abc' % '123abc' --- -Exception: Modulo by zero ---- testing: '123abc' % '123e5' --- int(0) +--- testing: '123abc' % '123e5' --- +int(123) --- testing: '123abc' % '123e5xyz' --- -Exception: Modulo by zero +int(123) --- testing: '123abc' % ' 123abc' --- -Exception: Modulo by zero +int(0) --- testing: '123abc' % '123 abc' --- -Exception: Modulo by zero +int(0) --- testing: '123abc' % '123abc ' --- -Exception: Modulo by zero +int(0) --- testing: '123abc' % '3.4a' --- -Exception: Modulo by zero +int(0) --- testing: '123abc' % 'a5.9' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: '123e5' % '0' --- -Exception: Modulo by zero +DivisionByZeroError: Modulo by zero --- testing: '123e5' % '65' --- int(50) --- testing: '123e5' % '-44' --- @@ -231,188 +231,188 @@ int(0) --- testing: '123e5' % '-7.7' --- int(6) --- testing: '123e5' % 'abc' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: '123e5' % '123abc' --- -Exception: Modulo by zero +int(0) --- testing: '123e5' % '123e5' --- int(0) --- testing: '123e5' % '123e5xyz' --- -Exception: Modulo by zero +int(0) --- testing: '123e5' % ' 123abc' --- -Exception: Modulo by zero +int(0) --- testing: '123e5' % '123 abc' --- -Exception: Modulo by zero +int(0) --- testing: '123e5' % '123abc ' --- -Exception: Modulo by zero +int(0) --- testing: '123e5' % '3.4a' --- -Exception: Modulo by zero +int(0) --- testing: '123e5' % 'a5.9' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: '123e5xyz' % '0' --- -Exception: Modulo by zero +DivisionByZeroError: Modulo by zero --- testing: '123e5xyz' % '65' --- -int(0) +int(50) --- testing: '123e5xyz' % '-44' --- -int(0) +int(20) --- testing: '123e5xyz' % '1.2' --- int(0) --- testing: '123e5xyz' % '-7.7' --- -int(0) +int(6) --- testing: '123e5xyz' % 'abc' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: '123e5xyz' % '123abc' --- -Exception: Modulo by zero +int(0) --- testing: '123e5xyz' % '123e5' --- int(0) --- testing: '123e5xyz' % '123e5xyz' --- -Exception: Modulo by zero +int(0) --- testing: '123e5xyz' % ' 123abc' --- -Exception: Modulo by zero +int(0) --- testing: '123e5xyz' % '123 abc' --- -Exception: Modulo by zero +int(0) --- testing: '123e5xyz' % '123abc ' --- -Exception: Modulo by zero +int(0) --- testing: '123e5xyz' % '3.4a' --- -Exception: Modulo by zero +int(0) --- testing: '123e5xyz' % 'a5.9' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: ' 123abc' % '0' --- -Exception: Modulo by zero +DivisionByZeroError: Modulo by zero --- testing: ' 123abc' % '65' --- -int(0) +int(58) --- testing: ' 123abc' % '-44' --- -int(0) +int(35) --- testing: ' 123abc' % '1.2' --- int(0) --- testing: ' 123abc' % '-7.7' --- -int(0) +int(4) --- testing: ' 123abc' % 'abc' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: ' 123abc' % '123abc' --- -Exception: Modulo by zero ---- testing: ' 123abc' % '123e5' --- int(0) +--- testing: ' 123abc' % '123e5' --- +int(123) --- testing: ' 123abc' % '123e5xyz' --- -Exception: Modulo by zero +int(123) --- testing: ' 123abc' % ' 123abc' --- -Exception: Modulo by zero +int(0) --- testing: ' 123abc' % '123 abc' --- -Exception: Modulo by zero +int(0) --- testing: ' 123abc' % '123abc ' --- -Exception: Modulo by zero +int(0) --- testing: ' 123abc' % '3.4a' --- -Exception: Modulo by zero +int(0) --- testing: ' 123abc' % 'a5.9' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: '123 abc' % '0' --- -Exception: Modulo by zero +DivisionByZeroError: Modulo by zero --- testing: '123 abc' % '65' --- -int(0) +int(58) --- testing: '123 abc' % '-44' --- -int(0) +int(35) --- testing: '123 abc' % '1.2' --- int(0) --- testing: '123 abc' % '-7.7' --- -int(0) +int(4) --- testing: '123 abc' % 'abc' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: '123 abc' % '123abc' --- -Exception: Modulo by zero ---- testing: '123 abc' % '123e5' --- int(0) +--- testing: '123 abc' % '123e5' --- +int(123) --- testing: '123 abc' % '123e5xyz' --- -Exception: Modulo by zero +int(123) --- testing: '123 abc' % ' 123abc' --- -Exception: Modulo by zero +int(0) --- testing: '123 abc' % '123 abc' --- -Exception: Modulo by zero +int(0) --- testing: '123 abc' % '123abc ' --- -Exception: Modulo by zero +int(0) --- testing: '123 abc' % '3.4a' --- -Exception: Modulo by zero +int(0) --- testing: '123 abc' % 'a5.9' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: '123abc ' % '0' --- -Exception: Modulo by zero +DivisionByZeroError: Modulo by zero --- testing: '123abc ' % '65' --- -int(0) +int(58) --- testing: '123abc ' % '-44' --- -int(0) +int(35) --- testing: '123abc ' % '1.2' --- int(0) --- testing: '123abc ' % '-7.7' --- -int(0) +int(4) --- testing: '123abc ' % 'abc' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: '123abc ' % '123abc' --- -Exception: Modulo by zero ---- testing: '123abc ' % '123e5' --- int(0) +--- testing: '123abc ' % '123e5' --- +int(123) --- testing: '123abc ' % '123e5xyz' --- -Exception: Modulo by zero +int(123) --- testing: '123abc ' % ' 123abc' --- -Exception: Modulo by zero +int(0) --- testing: '123abc ' % '123 abc' --- -Exception: Modulo by zero +int(0) --- testing: '123abc ' % '123abc ' --- -Exception: Modulo by zero +int(0) --- testing: '123abc ' % '3.4a' --- -Exception: Modulo by zero +int(0) --- testing: '123abc ' % 'a5.9' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: '3.4a' % '0' --- -Exception: Modulo by zero +DivisionByZeroError: Modulo by zero --- testing: '3.4a' % '65' --- -int(0) +int(3) --- testing: '3.4a' % '-44' --- -int(0) +int(3) --- testing: '3.4a' % '1.2' --- int(0) --- testing: '3.4a' % '-7.7' --- -int(0) +int(3) --- testing: '3.4a' % 'abc' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: '3.4a' % '123abc' --- -Exception: Modulo by zero +int(3) --- testing: '3.4a' % '123e5' --- -int(0) +int(3) --- testing: '3.4a' % '123e5xyz' --- -Exception: Modulo by zero +int(3) --- testing: '3.4a' % ' 123abc' --- -Exception: Modulo by zero +int(3) --- testing: '3.4a' % '123 abc' --- -Exception: Modulo by zero +int(3) --- testing: '3.4a' % '123abc ' --- -Exception: Modulo by zero +int(3) --- testing: '3.4a' % '3.4a' --- -Exception: Modulo by zero +int(0) --- testing: '3.4a' % 'a5.9' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: 'a5.9' % '0' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: 'a5.9' % '65' --- -int(0) +TypeError: Unsupported operand types: string % string --- testing: 'a5.9' % '-44' --- -int(0) +TypeError: Unsupported operand types: string % string --- testing: 'a5.9' % '1.2' --- -int(0) +TypeError: Unsupported operand types: string % string --- testing: 'a5.9' % '-7.7' --- -int(0) +TypeError: Unsupported operand types: string % string --- testing: 'a5.9' % 'abc' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: 'a5.9' % '123abc' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: 'a5.9' % '123e5' --- -int(0) +TypeError: Unsupported operand types: string % string --- testing: 'a5.9' % '123e5xyz' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: 'a5.9' % ' 123abc' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: 'a5.9' % '123 abc' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: 'a5.9' % '123abc ' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: 'a5.9' % '3.4a' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string --- testing: 'a5.9' % 'a5.9' --- -Exception: Modulo by zero +TypeError: Unsupported operand types: string % string diff --git a/tests/lang/operators/multiply_variationStr.phpt b/tests/lang/operators/multiply_variationStr.phpt index 68d71a48683ba..af650ae993555 100644 --- a/tests/lang/operators/multiply_variationStr.phpt +++ b/tests/lang/operators/multiply_variationStr.phpt @@ -11,13 +11,16 @@ $strVals = array( error_reporting(E_ERROR); foreach ($strVals as $strVal) { - foreach($strVals as $otherVal) { - echo "--- testing: '$strVal' * '$otherVal' ---\n"; - var_dump($strVal*$otherVal); - } + foreach($strVals as $otherVal) { + echo "--- testing: '$strVal' * '$otherVal' ---\n"; + try { + var_dump($strVal*$otherVal); + } catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; + } + } } - ?> --EXPECT-- --- testing: '0' * '0' --- @@ -31,13 +34,13 @@ float(0) --- testing: '0' * '-7.7' --- float(-0) --- testing: '0' * 'abc' --- -int(0) +Unsupported operand types: string * string --- testing: '0' * '123abc' --- int(0) --- testing: '0' * '123e5' --- float(0) --- testing: '0' * '123e5xyz' --- -int(0) +float(0) --- testing: '0' * ' 123abc' --- int(0) --- testing: '0' * '123 abc' --- @@ -45,9 +48,9 @@ int(0) --- testing: '0' * '123abc ' --- int(0) --- testing: '0' * '3.4a' --- -int(0) +float(0) --- testing: '0' * 'a5.9' --- -int(0) +Unsupported operand types: string * string --- testing: '65' * '0' --- int(0) --- testing: '65' * '65' --- @@ -59,23 +62,23 @@ float(78) --- testing: '65' * '-7.7' --- float(-500.5) --- testing: '65' * 'abc' --- -int(0) +Unsupported operand types: string * string --- testing: '65' * '123abc' --- -int(0) +int(7995) --- testing: '65' * '123e5' --- float(799500000) --- testing: '65' * '123e5xyz' --- -int(0) +float(799500000) --- testing: '65' * ' 123abc' --- -int(0) +int(7995) --- testing: '65' * '123 abc' --- -int(0) +int(7995) --- testing: '65' * '123abc ' --- -int(0) +int(7995) --- testing: '65' * '3.4a' --- -int(0) +float(221) --- testing: '65' * 'a5.9' --- -int(0) +Unsupported operand types: string * string --- testing: '-44' * '0' --- int(0) --- testing: '-44' * '65' --- @@ -87,23 +90,23 @@ float(-52.8) --- testing: '-44' * '-7.7' --- float(338.8) --- testing: '-44' * 'abc' --- -int(0) +Unsupported operand types: string * string --- testing: '-44' * '123abc' --- -int(0) +int(-5412) --- testing: '-44' * '123e5' --- float(-541200000) --- testing: '-44' * '123e5xyz' --- -int(0) +float(-541200000) --- testing: '-44' * ' 123abc' --- -int(0) +int(-5412) --- testing: '-44' * '123 abc' --- -int(0) +int(-5412) --- testing: '-44' * '123abc ' --- -int(0) +int(-5412) --- testing: '-44' * '3.4a' --- -int(0) +float(-149.6) --- testing: '-44' * 'a5.9' --- -int(0) +Unsupported operand types: string * string --- testing: '1.2' * '0' --- float(0) --- testing: '1.2' * '65' --- @@ -115,23 +118,23 @@ float(1.44) --- testing: '1.2' * '-7.7' --- float(-9.24) --- testing: '1.2' * 'abc' --- -float(0) +Unsupported operand types: string * string --- testing: '1.2' * '123abc' --- -float(0) +float(147.6) --- testing: '1.2' * '123e5' --- float(14760000) --- testing: '1.2' * '123e5xyz' --- -float(0) +float(14760000) --- testing: '1.2' * ' 123abc' --- -float(0) +float(147.6) --- testing: '1.2' * '123 abc' --- -float(0) +float(147.6) --- testing: '1.2' * '123abc ' --- -float(0) +float(147.6) --- testing: '1.2' * '3.4a' --- -float(0) +float(4.08) --- testing: '1.2' * 'a5.9' --- -float(0) +Unsupported operand types: string * string --- testing: '-7.7' * '0' --- float(-0) --- testing: '-7.7' * '65' --- @@ -143,79 +146,79 @@ float(-9.24) --- testing: '-7.7' * '-7.7' --- float(59.290000000000006) --- testing: '-7.7' * 'abc' --- -float(-0) +Unsupported operand types: string * string --- testing: '-7.7' * '123abc' --- -float(-0) +float(-947.1) --- testing: '-7.7' * '123e5' --- float(-94710000) --- testing: '-7.7' * '123e5xyz' --- -float(-0) +float(-94710000) --- testing: '-7.7' * ' 123abc' --- -float(-0) +float(-947.1) --- testing: '-7.7' * '123 abc' --- -float(-0) +float(-947.1) --- testing: '-7.7' * '123abc ' --- -float(-0) +float(-947.1) --- testing: '-7.7' * '3.4a' --- -float(-0) +float(-26.18) --- testing: '-7.7' * 'a5.9' --- -float(-0) +Unsupported operand types: string * string --- testing: 'abc' * '0' --- -int(0) +Unsupported operand types: string * string --- testing: 'abc' * '65' --- -int(0) +Unsupported operand types: string * string --- testing: 'abc' * '-44' --- -int(0) +Unsupported operand types: string * string --- testing: 'abc' * '1.2' --- -float(0) +Unsupported operand types: string * string --- testing: 'abc' * '-7.7' --- -float(-0) +Unsupported operand types: string * string --- testing: 'abc' * 'abc' --- -int(0) +Unsupported operand types: string * string --- testing: 'abc' * '123abc' --- -int(0) +Unsupported operand types: string * string --- testing: 'abc' * '123e5' --- -float(0) +Unsupported operand types: string * string --- testing: 'abc' * '123e5xyz' --- -int(0) +Unsupported operand types: string * string --- testing: 'abc' * ' 123abc' --- -int(0) +Unsupported operand types: string * string --- testing: 'abc' * '123 abc' --- -int(0) +Unsupported operand types: string * string --- testing: 'abc' * '123abc ' --- -int(0) +Unsupported operand types: string * string --- testing: 'abc' * '3.4a' --- -int(0) +Unsupported operand types: string * string --- testing: 'abc' * 'a5.9' --- -int(0) +Unsupported operand types: string * string --- testing: '123abc' * '0' --- int(0) --- testing: '123abc' * '65' --- -int(0) +int(7995) --- testing: '123abc' * '-44' --- -int(0) +int(-5412) --- testing: '123abc' * '1.2' --- -float(0) +float(147.6) --- testing: '123abc' * '-7.7' --- -float(-0) +float(-947.1) --- testing: '123abc' * 'abc' --- -int(0) +Unsupported operand types: string * string --- testing: '123abc' * '123abc' --- -int(0) +int(15129) --- testing: '123abc' * '123e5' --- -float(0) +float(1512900000) --- testing: '123abc' * '123e5xyz' --- -int(0) +float(1512900000) --- testing: '123abc' * ' 123abc' --- -int(0) +int(15129) --- testing: '123abc' * '123 abc' --- -int(0) +int(15129) --- testing: '123abc' * '123abc ' --- -int(0) +int(15129) --- testing: '123abc' * '3.4a' --- -int(0) +float(418.2) --- testing: '123abc' * 'a5.9' --- -int(0) +Unsupported operand types: string * string --- testing: '123e5' * '0' --- float(0) --- testing: '123e5' * '65' --- @@ -227,188 +230,188 @@ float(14760000) --- testing: '123e5' * '-7.7' --- float(-94710000) --- testing: '123e5' * 'abc' --- -float(0) +Unsupported operand types: string * string --- testing: '123e5' * '123abc' --- -float(0) +float(1512900000) --- testing: '123e5' * '123e5' --- float(151290000000000) --- testing: '123e5' * '123e5xyz' --- -float(0) +float(151290000000000) --- testing: '123e5' * ' 123abc' --- -float(0) +float(1512900000) --- testing: '123e5' * '123 abc' --- -float(0) +float(1512900000) --- testing: '123e5' * '123abc ' --- -float(0) +float(1512900000) --- testing: '123e5' * '3.4a' --- -float(0) +float(41820000) --- testing: '123e5' * 'a5.9' --- -float(0) +Unsupported operand types: string * string --- testing: '123e5xyz' * '0' --- -int(0) +float(0) --- testing: '123e5xyz' * '65' --- -int(0) +float(799500000) --- testing: '123e5xyz' * '-44' --- -int(0) +float(-541200000) --- testing: '123e5xyz' * '1.2' --- -float(0) +float(14760000) --- testing: '123e5xyz' * '-7.7' --- -float(-0) +float(-94710000) --- testing: '123e5xyz' * 'abc' --- -int(0) +Unsupported operand types: string * string --- testing: '123e5xyz' * '123abc' --- -int(0) +float(1512900000) --- testing: '123e5xyz' * '123e5' --- -float(0) +float(151290000000000) --- testing: '123e5xyz' * '123e5xyz' --- -int(0) +float(151290000000000) --- testing: '123e5xyz' * ' 123abc' --- -int(0) +float(1512900000) --- testing: '123e5xyz' * '123 abc' --- -int(0) +float(1512900000) --- testing: '123e5xyz' * '123abc ' --- -int(0) +float(1512900000) --- testing: '123e5xyz' * '3.4a' --- -int(0) +float(41820000) --- testing: '123e5xyz' * 'a5.9' --- -int(0) +Unsupported operand types: string * string --- testing: ' 123abc' * '0' --- int(0) --- testing: ' 123abc' * '65' --- -int(0) +int(7995) --- testing: ' 123abc' * '-44' --- -int(0) +int(-5412) --- testing: ' 123abc' * '1.2' --- -float(0) +float(147.6) --- testing: ' 123abc' * '-7.7' --- -float(-0) +float(-947.1) --- testing: ' 123abc' * 'abc' --- -int(0) +Unsupported operand types: string * string --- testing: ' 123abc' * '123abc' --- -int(0) +int(15129) --- testing: ' 123abc' * '123e5' --- -float(0) +float(1512900000) --- testing: ' 123abc' * '123e5xyz' --- -int(0) +float(1512900000) --- testing: ' 123abc' * ' 123abc' --- -int(0) +int(15129) --- testing: ' 123abc' * '123 abc' --- -int(0) +int(15129) --- testing: ' 123abc' * '123abc ' --- -int(0) +int(15129) --- testing: ' 123abc' * '3.4a' --- -int(0) +float(418.2) --- testing: ' 123abc' * 'a5.9' --- -int(0) +Unsupported operand types: string * string --- testing: '123 abc' * '0' --- int(0) --- testing: '123 abc' * '65' --- -int(0) +int(7995) --- testing: '123 abc' * '-44' --- -int(0) +int(-5412) --- testing: '123 abc' * '1.2' --- -float(0) +float(147.6) --- testing: '123 abc' * '-7.7' --- -float(-0) +float(-947.1) --- testing: '123 abc' * 'abc' --- -int(0) +Unsupported operand types: string * string --- testing: '123 abc' * '123abc' --- -int(0) +int(15129) --- testing: '123 abc' * '123e5' --- -float(0) +float(1512900000) --- testing: '123 abc' * '123e5xyz' --- -int(0) +float(1512900000) --- testing: '123 abc' * ' 123abc' --- -int(0) +int(15129) --- testing: '123 abc' * '123 abc' --- -int(0) +int(15129) --- testing: '123 abc' * '123abc ' --- -int(0) +int(15129) --- testing: '123 abc' * '3.4a' --- -int(0) +float(418.2) --- testing: '123 abc' * 'a5.9' --- -int(0) +Unsupported operand types: string * string --- testing: '123abc ' * '0' --- int(0) --- testing: '123abc ' * '65' --- -int(0) +int(7995) --- testing: '123abc ' * '-44' --- -int(0) +int(-5412) --- testing: '123abc ' * '1.2' --- -float(0) +float(147.6) --- testing: '123abc ' * '-7.7' --- -float(-0) +float(-947.1) --- testing: '123abc ' * 'abc' --- -int(0) +Unsupported operand types: string * string --- testing: '123abc ' * '123abc' --- -int(0) +int(15129) --- testing: '123abc ' * '123e5' --- -float(0) +float(1512900000) --- testing: '123abc ' * '123e5xyz' --- -int(0) +float(1512900000) --- testing: '123abc ' * ' 123abc' --- -int(0) +int(15129) --- testing: '123abc ' * '123 abc' --- -int(0) +int(15129) --- testing: '123abc ' * '123abc ' --- -int(0) +int(15129) --- testing: '123abc ' * '3.4a' --- -int(0) +float(418.2) --- testing: '123abc ' * 'a5.9' --- -int(0) +Unsupported operand types: string * string --- testing: '3.4a' * '0' --- -int(0) +float(0) --- testing: '3.4a' * '65' --- -int(0) +float(221) --- testing: '3.4a' * '-44' --- -int(0) +float(-149.6) --- testing: '3.4a' * '1.2' --- -float(0) +float(4.08) --- testing: '3.4a' * '-7.7' --- -float(-0) +float(-26.18) --- testing: '3.4a' * 'abc' --- -int(0) +Unsupported operand types: string * string --- testing: '3.4a' * '123abc' --- -int(0) +float(418.2) --- testing: '3.4a' * '123e5' --- -float(0) +float(41820000) --- testing: '3.4a' * '123e5xyz' --- -int(0) +float(41820000) --- testing: '3.4a' * ' 123abc' --- -int(0) +float(418.2) --- testing: '3.4a' * '123 abc' --- -int(0) +float(418.2) --- testing: '3.4a' * '123abc ' --- -int(0) +float(418.2) --- testing: '3.4a' * '3.4a' --- -int(0) +float(11.559999999999999) --- testing: '3.4a' * 'a5.9' --- -int(0) +Unsupported operand types: string * string --- testing: 'a5.9' * '0' --- -int(0) +Unsupported operand types: string * string --- testing: 'a5.9' * '65' --- -int(0) +Unsupported operand types: string * string --- testing: 'a5.9' * '-44' --- -int(0) +Unsupported operand types: string * string --- testing: 'a5.9' * '1.2' --- -float(0) +Unsupported operand types: string * string --- testing: 'a5.9' * '-7.7' --- -float(-0) +Unsupported operand types: string * string --- testing: 'a5.9' * 'abc' --- -int(0) +Unsupported operand types: string * string --- testing: 'a5.9' * '123abc' --- -int(0) +Unsupported operand types: string * string --- testing: 'a5.9' * '123e5' --- -float(0) +Unsupported operand types: string * string --- testing: 'a5.9' * '123e5xyz' --- -int(0) +Unsupported operand types: string * string --- testing: 'a5.9' * ' 123abc' --- -int(0) +Unsupported operand types: string * string --- testing: 'a5.9' * '123 abc' --- -int(0) +Unsupported operand types: string * string --- testing: 'a5.9' * '123abc ' --- -int(0) +Unsupported operand types: string * string --- testing: 'a5.9' * '3.4a' --- -int(0) +Unsupported operand types: string * string --- testing: 'a5.9' * 'a5.9' --- -int(0) +Unsupported operand types: string * string diff --git a/tests/lang/operators/negate_variationStr.phpt b/tests/lang/operators/negate_variationStr.phpt index 1aded5702c297..43b2f6a52a60e 100644 --- a/tests/lang/operators/negate_variationStr.phpt +++ b/tests/lang/operators/negate_variationStr.phpt @@ -8,10 +8,13 @@ $strVals = array( "a5.9" ); - foreach ($strVals as $strVal) { - echo "--- testing: '$strVal' ---\n"; - var_dump(-$strVal); + echo "--- testing: '$strVal' ---\n"; + try { + var_dump(-$strVal); + } catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; + } } ?> @@ -27,36 +30,32 @@ float(-1.2) --- testing: '-7.7' --- float(7.7) --- testing: 'abc' --- - -Warning: A non-numeric value encountered in %s on line %d -int(0) +Unsupported operand types: string * int --- testing: '123abc' --- Warning: A non-numeric value encountered in %s on line %d -int(0) +int(-123) --- testing: '123e5' --- float(-12300000) --- testing: '123e5xyz' --- Warning: A non-numeric value encountered in %s on line %d -int(0) +float(-12300000) --- testing: ' 123abc' --- Warning: A non-numeric value encountered in %s on line %d -int(0) +int(-123) --- testing: '123 abc' --- Warning: A non-numeric value encountered in %s on line %d -int(0) +int(-123) --- testing: '123abc ' --- Warning: A non-numeric value encountered in %s on line %d -int(0) +int(-123) --- testing: '3.4a' --- Warning: A non-numeric value encountered in %s on line %d -int(0) +float(-3.4) --- testing: 'a5.9' --- - -Warning: A non-numeric value encountered in %s on line %d -int(0) +Unsupported operand types: string * int diff --git a/tests/lang/operators/subtract_variationStr.phpt b/tests/lang/operators/subtract_variationStr.phpt index a6e35a4698176..6df852498df19 100644 --- a/tests/lang/operators/subtract_variationStr.phpt +++ b/tests/lang/operators/subtract_variationStr.phpt @@ -11,13 +11,16 @@ $strVals = array( error_reporting(E_ERROR); foreach ($strVals as $strVal) { - foreach($strVals as $otherVal) { - echo "--- testing: '$strVal' - '$otherVal' ---\n"; - var_dump($strVal-$otherVal); - } + foreach($strVals as $otherVal) { + echo "--- testing: '$strVal' - '$otherVal' ---\n"; + try { + var_dump($strVal-$otherVal); + } catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; + } + } } - ?> --EXPECT-- --- testing: '0' - '0' --- @@ -31,23 +34,23 @@ float(-1.2) --- testing: '0' - '-7.7' --- float(7.7) --- testing: '0' - 'abc' --- -int(0) +Unsupported operand types: string - string --- testing: '0' - '123abc' --- -int(0) +int(-123) --- testing: '0' - '123e5' --- float(-12300000) --- testing: '0' - '123e5xyz' --- -int(0) +float(-12300000) --- testing: '0' - ' 123abc' --- -int(0) +int(-123) --- testing: '0' - '123 abc' --- -int(0) +int(-123) --- testing: '0' - '123abc ' --- -int(0) +int(-123) --- testing: '0' - '3.4a' --- -int(0) +float(-3.4) --- testing: '0' - 'a5.9' --- -int(0) +Unsupported operand types: string - string --- testing: '65' - '0' --- int(65) --- testing: '65' - '65' --- @@ -59,23 +62,23 @@ float(63.8) --- testing: '65' - '-7.7' --- float(72.7) --- testing: '65' - 'abc' --- -int(65) +Unsupported operand types: string - string --- testing: '65' - '123abc' --- -int(65) +int(-58) --- testing: '65' - '123e5' --- float(-12299935) --- testing: '65' - '123e5xyz' --- -int(65) +float(-12299935) --- testing: '65' - ' 123abc' --- -int(65) +int(-58) --- testing: '65' - '123 abc' --- -int(65) +int(-58) --- testing: '65' - '123abc ' --- -int(65) +int(-58) --- testing: '65' - '3.4a' --- -int(65) +float(61.6) --- testing: '65' - 'a5.9' --- -int(65) +Unsupported operand types: string - string --- testing: '-44' - '0' --- int(-44) --- testing: '-44' - '65' --- @@ -87,23 +90,23 @@ float(-45.2) --- testing: '-44' - '-7.7' --- float(-36.3) --- testing: '-44' - 'abc' --- -int(-44) +Unsupported operand types: string - string --- testing: '-44' - '123abc' --- -int(-44) +int(-167) --- testing: '-44' - '123e5' --- float(-12300044) --- testing: '-44' - '123e5xyz' --- -int(-44) +float(-12300044) --- testing: '-44' - ' 123abc' --- -int(-44) +int(-167) --- testing: '-44' - '123 abc' --- -int(-44) +int(-167) --- testing: '-44' - '123abc ' --- -int(-44) +int(-167) --- testing: '-44' - '3.4a' --- -int(-44) +float(-47.4) --- testing: '-44' - 'a5.9' --- -int(-44) +Unsupported operand types: string - string --- testing: '1.2' - '0' --- float(1.2) --- testing: '1.2' - '65' --- @@ -115,23 +118,23 @@ float(0) --- testing: '1.2' - '-7.7' --- float(8.9) --- testing: '1.2' - 'abc' --- -float(1.2) +Unsupported operand types: string - string --- testing: '1.2' - '123abc' --- -float(1.2) +float(-121.8) --- testing: '1.2' - '123e5' --- float(-12299998.8) --- testing: '1.2' - '123e5xyz' --- -float(1.2) +float(-12299998.8) --- testing: '1.2' - ' 123abc' --- -float(1.2) +float(-121.8) --- testing: '1.2' - '123 abc' --- -float(1.2) +float(-121.8) --- testing: '1.2' - '123abc ' --- -float(1.2) +float(-121.8) --- testing: '1.2' - '3.4a' --- -float(1.2) +float(-2.2) --- testing: '1.2' - 'a5.9' --- -float(1.2) +Unsupported operand types: string - string --- testing: '-7.7' - '0' --- float(-7.7) --- testing: '-7.7' - '65' --- @@ -143,69 +146,69 @@ float(-8.9) --- testing: '-7.7' - '-7.7' --- float(0) --- testing: '-7.7' - 'abc' --- -float(-7.7) +Unsupported operand types: string - string --- testing: '-7.7' - '123abc' --- -float(-7.7) +float(-130.7) --- testing: '-7.7' - '123e5' --- float(-12300007.7) --- testing: '-7.7' - '123e5xyz' --- -float(-7.7) +float(-12300007.7) --- testing: '-7.7' - ' 123abc' --- -float(-7.7) +float(-130.7) --- testing: '-7.7' - '123 abc' --- -float(-7.7) +float(-130.7) --- testing: '-7.7' - '123abc ' --- -float(-7.7) +float(-130.7) --- testing: '-7.7' - '3.4a' --- -float(-7.7) +float(-11.1) --- testing: '-7.7' - 'a5.9' --- -float(-7.7) +Unsupported operand types: string - string --- testing: 'abc' - '0' --- -int(0) +Unsupported operand types: string - string --- testing: 'abc' - '65' --- -int(-65) +Unsupported operand types: string - string --- testing: 'abc' - '-44' --- -int(44) +Unsupported operand types: string - string --- testing: 'abc' - '1.2' --- -float(-1.2) +Unsupported operand types: string - string --- testing: 'abc' - '-7.7' --- -float(7.7) +Unsupported operand types: string - string --- testing: 'abc' - 'abc' --- -int(0) +Unsupported operand types: string - string --- testing: 'abc' - '123abc' --- -int(0) +Unsupported operand types: string - string --- testing: 'abc' - '123e5' --- -float(-12300000) +Unsupported operand types: string - string --- testing: 'abc' - '123e5xyz' --- -int(0) +Unsupported operand types: string - string --- testing: 'abc' - ' 123abc' --- -int(0) +Unsupported operand types: string - string --- testing: 'abc' - '123 abc' --- -int(0) +Unsupported operand types: string - string --- testing: 'abc' - '123abc ' --- -int(0) +Unsupported operand types: string - string --- testing: 'abc' - '3.4a' --- -int(0) +Unsupported operand types: string - string --- testing: 'abc' - 'a5.9' --- -int(0) +Unsupported operand types: string - string --- testing: '123abc' - '0' --- -int(0) +int(123) --- testing: '123abc' - '65' --- -int(-65) +int(58) --- testing: '123abc' - '-44' --- -int(44) +int(167) --- testing: '123abc' - '1.2' --- -float(-1.2) +float(121.8) --- testing: '123abc' - '-7.7' --- -float(7.7) +float(130.7) --- testing: '123abc' - 'abc' --- -int(0) +Unsupported operand types: string - string --- testing: '123abc' - '123abc' --- int(0) --- testing: '123abc' - '123e5' --- -float(-12300000) +float(-12299877) --- testing: '123abc' - '123e5xyz' --- -int(0) +float(-12299877) --- testing: '123abc' - ' 123abc' --- int(0) --- testing: '123abc' - '123 abc' --- @@ -213,9 +216,9 @@ int(0) --- testing: '123abc' - '123abc ' --- int(0) --- testing: '123abc' - '3.4a' --- -int(0) +float(119.6) --- testing: '123abc' - 'a5.9' --- -int(0) +Unsupported operand types: string - string --- testing: '123e5' - '0' --- float(12300000) --- testing: '123e5' - '65' --- @@ -227,69 +230,69 @@ float(12299998.8) --- testing: '123e5' - '-7.7' --- float(12300007.7) --- testing: '123e5' - 'abc' --- -float(12300000) +Unsupported operand types: string - string --- testing: '123e5' - '123abc' --- -float(12300000) +float(12299877) --- testing: '123e5' - '123e5' --- float(0) --- testing: '123e5' - '123e5xyz' --- -float(12300000) +float(0) --- testing: '123e5' - ' 123abc' --- -float(12300000) +float(12299877) --- testing: '123e5' - '123 abc' --- -float(12300000) +float(12299877) --- testing: '123e5' - '123abc ' --- -float(12300000) +float(12299877) --- testing: '123e5' - '3.4a' --- -float(12300000) +float(12299996.6) --- testing: '123e5' - 'a5.9' --- -float(12300000) +Unsupported operand types: string - string --- testing: '123e5xyz' - '0' --- -int(0) +float(12300000) --- testing: '123e5xyz' - '65' --- -int(-65) +float(12299935) --- testing: '123e5xyz' - '-44' --- -int(44) +float(12300044) --- testing: '123e5xyz' - '1.2' --- -float(-1.2) +float(12299998.8) --- testing: '123e5xyz' - '-7.7' --- -float(7.7) +float(12300007.7) --- testing: '123e5xyz' - 'abc' --- -int(0) +Unsupported operand types: string - string --- testing: '123e5xyz' - '123abc' --- -int(0) +float(12299877) --- testing: '123e5xyz' - '123e5' --- -float(-12300000) +float(0) --- testing: '123e5xyz' - '123e5xyz' --- -int(0) +float(0) --- testing: '123e5xyz' - ' 123abc' --- -int(0) +float(12299877) --- testing: '123e5xyz' - '123 abc' --- -int(0) +float(12299877) --- testing: '123e5xyz' - '123abc ' --- -int(0) +float(12299877) --- testing: '123e5xyz' - '3.4a' --- -int(0) +float(12299996.6) --- testing: '123e5xyz' - 'a5.9' --- -int(0) +Unsupported operand types: string - string --- testing: ' 123abc' - '0' --- -int(0) +int(123) --- testing: ' 123abc' - '65' --- -int(-65) +int(58) --- testing: ' 123abc' - '-44' --- -int(44) +int(167) --- testing: ' 123abc' - '1.2' --- -float(-1.2) +float(121.8) --- testing: ' 123abc' - '-7.7' --- -float(7.7) +float(130.7) --- testing: ' 123abc' - 'abc' --- -int(0) +Unsupported operand types: string - string --- testing: ' 123abc' - '123abc' --- int(0) --- testing: ' 123abc' - '123e5' --- -float(-12300000) +float(-12299877) --- testing: ' 123abc' - '123e5xyz' --- -int(0) +float(-12299877) --- testing: ' 123abc' - ' 123abc' --- int(0) --- testing: ' 123abc' - '123 abc' --- @@ -297,27 +300,27 @@ int(0) --- testing: ' 123abc' - '123abc ' --- int(0) --- testing: ' 123abc' - '3.4a' --- -int(0) +float(119.6) --- testing: ' 123abc' - 'a5.9' --- -int(0) +Unsupported operand types: string - string --- testing: '123 abc' - '0' --- -int(0) +int(123) --- testing: '123 abc' - '65' --- -int(-65) +int(58) --- testing: '123 abc' - '-44' --- -int(44) +int(167) --- testing: '123 abc' - '1.2' --- -float(-1.2) +float(121.8) --- testing: '123 abc' - '-7.7' --- -float(7.7) +float(130.7) --- testing: '123 abc' - 'abc' --- -int(0) +Unsupported operand types: string - string --- testing: '123 abc' - '123abc' --- int(0) --- testing: '123 abc' - '123e5' --- -float(-12300000) +float(-12299877) --- testing: '123 abc' - '123e5xyz' --- -int(0) +float(-12299877) --- testing: '123 abc' - ' 123abc' --- int(0) --- testing: '123 abc' - '123 abc' --- @@ -325,27 +328,27 @@ int(0) --- testing: '123 abc' - '123abc ' --- int(0) --- testing: '123 abc' - '3.4a' --- -int(0) +float(119.6) --- testing: '123 abc' - 'a5.9' --- -int(0) +Unsupported operand types: string - string --- testing: '123abc ' - '0' --- -int(0) +int(123) --- testing: '123abc ' - '65' --- -int(-65) +int(58) --- testing: '123abc ' - '-44' --- -int(44) +int(167) --- testing: '123abc ' - '1.2' --- -float(-1.2) +float(121.8) --- testing: '123abc ' - '-7.7' --- -float(7.7) +float(130.7) --- testing: '123abc ' - 'abc' --- -int(0) +Unsupported operand types: string - string --- testing: '123abc ' - '123abc' --- int(0) --- testing: '123abc ' - '123e5' --- -float(-12300000) +float(-12299877) --- testing: '123abc ' - '123e5xyz' --- -int(0) +float(-12299877) --- testing: '123abc ' - ' 123abc' --- int(0) --- testing: '123abc ' - '123 abc' --- @@ -353,62 +356,62 @@ int(0) --- testing: '123abc ' - '123abc ' --- int(0) --- testing: '123abc ' - '3.4a' --- -int(0) +float(119.6) --- testing: '123abc ' - 'a5.9' --- -int(0) +Unsupported operand types: string - string --- testing: '3.4a' - '0' --- -int(0) +float(3.4) --- testing: '3.4a' - '65' --- -int(-65) +float(-61.6) --- testing: '3.4a' - '-44' --- -int(44) +float(47.4) --- testing: '3.4a' - '1.2' --- -float(-1.2) +float(2.2) --- testing: '3.4a' - '-7.7' --- -float(7.7) +float(11.1) --- testing: '3.4a' - 'abc' --- -int(0) +Unsupported operand types: string - string --- testing: '3.4a' - '123abc' --- -int(0) +float(-119.6) --- testing: '3.4a' - '123e5' --- -float(-12300000) +float(-12299996.6) --- testing: '3.4a' - '123e5xyz' --- -int(0) +float(-12299996.6) --- testing: '3.4a' - ' 123abc' --- -int(0) +float(-119.6) --- testing: '3.4a' - '123 abc' --- -int(0) +float(-119.6) --- testing: '3.4a' - '123abc ' --- -int(0) +float(-119.6) --- testing: '3.4a' - '3.4a' --- -int(0) +float(0) --- testing: '3.4a' - 'a5.9' --- -int(0) +Unsupported operand types: string - string --- testing: 'a5.9' - '0' --- -int(0) +Unsupported operand types: string - string --- testing: 'a5.9' - '65' --- -int(-65) +Unsupported operand types: string - string --- testing: 'a5.9' - '-44' --- -int(44) +Unsupported operand types: string - string --- testing: 'a5.9' - '1.2' --- -float(-1.2) +Unsupported operand types: string - string --- testing: 'a5.9' - '-7.7' --- -float(7.7) +Unsupported operand types: string - string --- testing: 'a5.9' - 'abc' --- -int(0) +Unsupported operand types: string - string --- testing: 'a5.9' - '123abc' --- -int(0) +Unsupported operand types: string - string --- testing: 'a5.9' - '123e5' --- -float(-12300000) +Unsupported operand types: string - string --- testing: 'a5.9' - '123e5xyz' --- -int(0) +Unsupported operand types: string - string --- testing: 'a5.9' - ' 123abc' --- -int(0) +Unsupported operand types: string - string --- testing: 'a5.9' - '123 abc' --- -int(0) +Unsupported operand types: string - string --- testing: 'a5.9' - '123abc ' --- -int(0) +Unsupported operand types: string - string --- testing: 'a5.9' - '3.4a' --- -int(0) +Unsupported operand types: string - string --- testing: 'a5.9' - 'a5.9' --- -int(0) +Unsupported operand types: string - string From 66e969b5488c1e10368c9db8f6f25a36e2e2f56a Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Thu, 23 Jul 2020 19:48:04 +0100 Subject: [PATCH 06/14] Revert "Change warning type for well formed numeric float strings used as string offset" As the secondary vote for this is failing This reverts commit a835d27b31185688053a79eac59650a70eb97060. --- Zend/tests/numeric_strings/string_offset.phpt | 16 +++------ Zend/tests/offset_string.phpt | 4 +-- Zend/zend_execute.c | 18 ++-------- ext/opcache/jit/zend_jit_helpers.c | 18 ++-------- ext/opcache/tests/jit/fetch_dim_r_003.phpt | 36 ++----------------- ext/opcache/tests/jit/fetch_dim_r_004.phpt | 28 ++------------- 6 files changed, 13 insertions(+), 107 deletions(-) diff --git a/Zend/tests/numeric_strings/string_offset.phpt b/Zend/tests/numeric_strings/string_offset.phpt index ba917f2bb23c5..c1661f72dcc26 100644 --- a/Zend/tests/numeric_strings/string_offset.phpt +++ b/Zend/tests/numeric_strings/string_offset.phpt @@ -39,21 +39,13 @@ echo "Done\n"; ?> --EXPECTF-- string(1) "l" - -Warning: String offset cast occurred in %s on line %d -string(1) "l" -string(1) "l" - -Warning: String offset cast occurred in %s on line %d -string(1) "l" -string(1) "l" - -Warning: String offset cast occurred in %s on line %d +Illegal offset type string(1) "l" +Illegal offset type string(1) "l" - -Warning: String offset cast occurred in %s on line %d +Illegal offset type string(1) "l" +Illegal offset type Warning: Illegal string offset "7str" in %s on line %d string(1) "l" diff --git a/Zend/tests/offset_string.phpt b/Zend/tests/offset_string.phpt index 1dc7910f365e5..9c0a2c542145b 100644 --- a/Zend/tests/offset_string.phpt +++ b/Zend/tests/offset_string.phpt @@ -57,9 +57,7 @@ Warning: String offset cast occurred in %s on line %d string(1) "S" Illegal offset type string(1) "c" - -Warning: String offset cast occurred in %s on line %d -string(1) "o" +Illegal offset type Warning: Illegal string offset "15 and then some" in %s on line %d string(1) "r" diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index e992354ad0786..d1ed0c759132b 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -1342,8 +1342,7 @@ static zend_never_inline zend_long zend_check_string_offset(zval *dim, int type case IS_STRING: { /* allow errors in string offset for BC reasons */ - zend_uchar numeric_string_type = is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), &offset, NULL, true); - if (IS_LONG == numeric_string_type) { + if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), &offset, NULL, true)) { /* emit Illegal string warning on leading numerical string */ if (0 == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, false) && type != BP_VAR_UNSET) { @@ -1351,12 +1350,6 @@ static zend_never_inline zend_long zend_check_string_offset(zval *dim, int type } return offset; } - if (IS_DOUBLE == numeric_string_type) { - if (IS_DOUBLE == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, false)) { - zend_error(E_WARNING, "String offset cast occurred"); - break; - } - } zend_illegal_offset(); break; } @@ -2341,20 +2334,13 @@ static zend_always_inline void zend_fetch_dimension_address_read(zval *result, z case IS_STRING: { /* allow errors in string offset for BC reasons */ - zend_uchar numeric_string_type = is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), &offset, NULL, true); - if (IS_LONG == numeric_string_type) { + if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), &offset, NULL, true)) { /* emit Illegal string warning on leading numerical string */ if (0 == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, false)) { zend_error(E_WARNING, "Illegal string offset \"%s\"", Z_STRVAL_P(dim)); } goto out; } - if (IS_DOUBLE == numeric_string_type) { - if (IS_DOUBLE == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, false)) { - zend_error(E_WARNING, "String offset cast occurred"); - break; - } - } if (type == BP_VAR_IS) { ZVAL_NULL(result); return; diff --git a/ext/opcache/jit/zend_jit_helpers.c b/ext/opcache/jit/zend_jit_helpers.c index 7072580dd8fd1..435405d6ed7bf 100644 --- a/ext/opcache/jit/zend_jit_helpers.c +++ b/ext/opcache/jit/zend_jit_helpers.c @@ -680,20 +680,13 @@ static void ZEND_FASTCALL zend_jit_fetch_dim_str_r_helper(zval *container, zval case IS_STRING: { /* allow errors in string offset for BC reasons */ - zend_uchar numeric_string_type = is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), &offset, NULL, true); - if (IS_LONG == numeric_string_type) { + if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), &offset, NULL, true)) { /* emit Illegal string warning on leading numerical string */ if (0 == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, false)) { zend_error(E_WARNING, "Illegal string offset \"%s\"", Z_STRVAL_P(dim)); } goto out; } - if (IS_DOUBLE == numeric_string_type) { - if (IS_DOUBLE == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, false)) { - zend_error(E_WARNING, "String offset cast occurred"); - break; - } - } zend_type_error("Illegal offset type"); break; } @@ -834,8 +827,7 @@ static zend_never_inline zend_long zend_check_string_offset(zval *dim, int type) case IS_STRING: { /* allow errors in string offset for BC reasons */ - zend_uchar numeric_string_type = is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), &offset, NULL, true); - if (IS_LONG == numeric_string_type) { + if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), &offset, NULL, true)) { /* emit Illegal string warning on leading numerical string */ if (0 == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, false) && type != BP_VAR_UNSET) { @@ -843,12 +835,6 @@ static zend_never_inline zend_long zend_check_string_offset(zval *dim, int type) } return offset; } - if (IS_DOUBLE == numeric_string_type) { - if (IS_DOUBLE == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, false)) { - zend_error(E_WARNING, "String offset cast occurred"); - break; - } - } zend_type_error("Illegal offset type"); break; } diff --git a/ext/opcache/tests/jit/fetch_dim_r_003.phpt b/ext/opcache/tests/jit/fetch_dim_r_003.phpt index a14301989d8f7..7044281d6b31d 100644 --- a/ext/opcache/tests/jit/fetch_dim_r_003.phpt +++ b/ext/opcache/tests/jit/fetch_dim_r_003.phpt @@ -36,30 +36,6 @@ function foo() { $x = "2"; $y = "x"; var_dump($a[$x . $y]); - try { - var_dump($a["5.5"]); - } catch (\TypeError $e) { - echo $e->getMessage() . \PHP_EOL; - } - $x = "5."; - $y = "5"; - try { - var_dump($a[$x . $y]); - } catch (\TypeError $e) { - echo $e->getMessage() . \PHP_EOL; - } - try { - var_dump($a["5.5cx"]); - } catch (\TypeError $e) { - echo $e->getMessage() . \PHP_EOL; - } - try { - $x = "5.5"; - $y = "c"; - var_dump($a[$x . $y]); - } catch (\TypeError $e) { - echo $e->getMessage() . \PHP_EOL; - } } foo(); --EXPECTF-- @@ -82,16 +58,8 @@ string(1) "A" Illegal offset type Illegal offset type -Warning: Illegal string offset "2x" in %s on line %d +Warning: Illegal string offset "2x" in %sfetch_dim_r_003.php on line 24 string(1) "C" -Warning: Illegal string offset "2x" in %s on line %d +Warning: Illegal string offset "2x" in %sfetch_dim_r_003.php on line 27 string(1) "C" - -Warning: String offset cast occurred in %s on line %d -string(1) "F" - -Warning: String offset cast occurred in %s on line %d -string(1) "F" -Illegal offset type -Illegal offset type diff --git a/ext/opcache/tests/jit/fetch_dim_r_004.phpt b/ext/opcache/tests/jit/fetch_dim_r_004.phpt index 0cc9a6a25bf02..8902b0b625725 100644 --- a/ext/opcache/tests/jit/fetch_dim_r_004.phpt +++ b/ext/opcache/tests/jit/fetch_dim_r_004.phpt @@ -34,22 +34,6 @@ foo("2x"); $x=2; $y="x"; foo($x.$y); -foo("5.5"); -$x = "5."; -$y = "5"; -foo($x.$y); -try { - foo("5.5c"); -} catch (\TypeError $e) { - echo $e->getMessage() . \PHP_EOL; -} -try { - $x = "5.5"; - $y = "c"; - foo($x.$y); -} catch (\TypeError $e) { - echo $e->getMessage() . \PHP_EOL; -} --EXPECTF-- string(1) "A" string(1) "C" @@ -70,16 +54,8 @@ string(1) "A" Illegal offset type Illegal offset type -Warning: Illegal string offset "2x" in %s on line %d +Warning: Illegal string offset "2x" in %sfetch_dim_r_004.php on line 5 string(1) "C" -Warning: Illegal string offset "2x" in %s on line %d +Warning: Illegal string offset "2x" in %sfetch_dim_r_004.php on line 5 string(1) "C" - -Warning: String offset cast occurred in %s on line %d -string(1) "F" - -Warning: String offset cast occurred in %s on line %d -string(1) "F" -Illegal offset type -Illegal offset type From 21b98b7e612f02d9d9457fd83894675c9dcc6458 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Fri, 24 Jul 2020 21:23:40 +0100 Subject: [PATCH 07/14] Nits + better illegal string offset message --- Zend/tests/bug24773.phpt | 2 +- Zend/tests/bug31098.phpt | 4 +- Zend/tests/bug53432.phpt | 2 +- Zend/tests/indexing_001.phpt | 4 +- Zend/tests/numeric_strings/string_offset.phpt | 16 +- Zend/tests/offset_string.phpt | 10 +- Zend/tests/operator_unsupported_types.phpt | 638 +++++++++++++++++- Zend/zend_execute.c | 17 +- ext/opcache/jit/zend_jit_helpers.c | 28 +- ext/opcache/tests/jit/fetch_dim_r_003.phpt | 4 +- ext/opcache/tests/jit/fetch_dim_r_004.phpt | 4 +- tests/strings/offsets_general.phpt | 2 +- 12 files changed, 675 insertions(+), 56 deletions(-) diff --git a/Zend/tests/bug24773.phpt b/Zend/tests/bug24773.phpt index a5718e2ba0c63..4c73fd0dd00f2 100644 --- a/Zend/tests/bug24773.phpt +++ b/Zend/tests/bug24773.phpt @@ -6,7 +6,7 @@ Bug #24773 (unset() of integers treated as arrays causes a crash) unset($array["lvl1"]["lvl2"]["b"]); ?> --EXPECTF-- -Fatal error: Uncaught TypeError: Illegal offset type in %s:%d +Fatal error: Uncaught TypeError: Cannot access offset of type string on string in %s:%d Stack trace: #0 {main} thrown in %s on line %d diff --git a/Zend/tests/bug31098.phpt b/Zend/tests/bug31098.phpt index e8d0576f1982d..1cad1108c08da 100644 --- a/Zend/tests/bug31098.phpt +++ b/Zend/tests/bug31098.phpt @@ -58,7 +58,7 @@ ok Warning: Attempt to read property "wrong" on string in %s on line %d ok -Illegal offset type +Cannot access offset of type string on string ok -Illegal offset type +Cannot access offset of type string on string ok diff --git a/Zend/tests/bug53432.phpt b/Zend/tests/bug53432.phpt index af468902f2e4b..fb6b80857aa0d 100644 --- a/Zend/tests/bug53432.phpt +++ b/Zend/tests/bug53432.phpt @@ -57,7 +57,7 @@ string(6) " a" Warning: Illegal string offset -1 in %s on line %d NULL string(0) "" -Illegal offset type +Cannot access offset of type string on string string(1) "a" Error: [] operator not supported for strings string(0) "" diff --git a/Zend/tests/indexing_001.phpt b/Zend/tests/indexing_001.phpt index 300ce3e848a9e..c712b09802359 100644 --- a/Zend/tests/indexing_001.phpt +++ b/Zend/tests/indexing_001.phpt @@ -76,11 +76,11 @@ array(1) { } Warning: Array to string conversion in %s on line %d -Illegal offset type +Cannot access offset of type string on string string(0) "" Warning: Array to string conversion in %s on line %d -Illegal offset type +Cannot access offset of type string on string string(1) " " Cannot use a scalar value as an array float(0.1) diff --git a/Zend/tests/numeric_strings/string_offset.phpt b/Zend/tests/numeric_strings/string_offset.phpt index c1661f72dcc26..0c43bc1512106 100644 --- a/Zend/tests/numeric_strings/string_offset.phpt +++ b/Zend/tests/numeric_strings/string_offset.phpt @@ -39,29 +39,29 @@ echo "Done\n"; ?> --EXPECTF-- string(1) "l" -Illegal offset type +Cannot access offset of type string on string string(1) "l" -Illegal offset type +Cannot access offset of type string on string string(1) "l" -Illegal offset type +Cannot access offset of type string on string string(1) "l" -Illegal offset type +Cannot access offset of type string on string Warning: Illegal string offset "7str" in %s on line %d string(1) "l" -Illegal offset type +Cannot access offset of type string on string Warning: Illegal string offset " 7str" in %s on line %d string(1) "l" -Illegal offset type +Cannot access offset of type string on string Warning: Illegal string offset " 7 str" in %s on line %d string(1) "l" -Illegal offset type +Cannot access offset of type string on string Warning: Illegal string offset "7 str" in %s on line %d string(1) "l" -Illegal offset type +Cannot access offset of type string on string Warning: Illegal string offset "0xC" in %s on line %d string(1) "T" diff --git a/Zend/tests/offset_string.phpt b/Zend/tests/offset_string.phpt index 9c0a2c542145b..36481dccce7c1 100644 --- a/Zend/tests/offset_string.phpt +++ b/Zend/tests/offset_string.phpt @@ -55,9 +55,9 @@ string(1) "S" Warning: String offset cast occurred in %s on line %d string(1) "S" -Illegal offset type +Cannot access offset of type string on string string(1) "c" -Illegal offset type +Cannot access offset of type string on string Warning: Illegal string offset "15 and then some" in %s on line %d string(1) "r" @@ -67,9 +67,9 @@ string(1) "i" Warning: String offset cast occurred in %s on line %d string(1) "S" -Illegal offset type +Cannot access offset of type resource on string Notice: Object of class stdClass could not be converted to int in %s on line %d -Illegal offset type -Illegal offset type +Cannot access offset of type stdClass on string +Cannot access offset of type array on string Done diff --git a/Zend/tests/operator_unsupported_types.phpt b/Zend/tests/operator_unsupported_types.phpt index 9293d1b9a6b30..aab98f7168f38 100644 --- a/Zend/tests/operator_unsupported_types.phpt +++ b/Zend/tests/operator_unsupported_types.phpt @@ -24,6 +24,7 @@ $illegalValues = [ '[]', 'new stdClass', 'STDOUT', + '"foo"', ]; $legalValues = [ 'null', @@ -32,7 +33,7 @@ $legalValues = [ '2', '3.5', '"123"', - '"foo"', // Semi-legal + '"123foo"', // Semi-legal ]; set_error_handler(function($errno, $errstr) { @@ -128,12 +129,19 @@ BINARY OP: No error for [] + [] Unsupported operand types: array + stdClass Unsupported operand types: array + resource +Unsupported operand types: array + string Unsupported operand types: stdClass + array Unsupported operand types: stdClass + stdClass Unsupported operand types: stdClass + resource +Unsupported operand types: stdClass + string Unsupported operand types: resource + array Unsupported operand types: resource + stdClass Unsupported operand types: resource + resource +Unsupported operand types: resource + string +Unsupported operand types: string + array +Unsupported operand types: string + stdClass +Unsupported operand types: string + resource +Unsupported operand types: string + string Unsupported operand types: array + null Unsupported operand types: null + array Unsupported operand types: array + bool @@ -147,6 +155,7 @@ Unsupported operand types: float + array Unsupported operand types: array + string Unsupported operand types: string + array Unsupported operand types: array + string +Warning: A non-numeric value encountered Unsupported operand types: string + array Unsupported operand types: stdClass + null Unsupported operand types: null + stdClass @@ -161,6 +170,7 @@ Unsupported operand types: float + stdClass Unsupported operand types: stdClass + string Unsupported operand types: string + stdClass Unsupported operand types: stdClass + string +Warning: A non-numeric value encountered Unsupported operand types: string + stdClass Unsupported operand types: resource + null Unsupported operand types: null + resource @@ -175,16 +185,39 @@ Unsupported operand types: float + resource Unsupported operand types: resource + string Unsupported operand types: string + resource Unsupported operand types: resource + string +Warning: A non-numeric value encountered Unsupported operand types: string + resource +Unsupported operand types: string + null +Unsupported operand types: null + string +Unsupported operand types: string + bool +Unsupported operand types: bool + string +Unsupported operand types: string + bool +Unsupported operand types: bool + string +Unsupported operand types: string + int +Unsupported operand types: int + string +Unsupported operand types: string + float +Unsupported operand types: float + string +Unsupported operand types: string + string +Unsupported operand types: string + string +Unsupported operand types: string + string +Warning: A non-numeric value encountered +Unsupported operand types: string + string Unsupported operand types: array - array Unsupported operand types: array - stdClass Unsupported operand types: array - resource +Unsupported operand types: array - string Unsupported operand types: stdClass - array Unsupported operand types: stdClass - stdClass Unsupported operand types: stdClass - resource +Unsupported operand types: stdClass - string Unsupported operand types: resource - array Unsupported operand types: resource - stdClass Unsupported operand types: resource - resource +Unsupported operand types: resource - string +Unsupported operand types: string - array +Unsupported operand types: string - stdClass +Unsupported operand types: string - resource +Unsupported operand types: string - string Unsupported operand types: array - null Unsupported operand types: null - array Unsupported operand types: array - bool @@ -198,6 +231,7 @@ Unsupported operand types: float - array Unsupported operand types: array - string Unsupported operand types: string - array Unsupported operand types: array - string +Warning: A non-numeric value encountered Unsupported operand types: string - array Unsupported operand types: stdClass - null Unsupported operand types: null - stdClass @@ -212,6 +246,7 @@ Unsupported operand types: float - stdClass Unsupported operand types: stdClass - string Unsupported operand types: string - stdClass Unsupported operand types: stdClass - string +Warning: A non-numeric value encountered Unsupported operand types: string - stdClass Unsupported operand types: resource - null Unsupported operand types: null - resource @@ -226,16 +261,39 @@ Unsupported operand types: float - resource Unsupported operand types: resource - string Unsupported operand types: string - resource Unsupported operand types: resource - string +Warning: A non-numeric value encountered Unsupported operand types: string - resource +Unsupported operand types: string - null +Unsupported operand types: null - string +Unsupported operand types: string - bool +Unsupported operand types: bool - string +Unsupported operand types: string - bool +Unsupported operand types: bool - string +Unsupported operand types: string - int +Unsupported operand types: int - string +Unsupported operand types: string - float +Unsupported operand types: float - string +Unsupported operand types: string - string +Unsupported operand types: string - string +Unsupported operand types: string - string +Warning: A non-numeric value encountered +Unsupported operand types: string - string Unsupported operand types: array * array Unsupported operand types: stdClass * array Unsupported operand types: resource * array +Unsupported operand types: array * string Unsupported operand types: stdClass * array Unsupported operand types: stdClass * stdClass Unsupported operand types: stdClass * resource +Unsupported operand types: stdClass * string Unsupported operand types: resource * array Unsupported operand types: stdClass * resource Unsupported operand types: resource * resource +Unsupported operand types: resource * string +Unsupported operand types: string * array +Unsupported operand types: stdClass * string +Unsupported operand types: resource * string +Unsupported operand types: string * string Unsupported operand types: array * null Unsupported operand types: null * array Unsupported operand types: array * bool @@ -249,6 +307,7 @@ Unsupported operand types: float * array Unsupported operand types: array * string Unsupported operand types: string * array Unsupported operand types: array * string +Warning: A non-numeric value encountered Unsupported operand types: string * array Unsupported operand types: stdClass * null Unsupported operand types: stdClass * null @@ -278,15 +337,37 @@ Unsupported operand types: resource * string Unsupported operand types: resource * string Unsupported operand types: resource * string Unsupported operand types: resource * string +Unsupported operand types: string * null +Unsupported operand types: null * string +Unsupported operand types: string * bool +Unsupported operand types: bool * string +Unsupported operand types: string * bool +Unsupported operand types: bool * string +Unsupported operand types: string * int +Unsupported operand types: int * string +Unsupported operand types: string * float +Unsupported operand types: float * string +Unsupported operand types: string * string +Unsupported operand types: string * string +Unsupported operand types: string * string +Warning: A non-numeric value encountered +Unsupported operand types: string * string Unsupported operand types: array / array Unsupported operand types: array / stdClass Unsupported operand types: array / resource +Unsupported operand types: array / string Unsupported operand types: stdClass / array Unsupported operand types: stdClass / stdClass Unsupported operand types: stdClass / resource +Unsupported operand types: stdClass / string Unsupported operand types: resource / array Unsupported operand types: resource / stdClass Unsupported operand types: resource / resource +Unsupported operand types: resource / string +Unsupported operand types: string / array +Unsupported operand types: string / stdClass +Unsupported operand types: string / resource +Unsupported operand types: string / string Unsupported operand types: array / null Unsupported operand types: null / array Unsupported operand types: array / bool @@ -300,6 +381,7 @@ Unsupported operand types: float / array Unsupported operand types: array / string Unsupported operand types: string / array Unsupported operand types: array / string +Warning: A non-numeric value encountered Unsupported operand types: string / array Unsupported operand types: stdClass / null Unsupported operand types: null / stdClass @@ -314,6 +396,7 @@ Unsupported operand types: float / stdClass Unsupported operand types: stdClass / string Unsupported operand types: string / stdClass Unsupported operand types: stdClass / string +Warning: A non-numeric value encountered Unsupported operand types: string / stdClass Unsupported operand types: resource / null Unsupported operand types: null / resource @@ -328,16 +411,39 @@ Unsupported operand types: float / resource Unsupported operand types: resource / string Unsupported operand types: string / resource Unsupported operand types: resource / string +Warning: A non-numeric value encountered Unsupported operand types: string / resource +Unsupported operand types: string / null +Unsupported operand types: null / string +Unsupported operand types: string / bool +Unsupported operand types: bool / string +Unsupported operand types: string / bool +Unsupported operand types: bool / string +Unsupported operand types: string / int +Unsupported operand types: int / string +Unsupported operand types: string / float +Unsupported operand types: float / string +Unsupported operand types: string / string +Unsupported operand types: string / string +Unsupported operand types: string / string +Warning: A non-numeric value encountered +Unsupported operand types: string / string Unsupported operand types: array % array Unsupported operand types: array % stdClass Unsupported operand types: array % resource +Unsupported operand types: array % string Unsupported operand types: stdClass % array Unsupported operand types: stdClass % stdClass Unsupported operand types: stdClass % resource +Unsupported operand types: stdClass % string Unsupported operand types: resource % array Unsupported operand types: resource % stdClass Unsupported operand types: resource % resource +Unsupported operand types: resource % string +Unsupported operand types: string % array +Unsupported operand types: string % stdClass +Unsupported operand types: string % resource +Unsupported operand types: string % string Unsupported operand types: array % null Unsupported operand types: null % array Unsupported operand types: array % bool @@ -351,6 +457,7 @@ Unsupported operand types: float % array Unsupported operand types: array % string Unsupported operand types: string % array Unsupported operand types: array % string +Warning: A non-numeric value encountered Unsupported operand types: string % array Unsupported operand types: stdClass % null Unsupported operand types: null % stdClass @@ -365,6 +472,7 @@ Unsupported operand types: float % stdClass Unsupported operand types: stdClass % string Unsupported operand types: string % stdClass Unsupported operand types: stdClass % string +Warning: A non-numeric value encountered Unsupported operand types: string % stdClass Unsupported operand types: resource % null Unsupported operand types: null % resource @@ -379,16 +487,39 @@ Unsupported operand types: float % resource Unsupported operand types: resource % string Unsupported operand types: string % resource Unsupported operand types: resource % string +Warning: A non-numeric value encountered Unsupported operand types: string % resource +Unsupported operand types: string % null +Unsupported operand types: null % string +Unsupported operand types: string % bool +Unsupported operand types: bool % string +Unsupported operand types: string % bool +Unsupported operand types: bool % string +Unsupported operand types: string % int +Unsupported operand types: int % string +Unsupported operand types: string % float +Unsupported operand types: float % string +Unsupported operand types: string % string +Unsupported operand types: string % string +Unsupported operand types: string % string +Warning: A non-numeric value encountered +Unsupported operand types: string % string Unsupported operand types: array ** array Unsupported operand types: array ** stdClass Unsupported operand types: array ** resource +Unsupported operand types: array ** string Unsupported operand types: stdClass ** array Unsupported operand types: stdClass ** stdClass Unsupported operand types: stdClass ** resource +Unsupported operand types: stdClass ** string Unsupported operand types: resource ** array Unsupported operand types: resource ** stdClass Unsupported operand types: resource ** resource +Unsupported operand types: resource ** string +Unsupported operand types: string ** array +Unsupported operand types: string ** stdClass +Unsupported operand types: string ** resource +Unsupported operand types: string ** string Unsupported operand types: array ** null Unsupported operand types: null ** array Unsupported operand types: array ** bool @@ -402,6 +533,7 @@ Unsupported operand types: float ** array Unsupported operand types: array ** string Unsupported operand types: string ** array Unsupported operand types: array ** string +Warning: A non-numeric value encountered Unsupported operand types: string ** array Unsupported operand types: stdClass ** null Unsupported operand types: null ** stdClass @@ -416,6 +548,7 @@ Unsupported operand types: float ** stdClass Unsupported operand types: stdClass ** string Unsupported operand types: string ** stdClass Unsupported operand types: stdClass ** string +Warning: A non-numeric value encountered Unsupported operand types: string ** stdClass Unsupported operand types: resource ** null Unsupported operand types: null ** resource @@ -430,16 +563,39 @@ Unsupported operand types: float ** resource Unsupported operand types: resource ** string Unsupported operand types: string ** resource Unsupported operand types: resource ** string +Warning: A non-numeric value encountered Unsupported operand types: string ** resource +Unsupported operand types: string ** null +Unsupported operand types: null ** string +Unsupported operand types: string ** bool +Unsupported operand types: bool ** string +Unsupported operand types: string ** bool +Unsupported operand types: bool ** string +Unsupported operand types: string ** int +Unsupported operand types: int ** string +Unsupported operand types: string ** float +Unsupported operand types: float ** string +Unsupported operand types: string ** string +Unsupported operand types: string ** string +Unsupported operand types: string ** string +Warning: A non-numeric value encountered +Unsupported operand types: string ** string Unsupported operand types: array << array Unsupported operand types: array << stdClass Unsupported operand types: array << resource +Unsupported operand types: array << string Unsupported operand types: stdClass << array Unsupported operand types: stdClass << stdClass Unsupported operand types: stdClass << resource +Unsupported operand types: stdClass << string Unsupported operand types: resource << array Unsupported operand types: resource << stdClass Unsupported operand types: resource << resource +Unsupported operand types: resource << string +Unsupported operand types: string << array +Unsupported operand types: string << stdClass +Unsupported operand types: string << resource +Unsupported operand types: string << string Unsupported operand types: array << null Unsupported operand types: null << array Unsupported operand types: array << bool @@ -453,6 +609,7 @@ Unsupported operand types: float << array Unsupported operand types: array << string Unsupported operand types: string << array Unsupported operand types: array << string +Warning: A non-numeric value encountered Unsupported operand types: string << array Unsupported operand types: stdClass << null Unsupported operand types: null << stdClass @@ -467,6 +624,7 @@ Unsupported operand types: float << stdClass Unsupported operand types: stdClass << string Unsupported operand types: string << stdClass Unsupported operand types: stdClass << string +Warning: A non-numeric value encountered Unsupported operand types: string << stdClass Unsupported operand types: resource << null Unsupported operand types: null << resource @@ -481,16 +639,39 @@ Unsupported operand types: float << resource Unsupported operand types: resource << string Unsupported operand types: string << resource Unsupported operand types: resource << string +Warning: A non-numeric value encountered Unsupported operand types: string << resource +Unsupported operand types: string << null +Unsupported operand types: null << string +Unsupported operand types: string << bool +Unsupported operand types: bool << string +Unsupported operand types: string << bool +Unsupported operand types: bool << string +Unsupported operand types: string << int +Unsupported operand types: int << string +Unsupported operand types: string << float +Unsupported operand types: float << string +Unsupported operand types: string << string +Unsupported operand types: string << string +Unsupported operand types: string << string +Warning: A non-numeric value encountered +Unsupported operand types: string << string Unsupported operand types: array >> array Unsupported operand types: array >> stdClass Unsupported operand types: array >> resource +Unsupported operand types: array >> string Unsupported operand types: stdClass >> array Unsupported operand types: stdClass >> stdClass Unsupported operand types: stdClass >> resource +Unsupported operand types: stdClass >> string Unsupported operand types: resource >> array Unsupported operand types: resource >> stdClass Unsupported operand types: resource >> resource +Unsupported operand types: resource >> string +Unsupported operand types: string >> array +Unsupported operand types: string >> stdClass +Unsupported operand types: string >> resource +Unsupported operand types: string >> string Unsupported operand types: array >> null Unsupported operand types: null >> array Unsupported operand types: array >> bool @@ -504,6 +685,7 @@ Unsupported operand types: float >> array Unsupported operand types: array >> string Unsupported operand types: string >> array Unsupported operand types: array >> string +Warning: A non-numeric value encountered Unsupported operand types: string >> array Unsupported operand types: stdClass >> null Unsupported operand types: null >> stdClass @@ -518,6 +700,7 @@ Unsupported operand types: float >> stdClass Unsupported operand types: stdClass >> string Unsupported operand types: string >> stdClass Unsupported operand types: stdClass >> string +Warning: A non-numeric value encountered Unsupported operand types: string >> stdClass Unsupported operand types: resource >> null Unsupported operand types: null >> resource @@ -532,16 +715,39 @@ Unsupported operand types: float >> resource Unsupported operand types: resource >> string Unsupported operand types: string >> resource Unsupported operand types: resource >> string +Warning: A non-numeric value encountered Unsupported operand types: string >> resource +Unsupported operand types: string >> null +Unsupported operand types: null >> string +Unsupported operand types: string >> bool +Unsupported operand types: bool >> string +Unsupported operand types: string >> bool +Unsupported operand types: bool >> string +Unsupported operand types: string >> int +Unsupported operand types: int >> string +Unsupported operand types: string >> float +Unsupported operand types: float >> string +Unsupported operand types: string >> string +Unsupported operand types: string >> string +Unsupported operand types: string >> string +Warning: A non-numeric value encountered +Unsupported operand types: string >> string Unsupported operand types: array & array Unsupported operand types: stdClass & array Unsupported operand types: resource & array +Unsupported operand types: array & string Unsupported operand types: stdClass & array Unsupported operand types: stdClass & stdClass Unsupported operand types: stdClass & resource +Unsupported operand types: stdClass & string Unsupported operand types: resource & array Unsupported operand types: stdClass & resource Unsupported operand types: resource & resource +Unsupported operand types: resource & string +Unsupported operand types: string & array +Unsupported operand types: stdClass & string +Unsupported operand types: resource & string +No error for "foo" & "foo" Unsupported operand types: array & null Unsupported operand types: null & array Unsupported operand types: array & bool @@ -555,6 +761,7 @@ Unsupported operand types: float & array Unsupported operand types: array & string Unsupported operand types: string & array Unsupported operand types: array & string +Warning: A non-numeric value encountered Unsupported operand types: string & array Unsupported operand types: stdClass & null Unsupported operand types: stdClass & null @@ -584,15 +791,36 @@ Unsupported operand types: resource & string Unsupported operand types: resource & string Unsupported operand types: resource & string Unsupported operand types: resource & string +Unsupported operand types: string & null +Unsupported operand types: null & string +Unsupported operand types: string & bool +Unsupported operand types: bool & string +Unsupported operand types: string & bool +Unsupported operand types: bool & string +Unsupported operand types: string & int +Unsupported operand types: int & string +Unsupported operand types: string & float +Unsupported operand types: float & string +No error for "foo" & "123" +No error for "123" & "foo" +No error for "foo" & "123foo" +No error for "123foo" & "foo" Unsupported operand types: array | array Unsupported operand types: stdClass | array Unsupported operand types: resource | array +Unsupported operand types: array | string Unsupported operand types: stdClass | array Unsupported operand types: stdClass | stdClass Unsupported operand types: stdClass | resource +Unsupported operand types: stdClass | string Unsupported operand types: resource | array Unsupported operand types: stdClass | resource Unsupported operand types: resource | resource +Unsupported operand types: resource | string +Unsupported operand types: string | array +Unsupported operand types: stdClass | string +Unsupported operand types: resource | string +No error for "foo" | "foo" Unsupported operand types: array | null Unsupported operand types: null | array Unsupported operand types: array | bool @@ -606,6 +834,7 @@ Unsupported operand types: float | array Unsupported operand types: array | string Unsupported operand types: string | array Unsupported operand types: array | string +Warning: A non-numeric value encountered Unsupported operand types: string | array Unsupported operand types: stdClass | null Unsupported operand types: stdClass | null @@ -635,15 +864,36 @@ Unsupported operand types: resource | string Unsupported operand types: resource | string Unsupported operand types: resource | string Unsupported operand types: resource | string +Unsupported operand types: string | null +Unsupported operand types: null | string +Unsupported operand types: string | bool +Unsupported operand types: bool | string +Unsupported operand types: string | bool +Unsupported operand types: bool | string +Unsupported operand types: string | int +Unsupported operand types: int | string +Unsupported operand types: string | float +Unsupported operand types: float | string +No error for "foo" | "123" +No error for "123" | "foo" +No error for "foo" | "123foo" +No error for "123foo" | "foo" Unsupported operand types: array ^ array Unsupported operand types: stdClass ^ array Unsupported operand types: resource ^ array +Unsupported operand types: array ^ string Unsupported operand types: stdClass ^ array Unsupported operand types: stdClass ^ stdClass Unsupported operand types: stdClass ^ resource +Unsupported operand types: stdClass ^ string Unsupported operand types: resource ^ array Unsupported operand types: stdClass ^ resource Unsupported operand types: resource ^ resource +Unsupported operand types: resource ^ string +Unsupported operand types: string ^ array +Unsupported operand types: stdClass ^ string +Unsupported operand types: resource ^ string +No error for "foo" ^ "foo" Unsupported operand types: array ^ null Unsupported operand types: null ^ array Unsupported operand types: array ^ bool @@ -657,6 +907,7 @@ Unsupported operand types: float ^ array Unsupported operand types: array ^ string Unsupported operand types: string ^ array Unsupported operand types: array ^ string +Warning: A non-numeric value encountered Unsupported operand types: string ^ array Unsupported operand types: stdClass ^ null Unsupported operand types: stdClass ^ null @@ -686,15 +937,36 @@ Unsupported operand types: resource ^ string Unsupported operand types: resource ^ string Unsupported operand types: resource ^ string Unsupported operand types: resource ^ string +Unsupported operand types: string ^ null +Unsupported operand types: null ^ string +Unsupported operand types: string ^ bool +Unsupported operand types: bool ^ string +Unsupported operand types: string ^ bool +Unsupported operand types: bool ^ string +Unsupported operand types: string ^ int +Unsupported operand types: int ^ string +Unsupported operand types: string ^ float +Unsupported operand types: float ^ string +No error for "foo" ^ "123" +No error for "123" ^ "foo" +No error for "foo" ^ "123foo" +No error for "123foo" ^ "foo" No error for [] xor [] No error for [] xor new stdClass No error for [] xor STDOUT +No error for [] xor "foo" No error for new stdClass xor [] No error for new stdClass xor new stdClass No error for new stdClass xor STDOUT +No error for new stdClass xor "foo" No error for STDOUT xor [] No error for STDOUT xor new stdClass No error for STDOUT xor STDOUT +No error for STDOUT xor "foo" +No error for "foo" xor [] +No error for "foo" xor new stdClass +No error for "foo" xor STDOUT +No error for "foo" xor "foo" No error for [] xor null No error for null xor [] No error for [] xor true @@ -707,8 +979,8 @@ No error for [] xor 3.5 No error for 3.5 xor [] No error for [] xor "123" No error for "123" xor [] -No error for [] xor "foo" -No error for "foo" xor [] +No error for [] xor "123foo" +No error for "123foo" xor [] No error for new stdClass xor null No error for null xor new stdClass No error for new stdClass xor true @@ -721,8 +993,8 @@ No error for new stdClass xor 3.5 No error for 3.5 xor new stdClass No error for new stdClass xor "123" No error for "123" xor new stdClass -No error for new stdClass xor "foo" -No error for "foo" xor new stdClass +No error for new stdClass xor "123foo" +No error for "123foo" xor new stdClass No error for STDOUT xor null No error for null xor STDOUT No error for STDOUT xor true @@ -735,8 +1007,22 @@ No error for STDOUT xor 3.5 No error for 3.5 xor STDOUT No error for STDOUT xor "123" No error for "123" xor STDOUT -No error for STDOUT xor "foo" -No error for "foo" xor STDOUT +No error for STDOUT xor "123foo" +No error for "123foo" xor STDOUT +No error for "foo" xor null +No error for null xor "foo" +No error for "foo" xor true +No error for true xor "foo" +No error for "foo" xor false +No error for false xor "foo" +No error for "foo" xor 2 +No error for 2 xor "foo" +No error for "foo" xor 3.5 +No error for 3.5 xor "foo" +No error for "foo" xor "123" +No error for "123" xor "foo" +No error for "foo" xor "123foo" +No error for "123foo" xor "foo" Warning: Array to string conversion Warning: Array to string conversion No error for [] . [] @@ -745,6 +1031,9 @@ Object of class stdClass could not be converted to string Warning: Array to string conversion No error for [] . STDOUT Warning: Array to string conversion +No error for [] . "foo" +Warning: Array to string conversion +Object of class stdClass could not be converted to string Object of class stdClass could not be converted to string Object of class stdClass could not be converted to string Object of class stdClass could not be converted to string @@ -752,6 +1041,12 @@ Warning: Array to string conversion No error for STDOUT . [] Object of class stdClass could not be converted to string No error for STDOUT . STDOUT +No error for STDOUT . "foo" +Warning: Array to string conversion +No error for "foo" . [] +Object of class stdClass could not be converted to string +No error for "foo" . STDOUT +No error for "foo" . "foo" Warning: Array to string conversion No error for [] . null Warning: Array to string conversion @@ -777,9 +1072,9 @@ No error for [] . "123" Warning: Array to string conversion No error for "123" . [] Warning: Array to string conversion -No error for [] . "foo" +No error for [] . "123foo" Warning: Array to string conversion -No error for "foo" . [] +No error for "123foo" . [] Object of class stdClass could not be converted to string Object of class stdClass could not be converted to string Object of class stdClass could not be converted to string @@ -806,20 +1101,41 @@ No error for STDOUT . 3.5 No error for 3.5 . STDOUT No error for STDOUT . "123" No error for "123" . STDOUT -No error for STDOUT . "foo" -No error for "foo" . STDOUT +No error for STDOUT . "123foo" +No error for "123foo" . STDOUT +No error for "foo" . null +No error for null . "foo" +No error for "foo" . true +No error for true . "foo" +No error for "foo" . false +No error for false . "foo" +No error for "foo" . 2 +No error for 2 . "foo" +No error for "foo" . 3.5 +No error for 3.5 . "foo" +No error for "foo" . "123" +No error for "123" . "foo" +No error for "foo" . "123foo" +No error for "123foo" . "foo" ASSIGN OP: No error for [] += [] Unsupported operand types: array + stdClass Unsupported operand types: array + resource +Unsupported operand types: array + string Unsupported operand types: stdClass + array Unsupported operand types: stdClass + stdClass Unsupported operand types: stdClass + resource +Unsupported operand types: stdClass + string Unsupported operand types: resource + array Unsupported operand types: resource + stdClass Unsupported operand types: resource + resource +Unsupported operand types: resource + string +Unsupported operand types: string + array +Unsupported operand types: string + stdClass +Unsupported operand types: string + resource +Unsupported operand types: string + string Unsupported operand types: array + null Unsupported operand types: null + array Unsupported operand types: array + bool @@ -833,6 +1149,7 @@ Unsupported operand types: float + array Unsupported operand types: array + string Unsupported operand types: string + array Unsupported operand types: array + string +Warning: A non-numeric value encountered Unsupported operand types: string + array Unsupported operand types: stdClass + null Unsupported operand types: null + stdClass @@ -847,6 +1164,7 @@ Unsupported operand types: float + stdClass Unsupported operand types: stdClass + string Unsupported operand types: string + stdClass Unsupported operand types: stdClass + string +Warning: A non-numeric value encountered Unsupported operand types: string + stdClass Unsupported operand types: resource + null Unsupported operand types: null + resource @@ -861,16 +1179,39 @@ Unsupported operand types: float + resource Unsupported operand types: resource + string Unsupported operand types: string + resource Unsupported operand types: resource + string +Warning: A non-numeric value encountered Unsupported operand types: string + resource +Unsupported operand types: string + null +Unsupported operand types: null + string +Unsupported operand types: string + bool +Unsupported operand types: bool + string +Unsupported operand types: string + bool +Unsupported operand types: bool + string +Unsupported operand types: string + int +Unsupported operand types: int + string +Unsupported operand types: string + float +Unsupported operand types: float + string +Unsupported operand types: string + string +Unsupported operand types: string + string +Unsupported operand types: string + string +Warning: A non-numeric value encountered +Unsupported operand types: string + string Unsupported operand types: array - array Unsupported operand types: array - stdClass Unsupported operand types: array - resource +Unsupported operand types: array - string Unsupported operand types: stdClass - array Unsupported operand types: stdClass - stdClass Unsupported operand types: stdClass - resource +Unsupported operand types: stdClass - string Unsupported operand types: resource - array Unsupported operand types: resource - stdClass Unsupported operand types: resource - resource +Unsupported operand types: resource - string +Unsupported operand types: string - array +Unsupported operand types: string - stdClass +Unsupported operand types: string - resource +Unsupported operand types: string - string Unsupported operand types: array - null Unsupported operand types: null - array Unsupported operand types: array - bool @@ -884,6 +1225,7 @@ Unsupported operand types: float - array Unsupported operand types: array - string Unsupported operand types: string - array Unsupported operand types: array - string +Warning: A non-numeric value encountered Unsupported operand types: string - array Unsupported operand types: stdClass - null Unsupported operand types: null - stdClass @@ -898,6 +1240,7 @@ Unsupported operand types: float - stdClass Unsupported operand types: stdClass - string Unsupported operand types: string - stdClass Unsupported operand types: stdClass - string +Warning: A non-numeric value encountered Unsupported operand types: string - stdClass Unsupported operand types: resource - null Unsupported operand types: null - resource @@ -912,16 +1255,39 @@ Unsupported operand types: float - resource Unsupported operand types: resource - string Unsupported operand types: string - resource Unsupported operand types: resource - string +Warning: A non-numeric value encountered Unsupported operand types: string - resource +Unsupported operand types: string - null +Unsupported operand types: null - string +Unsupported operand types: string - bool +Unsupported operand types: bool - string +Unsupported operand types: string - bool +Unsupported operand types: bool - string +Unsupported operand types: string - int +Unsupported operand types: int - string +Unsupported operand types: string - float +Unsupported operand types: float - string +Unsupported operand types: string - string +Unsupported operand types: string - string +Unsupported operand types: string - string +Warning: A non-numeric value encountered +Unsupported operand types: string - string Unsupported operand types: array * array Unsupported operand types: array * stdClass Unsupported operand types: array * resource +Unsupported operand types: array * string Unsupported operand types: stdClass * array Unsupported operand types: stdClass * stdClass Unsupported operand types: stdClass * resource +Unsupported operand types: stdClass * string Unsupported operand types: resource * array Unsupported operand types: resource * stdClass Unsupported operand types: resource * resource +Unsupported operand types: resource * string +Unsupported operand types: string * array +Unsupported operand types: string * stdClass +Unsupported operand types: string * resource +Unsupported operand types: string * string Unsupported operand types: array * null Unsupported operand types: null * array Unsupported operand types: array * bool @@ -935,6 +1301,7 @@ Unsupported operand types: float * array Unsupported operand types: array * string Unsupported operand types: string * array Unsupported operand types: array * string +Warning: A non-numeric value encountered Unsupported operand types: string * array Unsupported operand types: stdClass * null Unsupported operand types: null * stdClass @@ -949,6 +1316,7 @@ Unsupported operand types: float * stdClass Unsupported operand types: stdClass * string Unsupported operand types: string * stdClass Unsupported operand types: stdClass * string +Warning: A non-numeric value encountered Unsupported operand types: string * stdClass Unsupported operand types: resource * null Unsupported operand types: null * resource @@ -963,16 +1331,39 @@ Unsupported operand types: float * resource Unsupported operand types: resource * string Unsupported operand types: string * resource Unsupported operand types: resource * string +Warning: A non-numeric value encountered Unsupported operand types: string * resource +Unsupported operand types: string * null +Unsupported operand types: null * string +Unsupported operand types: string * bool +Unsupported operand types: bool * string +Unsupported operand types: string * bool +Unsupported operand types: bool * string +Unsupported operand types: string * int +Unsupported operand types: int * string +Unsupported operand types: string * float +Unsupported operand types: float * string +Unsupported operand types: string * string +Unsupported operand types: string * string +Unsupported operand types: string * string +Warning: A non-numeric value encountered +Unsupported operand types: string * string Unsupported operand types: array / array Unsupported operand types: array / stdClass Unsupported operand types: array / resource +Unsupported operand types: array / string Unsupported operand types: stdClass / array Unsupported operand types: stdClass / stdClass Unsupported operand types: stdClass / resource +Unsupported operand types: stdClass / string Unsupported operand types: resource / array Unsupported operand types: resource / stdClass Unsupported operand types: resource / resource +Unsupported operand types: resource / string +Unsupported operand types: string / array +Unsupported operand types: string / stdClass +Unsupported operand types: string / resource +Unsupported operand types: string / string Unsupported operand types: array / null Unsupported operand types: null / array Unsupported operand types: array / bool @@ -986,6 +1377,7 @@ Unsupported operand types: float / array Unsupported operand types: array / string Unsupported operand types: string / array Unsupported operand types: array / string +Warning: A non-numeric value encountered Unsupported operand types: string / array Unsupported operand types: stdClass / null Unsupported operand types: null / stdClass @@ -1000,6 +1392,7 @@ Unsupported operand types: float / stdClass Unsupported operand types: stdClass / string Unsupported operand types: string / stdClass Unsupported operand types: stdClass / string +Warning: A non-numeric value encountered Unsupported operand types: string / stdClass Unsupported operand types: resource / null Unsupported operand types: null / resource @@ -1014,16 +1407,39 @@ Unsupported operand types: float / resource Unsupported operand types: resource / string Unsupported operand types: string / resource Unsupported operand types: resource / string +Warning: A non-numeric value encountered Unsupported operand types: string / resource +Unsupported operand types: string / null +Unsupported operand types: null / string +Unsupported operand types: string / bool +Unsupported operand types: bool / string +Unsupported operand types: string / bool +Unsupported operand types: bool / string +Unsupported operand types: string / int +Unsupported operand types: int / string +Unsupported operand types: string / float +Unsupported operand types: float / string +Unsupported operand types: string / string +Unsupported operand types: string / string +Unsupported operand types: string / string +Warning: A non-numeric value encountered +Unsupported operand types: string / string Unsupported operand types: array % array Unsupported operand types: array % stdClass Unsupported operand types: array % resource +Unsupported operand types: array % string Unsupported operand types: stdClass % array Unsupported operand types: stdClass % stdClass Unsupported operand types: stdClass % resource +Unsupported operand types: stdClass % string Unsupported operand types: resource % array Unsupported operand types: resource % stdClass Unsupported operand types: resource % resource +Unsupported operand types: resource % string +Unsupported operand types: string % array +Unsupported operand types: string % stdClass +Unsupported operand types: string % resource +Unsupported operand types: string % string Unsupported operand types: array % null Unsupported operand types: null % array Unsupported operand types: array % bool @@ -1037,6 +1453,7 @@ Unsupported operand types: float % array Unsupported operand types: array % string Unsupported operand types: string % array Unsupported operand types: array % string +Warning: A non-numeric value encountered Unsupported operand types: string % array Unsupported operand types: stdClass % null Unsupported operand types: null % stdClass @@ -1051,6 +1468,7 @@ Unsupported operand types: float % stdClass Unsupported operand types: stdClass % string Unsupported operand types: string % stdClass Unsupported operand types: stdClass % string +Warning: A non-numeric value encountered Unsupported operand types: string % stdClass Unsupported operand types: resource % null Unsupported operand types: null % resource @@ -1065,16 +1483,39 @@ Unsupported operand types: float % resource Unsupported operand types: resource % string Unsupported operand types: string % resource Unsupported operand types: resource % string +Warning: A non-numeric value encountered Unsupported operand types: string % resource +Unsupported operand types: string % null +Unsupported operand types: null % string +Unsupported operand types: string % bool +Unsupported operand types: bool % string +Unsupported operand types: string % bool +Unsupported operand types: bool % string +Unsupported operand types: string % int +Unsupported operand types: int % string +Unsupported operand types: string % float +Unsupported operand types: float % string +Unsupported operand types: string % string +Unsupported operand types: string % string +Unsupported operand types: string % string +Warning: A non-numeric value encountered +Unsupported operand types: string % string Unsupported operand types: array ** array Unsupported operand types: array ** stdClass Unsupported operand types: array ** resource +Unsupported operand types: array ** string Unsupported operand types: stdClass ** array Unsupported operand types: stdClass ** stdClass Unsupported operand types: stdClass ** resource +Unsupported operand types: stdClass ** string Unsupported operand types: resource ** array Unsupported operand types: resource ** stdClass Unsupported operand types: resource ** resource +Unsupported operand types: resource ** string +Unsupported operand types: string ** array +Unsupported operand types: string ** stdClass +Unsupported operand types: string ** resource +Unsupported operand types: string ** string Unsupported operand types: array ** null Unsupported operand types: null ** array Unsupported operand types: array ** bool @@ -1088,6 +1529,7 @@ Unsupported operand types: float ** array Unsupported operand types: array ** string Unsupported operand types: string ** array Unsupported operand types: array ** string +Warning: A non-numeric value encountered Unsupported operand types: string ** array Unsupported operand types: stdClass ** null Unsupported operand types: null ** stdClass @@ -1102,6 +1544,7 @@ Unsupported operand types: float ** stdClass Unsupported operand types: stdClass ** string Unsupported operand types: string ** stdClass Unsupported operand types: stdClass ** string +Warning: A non-numeric value encountered Unsupported operand types: string ** stdClass Unsupported operand types: resource ** null Unsupported operand types: null ** resource @@ -1116,16 +1559,39 @@ Unsupported operand types: float ** resource Unsupported operand types: resource ** string Unsupported operand types: string ** resource Unsupported operand types: resource ** string +Warning: A non-numeric value encountered Unsupported operand types: string ** resource +Unsupported operand types: string ** null +Unsupported operand types: null ** string +Unsupported operand types: string ** bool +Unsupported operand types: bool ** string +Unsupported operand types: string ** bool +Unsupported operand types: bool ** string +Unsupported operand types: string ** int +Unsupported operand types: int ** string +Unsupported operand types: string ** float +Unsupported operand types: float ** string +Unsupported operand types: string ** string +Unsupported operand types: string ** string +Unsupported operand types: string ** string +Warning: A non-numeric value encountered +Unsupported operand types: string ** string Unsupported operand types: array << array Unsupported operand types: array << stdClass Unsupported operand types: array << resource +Unsupported operand types: array << string Unsupported operand types: stdClass << array Unsupported operand types: stdClass << stdClass Unsupported operand types: stdClass << resource +Unsupported operand types: stdClass << string Unsupported operand types: resource << array Unsupported operand types: resource << stdClass Unsupported operand types: resource << resource +Unsupported operand types: resource << string +Unsupported operand types: string << array +Unsupported operand types: string << stdClass +Unsupported operand types: string << resource +Unsupported operand types: string << string Unsupported operand types: array << null Unsupported operand types: null << array Unsupported operand types: array << bool @@ -1139,6 +1605,7 @@ Unsupported operand types: float << array Unsupported operand types: array << string Unsupported operand types: string << array Unsupported operand types: array << string +Warning: A non-numeric value encountered Unsupported operand types: string << array Unsupported operand types: stdClass << null Unsupported operand types: null << stdClass @@ -1153,6 +1620,7 @@ Unsupported operand types: float << stdClass Unsupported operand types: stdClass << string Unsupported operand types: string << stdClass Unsupported operand types: stdClass << string +Warning: A non-numeric value encountered Unsupported operand types: string << stdClass Unsupported operand types: resource << null Unsupported operand types: null << resource @@ -1167,16 +1635,39 @@ Unsupported operand types: float << resource Unsupported operand types: resource << string Unsupported operand types: string << resource Unsupported operand types: resource << string +Warning: A non-numeric value encountered Unsupported operand types: string << resource +Unsupported operand types: string << null +Unsupported operand types: null << string +Unsupported operand types: string << bool +Unsupported operand types: bool << string +Unsupported operand types: string << bool +Unsupported operand types: bool << string +Unsupported operand types: string << int +Unsupported operand types: int << string +Unsupported operand types: string << float +Unsupported operand types: float << string +Unsupported operand types: string << string +Unsupported operand types: string << string +Unsupported operand types: string << string +Warning: A non-numeric value encountered +Unsupported operand types: string << string Unsupported operand types: array >> array Unsupported operand types: array >> stdClass Unsupported operand types: array >> resource +Unsupported operand types: array >> string Unsupported operand types: stdClass >> array Unsupported operand types: stdClass >> stdClass Unsupported operand types: stdClass >> resource +Unsupported operand types: stdClass >> string Unsupported operand types: resource >> array Unsupported operand types: resource >> stdClass Unsupported operand types: resource >> resource +Unsupported operand types: resource >> string +Unsupported operand types: string >> array +Unsupported operand types: string >> stdClass +Unsupported operand types: string >> resource +Unsupported operand types: string >> string Unsupported operand types: array >> null Unsupported operand types: null >> array Unsupported operand types: array >> bool @@ -1190,6 +1681,7 @@ Unsupported operand types: float >> array Unsupported operand types: array >> string Unsupported operand types: string >> array Unsupported operand types: array >> string +Warning: A non-numeric value encountered Unsupported operand types: string >> array Unsupported operand types: stdClass >> null Unsupported operand types: null >> stdClass @@ -1204,6 +1696,7 @@ Unsupported operand types: float >> stdClass Unsupported operand types: stdClass >> string Unsupported operand types: string >> stdClass Unsupported operand types: stdClass >> string +Warning: A non-numeric value encountered Unsupported operand types: string >> stdClass Unsupported operand types: resource >> null Unsupported operand types: null >> resource @@ -1218,16 +1711,39 @@ Unsupported operand types: float >> resource Unsupported operand types: resource >> string Unsupported operand types: string >> resource Unsupported operand types: resource >> string +Warning: A non-numeric value encountered Unsupported operand types: string >> resource +Unsupported operand types: string >> null +Unsupported operand types: null >> string +Unsupported operand types: string >> bool +Unsupported operand types: bool >> string +Unsupported operand types: string >> bool +Unsupported operand types: bool >> string +Unsupported operand types: string >> int +Unsupported operand types: int >> string +Unsupported operand types: string >> float +Unsupported operand types: float >> string +Unsupported operand types: string >> string +Unsupported operand types: string >> string +Unsupported operand types: string >> string +Warning: A non-numeric value encountered +Unsupported operand types: string >> string Unsupported operand types: array & array Unsupported operand types: array & stdClass Unsupported operand types: array & resource +Unsupported operand types: array & string Unsupported operand types: stdClass & array Unsupported operand types: stdClass & stdClass Unsupported operand types: stdClass & resource +Unsupported operand types: stdClass & string Unsupported operand types: resource & array Unsupported operand types: resource & stdClass Unsupported operand types: resource & resource +Unsupported operand types: resource & string +Unsupported operand types: string & array +Unsupported operand types: string & stdClass +Unsupported operand types: string & resource +No error for "foo" &= "foo" Unsupported operand types: array & null Unsupported operand types: null & array Unsupported operand types: array & bool @@ -1241,6 +1757,7 @@ Unsupported operand types: float & array Unsupported operand types: array & string Unsupported operand types: string & array Unsupported operand types: array & string +Warning: A non-numeric value encountered Unsupported operand types: string & array Unsupported operand types: stdClass & null Unsupported operand types: null & stdClass @@ -1255,6 +1772,7 @@ Unsupported operand types: float & stdClass Unsupported operand types: stdClass & string Unsupported operand types: string & stdClass Unsupported operand types: stdClass & string +Warning: A non-numeric value encountered Unsupported operand types: string & stdClass Unsupported operand types: resource & null Unsupported operand types: null & resource @@ -1269,16 +1787,38 @@ Unsupported operand types: float & resource Unsupported operand types: resource & string Unsupported operand types: string & resource Unsupported operand types: resource & string +Warning: A non-numeric value encountered Unsupported operand types: string & resource +Unsupported operand types: string & null +Unsupported operand types: null & string +Unsupported operand types: string & bool +Unsupported operand types: bool & string +Unsupported operand types: string & bool +Unsupported operand types: bool & string +Unsupported operand types: string & int +Unsupported operand types: int & string +Unsupported operand types: string & float +Unsupported operand types: float & string +No error for "foo" &= "123" +No error for "123" &= "foo" +No error for "foo" &= "123foo" +No error for "123foo" &= "foo" Unsupported operand types: array | array Unsupported operand types: array | stdClass Unsupported operand types: array | resource +Unsupported operand types: array | string Unsupported operand types: stdClass | array Unsupported operand types: stdClass | stdClass Unsupported operand types: stdClass | resource +Unsupported operand types: stdClass | string Unsupported operand types: resource | array Unsupported operand types: resource | stdClass Unsupported operand types: resource | resource +Unsupported operand types: resource | string +Unsupported operand types: string | array +Unsupported operand types: string | stdClass +Unsupported operand types: string | resource +No error for "foo" |= "foo" Unsupported operand types: array | null Unsupported operand types: null | array Unsupported operand types: array | bool @@ -1292,6 +1832,7 @@ Unsupported operand types: float | array Unsupported operand types: array | string Unsupported operand types: string | array Unsupported operand types: array | string +Warning: A non-numeric value encountered Unsupported operand types: string | array Unsupported operand types: stdClass | null Unsupported operand types: null | stdClass @@ -1306,6 +1847,7 @@ Unsupported operand types: float | stdClass Unsupported operand types: stdClass | string Unsupported operand types: string | stdClass Unsupported operand types: stdClass | string +Warning: A non-numeric value encountered Unsupported operand types: string | stdClass Unsupported operand types: resource | null Unsupported operand types: null | resource @@ -1320,16 +1862,38 @@ Unsupported operand types: float | resource Unsupported operand types: resource | string Unsupported operand types: string | resource Unsupported operand types: resource | string +Warning: A non-numeric value encountered Unsupported operand types: string | resource +Unsupported operand types: string | null +Unsupported operand types: null | string +Unsupported operand types: string | bool +Unsupported operand types: bool | string +Unsupported operand types: string | bool +Unsupported operand types: bool | string +Unsupported operand types: string | int +Unsupported operand types: int | string +Unsupported operand types: string | float +Unsupported operand types: float | string +No error for "foo" |= "123" +No error for "123" |= "foo" +No error for "foo" |= "123foo" +No error for "123foo" |= "foo" Unsupported operand types: array ^ array Unsupported operand types: array ^ stdClass Unsupported operand types: array ^ resource +Unsupported operand types: array ^ string Unsupported operand types: stdClass ^ array Unsupported operand types: stdClass ^ stdClass Unsupported operand types: stdClass ^ resource +Unsupported operand types: stdClass ^ string Unsupported operand types: resource ^ array Unsupported operand types: resource ^ stdClass Unsupported operand types: resource ^ resource +Unsupported operand types: resource ^ string +Unsupported operand types: string ^ array +Unsupported operand types: string ^ stdClass +Unsupported operand types: string ^ resource +No error for "foo" ^= "foo" Unsupported operand types: array ^ null Unsupported operand types: null ^ array Unsupported operand types: array ^ bool @@ -1343,6 +1907,7 @@ Unsupported operand types: float ^ array Unsupported operand types: array ^ string Unsupported operand types: string ^ array Unsupported operand types: array ^ string +Warning: A non-numeric value encountered Unsupported operand types: string ^ array Unsupported operand types: stdClass ^ null Unsupported operand types: null ^ stdClass @@ -1357,6 +1922,7 @@ Unsupported operand types: float ^ stdClass Unsupported operand types: stdClass ^ string Unsupported operand types: string ^ stdClass Unsupported operand types: stdClass ^ string +Warning: A non-numeric value encountered Unsupported operand types: string ^ stdClass Unsupported operand types: resource ^ null Unsupported operand types: null ^ resource @@ -1371,7 +1937,22 @@ Unsupported operand types: float ^ resource Unsupported operand types: resource ^ string Unsupported operand types: string ^ resource Unsupported operand types: resource ^ string +Warning: A non-numeric value encountered Unsupported operand types: string ^ resource +Unsupported operand types: string ^ null +Unsupported operand types: null ^ string +Unsupported operand types: string ^ bool +Unsupported operand types: bool ^ string +Unsupported operand types: string ^ bool +Unsupported operand types: bool ^ string +Unsupported operand types: string ^ int +Unsupported operand types: int ^ string +Unsupported operand types: string ^ float +Unsupported operand types: float ^ string +No error for "foo" ^= "123" +No error for "123" ^= "foo" +No error for "foo" ^= "123foo" +No error for "123foo" ^= "foo" Warning: Array to string conversion Warning: Array to string conversion No error for [] .= [] @@ -1379,6 +1960,9 @@ Warning: Array to string conversion Object of class stdClass could not be converted to string Warning: Array to string conversion No error for [] .= STDOUT +Warning: Array to string conversion +No error for [] .= "foo" +Object of class stdClass could not be converted to string Object of class stdClass could not be converted to string Object of class stdClass could not be converted to string Object of class stdClass could not be converted to string @@ -1386,6 +1970,12 @@ Warning: Array to string conversion No error for STDOUT .= [] Object of class stdClass could not be converted to string No error for STDOUT .= STDOUT +No error for STDOUT .= "foo" +Warning: Array to string conversion +No error for "foo" .= [] +Object of class stdClass could not be converted to string +No error for "foo" .= STDOUT +No error for "foo" .= "foo" Warning: Array to string conversion No error for [] .= null Warning: Array to string conversion @@ -1411,9 +2001,9 @@ No error for [] .= "123" Warning: Array to string conversion No error for "123" .= [] Warning: Array to string conversion -No error for [] .= "foo" +No error for [] .= "123foo" Warning: Array to string conversion -No error for "foo" .= [] +No error for "123foo" .= [] Object of class stdClass could not be converted to string Object of class stdClass could not be converted to string Object of class stdClass could not be converted to string @@ -1440,14 +2030,30 @@ No error for STDOUT .= 3.5 No error for 3.5 .= STDOUT No error for STDOUT .= "123" No error for "123" .= STDOUT -No error for STDOUT .= "foo" -No error for "foo" .= STDOUT +No error for STDOUT .= "123foo" +No error for "123foo" .= STDOUT +No error for "foo" .= null +No error for null .= "foo" +No error for "foo" .= true +No error for true .= "foo" +No error for "foo" .= false +No error for false .= "foo" +No error for "foo" .= 2 +No error for 2 .= "foo" +No error for "foo" .= 3.5 +No error for 3.5 .= "foo" +No error for "foo" .= "123" +No error for "123" .= "foo" +No error for "foo" .= "123foo" +No error for "123foo" .= "foo" UNARY OP: Cannot perform bitwise not on array Cannot perform bitwise not on stdClass Cannot perform bitwise not on resource +Warning: Undefined variable $copy +No error for ~ INCDEC: @@ -1457,3 +2063,5 @@ Cannot increment stdClass Cannot decrement stdClass Cannot increment resource Cannot decrement resource +No error for fop++ +No error for foo-- diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index d1ed0c759132b..0bc1a3c9f9a13 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -770,10 +770,10 @@ static zend_bool zend_verify_weak_scalar_type_hint_no_sideeffect(uint32_t type_m double dval; zend_bool bval; - if (type_mask & MAY_BE_LONG && zend_parse_arg_long_weak(arg, &lval)) { + if ((type_mask & MAY_BE_LONG) && zend_parse_arg_long_weak(arg, &lval)) { return 1; } - if (type_mask & MAY_BE_DOUBLE && zend_parse_arg_double_weak(arg, &dval)) { + if ((type_mask & MAY_BE_DOUBLE) && zend_parse_arg_double_weak(arg, &dval)) { return 1; } /* We don't call cast_object here, because this check must be side-effect free. As this @@ -1247,6 +1247,11 @@ static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_illegal_offset(void) zend_type_error("Illegal offset type"); } +static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_illegal_string_offset(const zval *offset) +{ + zend_type_error("Cannot access offset of type %s on string", zend_zval_type_name(offset)); +} + static zend_never_inline void zend_assign_to_object_dim(zval *object, zval *dim, zval *value OPLINE_DC EXECUTE_DATA_DC) { Z_OBJ_HT_P(object)->write_dimension(Z_OBJ_P(object), dim, value); @@ -1350,7 +1355,7 @@ static zend_never_inline zend_long zend_check_string_offset(zval *dim, int type } return offset; } - zend_illegal_offset(); + zend_illegal_string_offset(dim); break; } case IS_UNDEF: @@ -1365,7 +1370,7 @@ static zend_never_inline zend_long zend_check_string_offset(zval *dim, int type dim = Z_REFVAL_P(dim); goto try_again; default: - zend_illegal_offset(); + zend_illegal_string_offset(dim); break; } @@ -2345,7 +2350,7 @@ static zend_always_inline void zend_fetch_dimension_address_read(zval *result, z ZVAL_NULL(result); return; } - zend_illegal_offset(); + zend_illegal_string_offset(dim); break; } case IS_UNDEF: @@ -2362,7 +2367,7 @@ static zend_always_inline void zend_fetch_dimension_address_read(zval *result, z dim = Z_REFVAL_P(dim); goto try_string_offset; default: - zend_illegal_offset(); + zend_illegal_string_offset(dim); break; } diff --git a/ext/opcache/jit/zend_jit_helpers.c b/ext/opcache/jit/zend_jit_helpers.c index 435405d6ed7bf..5cfb83689a1b3 100644 --- a/ext/opcache/jit/zend_jit_helpers.c +++ b/ext/opcache/jit/zend_jit_helpers.c @@ -27,6 +27,12 @@ static ZEND_COLD void undef_result_after_exception() { } } +static ZEND_COLD void zend_jit_illegal_string_offset(zval *offset) +{ + zend_type_error("Cannot access offset of type %s on string", zend_zval_type_name(offset)); +} + + static zend_never_inline zend_function* ZEND_FASTCALL _zend_jit_init_func_run_time_cache(const zend_op_array *op_array) /* {{{ */ { void **run_time_cache; @@ -350,8 +356,8 @@ static void ZEND_FASTCALL zend_jit_fetch_dim_r_helper(zend_array *ht, zval *dim, hval = 1; goto num_index; default: - zend_type_error("Illegal offset type"); - ZVAL_NULL(result); + zend_jit_illegal_string_offset(dim); + undef_result_after_exception(); return; } @@ -422,8 +428,8 @@ static void ZEND_FASTCALL zend_jit_fetch_dim_is_helper(zend_array *ht, zval *dim hval = 1; goto num_index; default: - zend_type_error("Illegal offset type"); - ZVAL_NULL(result); + zend_jit_illegal_string_offset(dim); + undef_result_after_exception(); return; } @@ -560,7 +566,7 @@ static zval* ZEND_FASTCALL zend_jit_fetch_dim_rw_helper(zend_array *ht, zval *di hval = 1; goto num_index; default: - zend_type_error("Illegal offset type"); + zend_jit_illegal_string_offset(dim); undef_result_after_exception(); return NULL; } @@ -641,7 +647,7 @@ static zval* ZEND_FASTCALL zend_jit_fetch_dim_w_helper(zend_array *ht, zval *dim hval = 1; goto num_index; default: - zend_type_error("Illegal offset type"); + zend_jit_illegal_string_offset(dim); undef_result_after_exception(); return NULL; } @@ -687,7 +693,7 @@ static void ZEND_FASTCALL zend_jit_fetch_dim_str_r_helper(zval *container, zval } goto out; } - zend_type_error("Illegal offset type"); + zend_jit_illegal_string_offset(dim); break; } case IS_UNDEF: @@ -702,7 +708,7 @@ static void ZEND_FASTCALL zend_jit_fetch_dim_str_r_helper(zval *container, zval dim = Z_REFVAL_P(dim); goto try_string_offset; default: - zend_type_error("Illegal offset type"); + zend_jit_illegal_string_offset(dim); break; } @@ -751,7 +757,7 @@ static void ZEND_FASTCALL zend_jit_fetch_dim_str_is_helper(zval *container, zval dim = Z_REFVAL_P(dim); goto try_string_offset; default: - zend_type_error("Illegal offset type"); + zend_jit_illegal_string_offset(dim); break; } @@ -835,7 +841,7 @@ static zend_never_inline zend_long zend_check_string_offset(zval *dim, int type) } return offset; } - zend_type_error("Illegal offset type"); + zend_jit_illegal_string_offset(dim); break; } case IS_UNDEF: @@ -850,7 +856,7 @@ static zend_never_inline zend_long zend_check_string_offset(zval *dim, int type) dim = Z_REFVAL_P(dim); goto try_again; default: - zend_type_error("Illegal offset type"); + zend_jit_illegal_string_offset(dim); break; } diff --git a/ext/opcache/tests/jit/fetch_dim_r_003.phpt b/ext/opcache/tests/jit/fetch_dim_r_003.phpt index 7044281d6b31d..e0fb75ee48474 100644 --- a/ext/opcache/tests/jit/fetch_dim_r_003.phpt +++ b/ext/opcache/tests/jit/fetch_dim_r_003.phpt @@ -55,8 +55,8 @@ string(1) "B" Warning: String offset cast occurred in %s on line %d string(1) "A" -Illegal offset type -Illegal offset type +Cannot access offset of type string on string +Cannot access offset of type string on string Warning: Illegal string offset "2x" in %sfetch_dim_r_003.php on line 24 string(1) "C" diff --git a/ext/opcache/tests/jit/fetch_dim_r_004.phpt b/ext/opcache/tests/jit/fetch_dim_r_004.phpt index 8902b0b625725..23c6bf4d0ff94 100644 --- a/ext/opcache/tests/jit/fetch_dim_r_004.phpt +++ b/ext/opcache/tests/jit/fetch_dim_r_004.phpt @@ -51,8 +51,8 @@ string(1) "B" Warning: String offset cast occurred in %s on line %d string(1) "A" -Illegal offset type -Illegal offset type +Cannot access offset of type string on string +Cannot access offset of type string on string Warning: Illegal string offset "2x" in %sfetch_dim_r_004.php on line 5 string(1) "C" diff --git a/tests/strings/offsets_general.phpt b/tests/strings/offsets_general.phpt index e19afb1e0d199..16960eac95228 100644 --- a/tests/strings/offsets_general.phpt +++ b/tests/strings/offsets_general.phpt @@ -23,5 +23,5 @@ string(1) "f" string(1) "o" bool(true) bool(true) -Illegal offset type +Cannot access offset of type string on string bool(false) From e520e2fd3c9ab3352bb689f15176b8dda39e132b Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Fri, 24 Jul 2020 22:37:07 +0100 Subject: [PATCH 08/14] Better way to deal with remain of leading numeric strings --- Zend/zend_execute.c | 19 +++++----- Zend/zend_ini_scanner.l | 2 +- Zend/zend_operators.c | 78 ++++++++++++++++++++++------------------- Zend/zend_operators.h | 8 ++--- 4 files changed, 56 insertions(+), 51 deletions(-) diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 0bc1a3c9f9a13..27eebf47f561c 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -1346,11 +1346,11 @@ static zend_never_inline zend_long zend_check_string_offset(zval *dim, int type switch(Z_TYPE_P(dim)) { case IS_STRING: { - /* allow errors in string offset for BC reasons */ - if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), &offset, NULL, true)) { - /* emit Illegal string warning on leading numerical string */ - if (0 == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, false) - && type != BP_VAR_UNSET) { + bool trailing_data = false; + /* For BC reasons we allow errors so that we can warn on leading numeric string */ + if (IS_LONG == is_numeric_string_ex(Z_STRVAL_P(dim), Z_STRLEN_P(dim), &offset, NULL, + /* allow errors */ true, NULL, &trailing_data)) { + if (UNEXPECTED(trailing_data) && type != BP_VAR_UNSET) { zend_error(E_WARNING, "Illegal string offset \"%s\"", Z_STRVAL_P(dim)); } return offset; @@ -2338,10 +2338,11 @@ static zend_always_inline void zend_fetch_dimension_address_read(zval *result, z switch (Z_TYPE_P(dim)) { case IS_STRING: { - /* allow errors in string offset for BC reasons */ - if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), &offset, NULL, true)) { - /* emit Illegal string warning on leading numerical string */ - if (0 == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, false)) { + bool trailing_data = false; + /* For BC reasons we allow errors so that we can warn on leading numeric string */ + if (IS_LONG == is_numeric_string_ex(Z_STRVAL_P(dim), Z_STRLEN_P(dim), &offset, + NULL, /* allow errors */ true, NULL, &trailing_data)) { + if (UNEXPECTED(trailing_data)) { zend_error(E_WARNING, "Illegal string offset \"%s\"", Z_STRVAL_P(dim)); } goto out; diff --git a/Zend/zend_ini_scanner.l b/Zend/zend_ini_scanner.l index e8641faa49584..c8efb1f144d95 100644 --- a/Zend/zend_ini_scanner.l +++ b/Zend/zend_ini_scanner.l @@ -158,7 +158,7 @@ static inline int convert_to_number(zval *retval, const char *str, const int str zend_long lval; double dval; - if ((type = is_numeric_string_ex(str, str_len, &lval, &dval, 0, &overflow)) != 0) { + if ((type = is_numeric_string_ex(str, str_len, &lval, &dval, 0, &overflow, NULL)) != 0) { if (type == IS_LONG) { ZVAL_LONG(retval, lval); return SUCCESS; diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index b079bbb3d9b8f..5f40513a1b703 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -243,21 +243,22 @@ static zend_never_inline int ZEND_FASTCALL _zendi_try_convert_scalar_to_number(z ZVAL_LONG(holder, 1); return SUCCESS; case IS_STRING: - if ((Z_TYPE_INFO_P(holder) = is_numeric_string(Z_STRVAL_P(op), Z_STRLEN_P(op), - &Z_LVAL_P(holder), &Z_DVAL_P(holder), false)) == 0) { - /* Not strictly numeric - * For BC reasons warn on leading numeric strings */ - if ((Z_TYPE_INFO_P(holder) = is_numeric_string(Z_STRVAL_P(op), Z_STRLEN_P(op), - &Z_LVAL_P(holder), &Z_DVAL_P(holder), /* allow errors */ true)) == 0) { - /* Will lead to invalid OP type error */ - return FAILURE; - } + { + bool trailing_data = false; + /* For BC reasons we allow errors so that we can warn on leading numeric string */ + if (0 == (Z_TYPE_INFO_P(holder) = is_numeric_string_ex(Z_STRVAL_P(op), Z_STRLEN_P(op), + &Z_LVAL_P(holder), &Z_DVAL_P(holder), /* allow errors */ true, NULL, &trailing_data))) { + /* Will lead to invalid OP type error */ + return FAILURE; + } + if (UNEXPECTED(trailing_data)) { zend_error(E_WARNING, "A non-numeric value encountered"); if (UNEXPECTED(EG(exception))) { return FAILURE; } } return SUCCESS; + } case IS_OBJECT: if (Z_OBJ_HT_P(op)->cast_object(Z_OBJ_P(op), holder, _IS_NUMBER) == FAILURE || EG(exception)) { @@ -300,32 +301,29 @@ static zend_never_inline zend_long ZEND_FASTCALL zendi_try_get_long(zval *op, ze zend_uchar type; zend_long lval; double dval; - if (0 == (type = is_numeric_string(Z_STRVAL_P(op), Z_STRLEN_P(op), &lval, &dval, false))) { - /* Not strictly numeric - * For BC reasons warn on leading numeric strings */ - if (0 == (type = is_numeric_string(Z_STRVAL_P(op), Z_STRLEN_P(op), &lval, &dval, - /* allow errors */ true))) { - /* Will lead to invalid OP type error */ - *failed = 1; - return 0; - } - zend_error(E_WARNING, "A non-numeric value encountered"); - if (UNEXPECTED(EG(exception))) { - *failed = 1; - } - if (type == IS_LONG) { - return lval; - } else { - /* Previously we used strtol here, not is_numeric_string, - * and strtol gives you LONG_MAX/_MIN on overflow. - * We use use saturating conversion to emulate strtol()'s - * behaviour. - */ - return zend_dval_to_lval_cap(dval); - } + bool trailing_data = false; + + /* For BC reasons we allow errors so that we can warn on leading numeric string */ + type = is_numeric_string_ex(Z_STRVAL_P(op), Z_STRLEN_P(op), &lval, &dval, + /* allow errors */ true, NULL, &trailing_data); + if (type == 0) { + *failed = 1; + return 0; } else if (EXPECTED(type == IS_LONG)) { + if (UNEXPECTED(trailing_data)) { + zend_error(E_WARNING, "A non-numeric value encountered"); + if (UNEXPECTED(EG(exception))) { + *failed = 1; + } + } return lval; } else { + if (trailing_data) { + zend_error(E_WARNING, "A non-numeric value encountered"); + if (UNEXPECTED(EG(exception))) { + *failed = 1; + } + } /* Previously we used strtol here, not is_numeric_string, * and strtol gives you LONG_MAX/_MIN on overflow. * We use use saturating conversion to emulate strtol()'s @@ -2831,8 +2829,8 @@ ZEND_API int ZEND_FASTCALL zendi_smart_streq(zend_string *s1, zend_string *s2) / zend_long lval1 = 0, lval2 = 0; double dval1 = 0.0, dval2 = 0.0; - if ((ret1 = is_numeric_string_ex(s1->val, s1->len, &lval1, &dval1, false, &oflow1)) && - (ret2 = is_numeric_string_ex(s2->val, s2->len, &lval2, &dval2, false, &oflow2))) { + if ((ret1 = is_numeric_string_ex(s1->val, s1->len, &lval1, &dval1, false, &oflow1, NULL)) && + (ret2 = is_numeric_string_ex(s2->val, s2->len, &lval2, &dval2, false, &oflow2, NULL))) { #if ZEND_ULONG_MAX == 0xFFFFFFFF if (oflow1 != 0 && oflow1 == oflow2 && dval1 - dval2 == 0. && ((oflow1 == 1 && dval1 > 9007199254740991. /*0x1FFFFFFFFFFFFF*/) @@ -2879,8 +2877,8 @@ ZEND_API int ZEND_FASTCALL zendi_smart_strcmp(zend_string *s1, zend_string *s2) zend_long lval1 = 0, lval2 = 0; double dval1 = 0.0, dval2 = 0.0; - if ((ret1 = is_numeric_string_ex(s1->val, s1->len, &lval1, &dval1, false, &oflow1)) && - (ret2 = is_numeric_string_ex(s2->val, s2->len, &lval2, &dval2, false, &oflow2))) { + if ((ret1 = is_numeric_string_ex(s1->val, s1->len, &lval1, &dval1, false, &oflow1, NULL)) && + (ret2 = is_numeric_string_ex(s2->val, s2->len, &lval2, &dval2, false, &oflow2, NULL))) { #if ZEND_ULONG_MAX == 0xFFFFFFFF if (oflow1 != 0 && oflow1 == oflow2 && dval1 - dval2 == 0. && ((oflow1 == 1 && dval1 > 9007199254740991. /*0x1FFFFFFFFFFFFF*/) @@ -2982,7 +2980,7 @@ ZEND_API zend_uchar ZEND_FASTCALL is_numeric_str_function(const zend_string *str /* }}} */ ZEND_API zend_uchar ZEND_FASTCALL _is_numeric_string_ex(const char *str, size_t length, zend_long *lval, - double *dval, bool allow_errors, int *oflow_info) /* {{{ */ + double *dval, bool allow_errors, int *oflow_info, bool *trailing_data) /* {{{ */ { const char *ptr; int digits = 0, dp_or_e = 0; @@ -2998,6 +2996,9 @@ ZEND_API zend_uchar ZEND_FASTCALL _is_numeric_string_ex(const char *str, size_t if (oflow_info != NULL) { *oflow_info = 0; } + if (trailing_data != NULL) { + *trailing_data = false; + } /* Skip any whitespace * This is much faster than the isspace() function */ @@ -3077,6 +3078,9 @@ ZEND_API zend_uchar ZEND_FASTCALL _is_numeric_string_ex(const char *str, size_t if (!allow_errors) { return 0; } + if (trailing_data != NULL) { + *trailing_data = true; + } } } diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index 246b403ba424a..9eb064b125d7a 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -87,7 +87,7 @@ static zend_always_inline zend_bool instanceof_function( * if the integer is larger than ZEND_LONG_MAX and -1 if it's smaller than ZEND_LONG_MIN. */ ZEND_API zend_uchar ZEND_FASTCALL _is_numeric_string_ex(const char *str, size_t length, zend_long *lval, - double *dval, bool allow_errors, int *oflow_info); + double *dval, bool allow_errors, int *oflow_info, bool *trailing_data); ZEND_API const char* ZEND_FASTCALL zend_memnstr_ex(const char *haystack, const char *needle, size_t needle_len, const char *end); ZEND_API const char* ZEND_FASTCALL zend_memnrstr_ex(const char *haystack, const char *needle, size_t needle_len, const char *end); @@ -137,16 +137,16 @@ static zend_always_inline zend_long zend_dval_to_lval_cap(double d) #define ZEND_IS_XDIGIT(c) (((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f')) static zend_always_inline zend_uchar is_numeric_string_ex(const char *str, size_t length, zend_long *lval, - double *dval, bool allow_errors, int *oflow_info) + double *dval, bool allow_errors, int *oflow_info, bool *trailing_data) { if (*str > '9') { return 0; } - return _is_numeric_string_ex(str, length, lval, dval, allow_errors, oflow_info); + return _is_numeric_string_ex(str, length, lval, dval, allow_errors, oflow_info, trailing_data); } static zend_always_inline zend_uchar is_numeric_string(const char *str, size_t length, zend_long *lval, double *dval, bool allow_errors) { - return is_numeric_string_ex(str, length, lval, dval, allow_errors, NULL); + return is_numeric_string_ex(str, length, lval, dval, allow_errors, NULL, NULL); } ZEND_API zend_uchar ZEND_FASTCALL is_numeric_str_function(const zend_string *str, zend_long *lval, double *dval); From 6465972ce526686b4687c01936f03e560b301048 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sat, 25 Jul 2020 01:57:29 +0100 Subject: [PATCH 09/14] Fix compiler error in PDO --- ext/pdo/pdo_stmt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index 6bb7ca7322725..ce008d09c7f87 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -2302,7 +2302,7 @@ static zval *row_prop_read(zend_object *object, zend_string *name, int type, voi ZVAL_NULL(rv); if (stmt) { - if (is_numeric_string_ex(ZSTR_VAL(name), ZSTR_LEN(name), &lval, NULL, 0, NULL) == IS_LONG) { + if (is_numeric_string(ZSTR_VAL(name), ZSTR_LEN(name), &lval, NULL, 0) == IS_LONG) { if (lval >= 0 && lval < stmt->column_count) { fetch_value(stmt, rv, lval, NULL); } @@ -2340,7 +2340,7 @@ static zval *row_dim_read(zend_object *object, zval *member, int type, zval *rv) fetch_value(stmt, rv, Z_LVAL_P(member), NULL); } } else if (Z_TYPE_P(member) == IS_STRING - && is_numeric_string_ex(Z_STRVAL_P(member), Z_STRLEN_P(member), &lval, NULL, 0, NULL) == IS_LONG) { + && is_numeric_string(Z_STRVAL_P(member), Z_STRLEN_P(member), &lval, NULL, 0) == IS_LONG) { if (lval >= 0 && lval < stmt->column_count) { fetch_value(stmt, rv, lval, NULL); } @@ -2387,7 +2387,7 @@ static int row_prop_exists(zend_object *object, zend_string *name, int check_emp zend_long lval; if (stmt) { - if (is_numeric_string_ex(ZSTR_VAL(name), ZSTR_LEN(name), &lval, NULL, 0, NULL) == IS_LONG) { + if (is_numeric_string(ZSTR_VAL(name), ZSTR_LEN(name), &lval, NULL, 0) == IS_LONG) { return lval >=0 && lval < stmt->column_count; } @@ -2422,7 +2422,7 @@ static int row_dim_exists(zend_object *object, zval *member, int check_empty) if (Z_TYPE_P(member) == IS_LONG) { return Z_LVAL_P(member) >= 0 && Z_LVAL_P(member) < stmt->column_count; } else if (Z_TYPE_P(member) == IS_STRING) { - if (is_numeric_string_ex(Z_STRVAL_P(member), Z_STRLEN_P(member), &lval, NULL, 0, NULL) == IS_LONG) { + if (is_numeric_string(Z_STRVAL_P(member), Z_STRLEN_P(member), &lval, NULL, 0) == IS_LONG) { return lval >=0 && lval < stmt->column_count; } } else { From a3d805eae9876c34b446f449857a9cc9c93c5879 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Tue, 28 Jul 2020 14:52:58 +0100 Subject: [PATCH 10/14] Fix 32bit by not caring about the value of bitshift --- .../invalid_numeric_string_must_generate_warning_assign.phpt | 2 +- .../invalid_numeric_strings_must_generate_warning.phpt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Zend/tests/numeric_strings/invalid_numeric_string_must_generate_warning_assign.phpt b/Zend/tests/numeric_strings/invalid_numeric_string_must_generate_warning_assign.phpt index 4a1100296c01c..51df22634869c 100644 --- a/Zend/tests/numeric_strings/invalid_numeric_string_must_generate_warning_assign.phpt +++ b/Zend/tests/numeric_strings/invalid_numeric_string_must_generate_warning_assign.phpt @@ -205,7 +205,7 @@ TypeError: Unsupported operand types: string % string Warning: A non-numeric value encountered in %s on line %d Warning: A non-numeric value encountered in %s on line %d -int(360639813910528) +int(%d) Unsupported operand types: string << string string(4) "quis" --- diff --git a/Zend/tests/numeric_strings/invalid_numeric_strings_must_generate_warning.phpt b/Zend/tests/numeric_strings/invalid_numeric_strings_must_generate_warning.phpt index f24298245faa6..3ffe78a119e96 100644 --- a/Zend/tests/numeric_strings/invalid_numeric_strings_must_generate_warning.phpt +++ b/Zend/tests/numeric_strings/invalid_numeric_strings_must_generate_warning.phpt @@ -158,7 +158,7 @@ TypeError: Unsupported operand types: string % string Warning: A non-numeric value encountered in %s on line %d Warning: A non-numeric value encountered in %s on line %d -int(360639813910528) +int(%d) Unsupported operand types: string << string --- From 815544fc8b18c299decf4d2e0f1e29e0490c18e5 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Tue, 28 Jul 2020 15:05:53 +0100 Subject: [PATCH 11/14] Use is_numeric_str_function() more often --- Zend/zend_execute.c | 2 +- Zend/zend_operators.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 27eebf47f561c..51d4a0d00388e 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -728,7 +728,7 @@ static zend_bool zend_verify_weak_scalar_type_hint(uint32_t type_mask, zval *arg /* For an int|float union type and string value, * determine chosen type by is_numeric_string() semantics. */ if ((type_mask & MAY_BE_DOUBLE) && Z_TYPE_P(arg) == IS_STRING) { - zend_uchar type = is_numeric_string(Z_STRVAL_P(arg), Z_STRLEN_P(arg), &lval, &dval, false); + zend_uchar type = is_numeric_str_function(Z_STR_P(arg), &lval, &dval); if (type == IS_LONG) { zend_string_release(Z_STR_P(arg)); ZVAL_LONG(arg, lval); diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 5f40513a1b703..24a4cc842a9d2 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -2417,7 +2417,7 @@ ZEND_API int ZEND_FASTCALL increment_function(zval *op1) /* {{{ */ zend_long lval; double dval; - switch (is_numeric_string(Z_STRVAL_P(op1), Z_STRLEN_P(op1), &lval, &dval, false)) { + switch (is_numeric_str_function(Z_STR_P(op1), &lval, &dval)) { case IS_LONG: zval_ptr_dtor_str(op1); if (lval == ZEND_LONG_MAX) { @@ -2484,7 +2484,7 @@ ZEND_API int ZEND_FASTCALL decrement_function(zval *op1) /* {{{ */ ZVAL_LONG(op1, -1); break; } - switch (is_numeric_string(Z_STRVAL_P(op1), Z_STRLEN_P(op1), &lval, &dval, false)) { + switch (is_numeric_str_function(Z_STR_P(op1), &lval, &dval)) { case IS_LONG: zval_ptr_dtor_str(op1); if (lval == ZEND_LONG_MIN) { From 5a068ac17d986bdf0192505ed43b1a5cc09a784f Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Tue, 28 Jul 2020 15:08:08 +0100 Subject: [PATCH 12/14] Extract duplicate warning check --- Zend/zend_operators.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 24a4cc842a9d2..fba6c6337a7eb 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -309,21 +309,16 @@ static zend_never_inline zend_long ZEND_FASTCALL zendi_try_get_long(zval *op, ze if (type == 0) { *failed = 1; return 0; - } else if (EXPECTED(type == IS_LONG)) { - if (UNEXPECTED(trailing_data)) { - zend_error(E_WARNING, "A non-numeric value encountered"); - if (UNEXPECTED(EG(exception))) { - *failed = 1; - } + } + if (UNEXPECTED(trailing_data)) { + zend_error(E_WARNING, "A non-numeric value encountered"); + if (UNEXPECTED(EG(exception))) { + *failed = 1; } + } + if (EXPECTED(type == IS_LONG)) { return lval; } else { - if (trailing_data) { - zend_error(E_WARNING, "A non-numeric value encountered"); - if (UNEXPECTED(EG(exception))) { - *failed = 1; - } - } /* Previously we used strtol here, not is_numeric_string, * and strtol gives you LONG_MAX/_MIN on overflow. * We use use saturating conversion to emulate strtol()'s From ab4d111b1020abb5d71025ced75d0f597d4ad597 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Tue, 28 Jul 2020 15:27:05 +0100 Subject: [PATCH 13/14] Adjust JIT helpers --- ext/opcache/jit/zend_jit_helpers.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/ext/opcache/jit/zend_jit_helpers.c b/ext/opcache/jit/zend_jit_helpers.c index 5cfb83689a1b3..7ae956f1774b4 100644 --- a/ext/opcache/jit/zend_jit_helpers.c +++ b/ext/opcache/jit/zend_jit_helpers.c @@ -685,10 +685,11 @@ static void ZEND_FASTCALL zend_jit_fetch_dim_str_r_helper(zval *container, zval switch (Z_TYPE_P(dim)) { case IS_STRING: { - /* allow errors in string offset for BC reasons */ - if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), &offset, NULL, true)) { - /* emit Illegal string warning on leading numerical string */ - if (0 == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, false)) { + bool trailing_data = false; + /* For BC reasons we allow errors so that we can warn on leading numeric string */ + if (IS_LONG == is_numeric_string_ex(Z_STRVAL_P(dim), Z_STRLEN_P(dim), &offset, NULL, + /* allow errors */ true, NULL, &trailing_data)) { + if (UNEXPECTED(trailing_data)) { zend_error(E_WARNING, "Illegal string offset \"%s\"", Z_STRVAL_P(dim)); } goto out; @@ -832,11 +833,11 @@ static zend_never_inline zend_long zend_check_string_offset(zval *dim, int type) switch(Z_TYPE_P(dim)) { case IS_STRING: { - /* allow errors in string offset for BC reasons */ - if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), &offset, NULL, true)) { - /* emit Illegal string warning on leading numerical string */ - if (0 == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, false) - && type != BP_VAR_UNSET) { + bool trailing_data = false; + /* For BC reasons we allow errors so that we can warn on leading numeric string */ + if (IS_LONG == is_numeric_string_ex(Z_STRVAL_P(dim), Z_STRLEN_P(dim), &offset, NULL, + /* allow errors */ true, NULL, &trailing_data)) { + if (UNEXPECTED(trailing_data) && type != BP_VAR_UNSET) { zend_error(E_WARNING, "Illegal string offset \"%s\"", Z_STRVAL_P(dim)); } return offset; From b9b3145f2a01bc187e792c04cdddc5494525f096 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Tue, 28 Jul 2020 16:52:00 +0100 Subject: [PATCH 14/14] Fix test after rebase --- Zend/tests/operator_unsupported_types.phpt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Zend/tests/operator_unsupported_types.phpt b/Zend/tests/operator_unsupported_types.phpt index aab98f7168f38..94e23ec60376a 100644 --- a/Zend/tests/operator_unsupported_types.phpt +++ b/Zend/tests/operator_unsupported_types.phpt @@ -2052,8 +2052,7 @@ UNARY OP: Cannot perform bitwise not on array Cannot perform bitwise not on stdClass Cannot perform bitwise not on resource -Warning: Undefined variable $copy -No error for ~ +No error for ~"foo" INCDEC: