diff options
26 files changed, 143 insertions, 158 deletions
@@ -95,6 +95,10 @@ PHP 8.0 UPGRADE NOTES is already used will now result in an Error exception. Previously this was a warning. RFC: Part of https://wiki.php.net/rfc/engine_warnings + . Attempting to use an invalid type (array or object) as an array key or + string offset will now result in a TypeError exception. Previously this was + a warning. + RFC: Part of https://wiki.php.net/rfc/engine_warnings - COM: . Removed the ability to import case-insensitive constants from type diff --git a/Zend/tests/036.phpt b/Zend/tests/036.phpt index 3ff522b16f..6b6549d935 100644 --- a/Zend/tests/036.phpt +++ b/Zend/tests/036.phpt @@ -3,14 +3,19 @@ Trying to use lambda in array offset --FILE-- <?php -$test[function(){}] = 1; -$a{function() { }} = 1; +try { + $test[function(){}] = 1; +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} +try { + $a{function() { }} = 1; +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} ?> --EXPECTF-- - -Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d - -Warning: Illegal offset type in %s on line %d - -Warning: Illegal offset type in %s on line %d +Deprecated: Array and string offset access syntax with curly braces is deprecated in %s on line %d +Illegal offset type +Illegal offset type diff --git a/Zend/tests/038.phpt b/Zend/tests/038.phpt index 963e73f9ea..e55757bbcd 100644 --- a/Zend/tests/038.phpt +++ b/Zend/tests/038.phpt @@ -3,10 +3,12 @@ Trying to use lambda as array key --FILE-- <?php -var_dump(array(function() { } => 1)); +try { + var_dump(array(function() { } => 1)); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} ?> ---EXPECTF-- -Warning: Illegal offset type in %s on line %d -array(0) { -} +--EXPECT-- +Illegal offset type diff --git a/Zend/tests/assign_dim_obj_null_return.phpt b/Zend/tests/assign_dim_obj_null_return.phpt index e09c753d4a..074b7ed239 100644 --- a/Zend/tests/assign_dim_obj_null_return.phpt +++ b/Zend/tests/assign_dim_obj_null_return.phpt @@ -13,8 +13,17 @@ function test() { echo $e->getMessage(), "\n"; } - var_dump($array[[]] = 123); - var_dump($array[new stdClass] = 123); + try { + var_dump($array[[]] = 123); + } catch (Error $e) { + echo $e->getMessage(), "\n"; + } + + try { + var_dump($array[new stdClass] = 123); + } catch (Error $e) { + echo $e->getMessage(), "\n"; + } var_dump($true[123] = 456); try { @@ -23,8 +32,17 @@ function test() { echo $e->getMessage(), "\n"; } - var_dump($array[[]] += 123); - var_dump($array[new stdClass] += 123); + try { + var_dump($array[[]] += 123); + } catch (Error $e) { + echo $e->getMessage(), "\n"; + } + + try { + var_dump($array[new stdClass] += 123); + } catch (Error $e) { + echo $e->getMessage(), "\n"; + } var_dump($true[123] += 456); try { @@ -44,22 +62,14 @@ test(); ?> --EXPECTF-- Cannot add element to the array as the next element is already occupied - -Warning: Illegal offset type in %s on line %d -NULL - -Warning: Illegal offset type in %s on line %d -NULL +Illegal offset type +Illegal offset type Warning: Cannot use a scalar value as an array in %s on line %d NULL Cannot add element to the array as the next element is already occupied - -Warning: Illegal offset type in %s on line %d -NULL - -Warning: Illegal offset type in %s on line %d -NULL +Illegal offset type +Illegal offset type Warning: Cannot use a scalar value as an array in %s on line %d NULL diff --git a/Zend/tests/bug36303.phpt b/Zend/tests/bug36303.phpt index 50c473d320..80f2aa1bfc 100644 --- a/Zend/tests/bug36303.phpt +++ b/Zend/tests/bug36303.phpt @@ -1,5 +1,7 @@ --TEST-- Bug #36303 (foreach on error_zval produces segfault) +--XFAIL-- +TODO: ERROR zval still possible? --FILE-- <?php $x = []; diff --git a/Zend/tests/bug52237.phpt b/Zend/tests/bug52237.phpt index 97ea6d9ead..3e1ac042fd 100644 --- a/Zend/tests/bug52237.phpt +++ b/Zend/tests/bug52237.phpt @@ -1,5 +1,7 @@ --TEST-- Bug #52237 (Crash when passing the reference of the property of a non-object) +--XFAIL-- +TODO: ERROR zval still possible? --FILE-- <?php $data = []; diff --git a/Zend/tests/constant_expressions_invalid_offset_type_error.phpt b/Zend/tests/constant_expressions_invalid_offset_type_error.phpt index 52d2194e26..649c3a325a 100644 --- a/Zend/tests/constant_expressions_invalid_offset_type_error.phpt +++ b/Zend/tests/constant_expressions_invalid_offset_type_error.phpt @@ -8,7 +8,7 @@ const C2 = [C1, [] => 1]; ?> --EXPECTF-- -Fatal error: Uncaught Error: Illegal offset type 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/offset_array.phpt b/Zend/tests/offset_array.phpt index a1d0a43c69..00e6cb05e7 100644 --- a/Zend/tests/offset_array.phpt +++ b/Zend/tests/offset_array.phpt @@ -17,10 +17,18 @@ $fp = fopen(__FILE__, "r"); var_dump($arr[$fp]); $obj = new stdClass; -var_dump($arr[$obj]); +try { + var_dump($arr[$obj]); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} $arr1 = Array(1,2,3); -var_dump($arr[$arr1]); +try { + var_dump($arr[$arr1]); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} echo "Done\n"; ?> @@ -38,10 +46,6 @@ int(1) Notice: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d int(%d) - -Warning: Illegal offset type in %s on line %d -NULL - -Warning: Illegal offset type in %s on line %d -NULL +Illegal offset type +Illegal offset type Done diff --git a/Zend/tests/offset_string.phpt b/Zend/tests/offset_string.phpt index 3ad48e7412..01b0815ea0 100644 --- a/Zend/tests/offset_string.phpt +++ b/Zend/tests/offset_string.phpt @@ -17,13 +17,25 @@ var_dump($str[TRUE]); var_dump($str[FALSE]); $fp = fopen(__FILE__, "r"); -var_dump($str[$fp]); +try { + var_dump($str[$fp]); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} $obj = new stdClass; -var_dump($str[$obj]); +try { + var_dump($str[$obj]); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} $arr = Array(1,2,3); -var_dump($str[$arr]); +try { + var_dump($str[$arr]); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} echo "Done\n"; ?> @@ -51,15 +63,9 @@ string(1) "i" Notice: String offset cast occurred in %s on line %d string(1) "S" - -Warning: Illegal offset type in %s on line %d -string(1) "%s" - -Warning: Illegal offset type in %s on line %d +Illegal offset type Notice: Object of class stdClass could not be converted to int in %s on line %d -string(1) "%s" - -Warning: Illegal offset type in %s on line %d -string(1) "i" +Illegal offset type +Illegal offset type Done diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 34fcf1506a..e3953acfcc 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -1554,7 +1554,7 @@ ZEND_API int array_set_zval_key(HashTable *ht, zval *key, zval *value) /* {{{ */ result = zend_hash_index_update(ht, zend_dval_to_lval(Z_DVAL_P(key)), value); break; default: - zend_error(E_WARNING, "Illegal offset type"); + zend_type_error("Illegal offset type"); result = NULL; } diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c index 0692993490..660e6d5b6f 100644 --- a/Zend/zend_ast.c +++ b/Zend/zend_ast.c @@ -440,7 +440,7 @@ static int zend_ast_add_array_element(zval *result, zval *offset, zval *expr) zend_hash_index_update(Z_ARRVAL_P(result), Z_RES_HANDLE_P(offset), expr); break; default: - zend_throw_error(NULL, "Illegal offset type"); + zend_type_error("Illegal offset type"); return FAILURE; } return SUCCESS; diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index f8f2527256..fa2cb94440 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -1220,7 +1220,7 @@ static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_use_object_as_array(v static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_illegal_offset(void) { - zend_error(E_WARNING, "Illegal offset type"); + zend_type_error("Illegal offset type"); } static zend_never_inline void zend_assign_to_object_dim(zval *object, zval *dim, zval *value OPLINE_DC EXECUTE_DATA_DC) @@ -2361,7 +2361,7 @@ str_idx: ZVAL_UNDEFINED_OP2(); goto str_idx; } else { - zend_error(E_WARNING, "Illegal offset type in isset or empty"); + zend_type_error("Illegal offset type in isset or empty"); return NULL; } } diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 22d302f9c0..430df91bce 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -6176,7 +6176,7 @@ ZEND_VM_C_LABEL(num_index_dim): key = ZSTR_EMPTY_ALLOC(); ZEND_VM_C_GOTO(str_index_dim); } else { - zend_error(E_WARNING, "Illegal offset type in unset"); + zend_type_error("Illegal offset type in unset"); } break; } else if (Z_ISREF_P(container)) { diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 4b27d0d26a..c92ae3a8c3 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -23965,7 +23965,7 @@ num_index_dim: key = ZSTR_EMPTY_ALLOC(); goto str_index_dim; } else { - zend_error(E_WARNING, "Illegal offset type in unset"); + zend_type_error("Illegal offset type in unset"); } break; } else if (Z_ISREF_P(container)) { @@ -26190,7 +26190,7 @@ num_index_dim: key = ZSTR_EMPTY_ALLOC(); goto str_index_dim; } else { - zend_error(E_WARNING, "Illegal offset type in unset"); + zend_type_error("Illegal offset type in unset"); } break; } else if (Z_ISREF_P(container)) { @@ -29985,7 +29985,7 @@ num_index_dim: key = ZSTR_EMPTY_ALLOC(); goto str_index_dim; } else { - zend_error(E_WARNING, "Illegal offset type in unset"); + zend_type_error("Illegal offset type in unset"); } break; } else if (Z_ISREF_P(container)) { @@ -41598,7 +41598,7 @@ num_index_dim: key = ZSTR_EMPTY_ALLOC(); goto str_index_dim; } else { - zend_error(E_WARNING, "Illegal offset type in unset"); + zend_type_error("Illegal offset type in unset"); } break; } else if (Z_ISREF_P(container)) { @@ -45123,7 +45123,7 @@ num_index_dim: key = ZSTR_EMPTY_ALLOC(); goto str_index_dim; } else { - zend_error(E_WARNING, "Illegal offset type in unset"); + zend_type_error("Illegal offset type in unset"); } break; } else if (Z_ISREF_P(container)) { @@ -50352,7 +50352,7 @@ num_index_dim: key = ZSTR_EMPTY_ALLOC(); goto str_index_dim; } else { - zend_error(E_WARNING, "Illegal offset type in unset"); + zend_type_error("Illegal offset type in unset"); } break; } else if (Z_ISREF_P(container)) { diff --git a/ext/opcache/jit/zend_jit_helpers.c b/ext/opcache/jit/zend_jit_helpers.c index 54b888a132..4883d526bb 100644 --- a/ext/opcache/jit/zend_jit_helpers.c +++ b/ext/opcache/jit/zend_jit_helpers.c @@ -260,7 +260,7 @@ static void ZEND_FASTCALL zend_jit_fetch_dim_r_helper(zend_array *ht, zval *dim, hval = 1; goto num_index; default: - zend_error(E_WARNING, "Illegal offset type"); + zend_type_error("Illegal offset type"); ZVAL_NULL(result); return; } @@ -332,7 +332,7 @@ static void ZEND_FASTCALL zend_jit_fetch_dim_is_helper(zend_array *ht, zval *dim hval = 1; goto num_index; default: - zend_error(E_WARNING, "Illegal offset type"); + zend_type_error("Illegal offset type"); ZVAL_NULL(result); return; } @@ -401,7 +401,7 @@ static int ZEND_FASTCALL zend_jit_fetch_dim_isset_helper(zend_array *ht, zval *d hval = 1; goto num_index; default: - zend_error(E_WARNING, "Illegal offset type in isset or empty"); + zend_type_error("Illegal offset type in isset or empty"); return 0; } @@ -468,7 +468,7 @@ static zval* ZEND_FASTCALL zend_jit_fetch_dim_rw_helper(zend_array *ht, zval *di hval = 1; goto num_index; default: - zend_error(E_WARNING, "Illegal offset type"); + zend_type_error("Illegal offset type"); return NULL; } @@ -536,7 +536,7 @@ static zval* ZEND_FASTCALL zend_jit_fetch_dim_w_helper(zend_array *ht, zval *dim hval = 1; goto num_index; default: - zend_error(E_WARNING, "Illegal offset type"); + zend_type_error("Illegal offset type"); return NULL; } @@ -590,7 +590,7 @@ try_string_offset: dim = Z_REFVAL_P(dim); goto try_string_offset; default: - zend_error(E_WARNING, "Illegal offset type"); + zend_type_error("Illegal offset type"); break; } @@ -638,7 +638,7 @@ try_string_offset: dim = Z_REFVAL_P(dim); goto try_string_offset; default: - zend_error(E_WARNING, "Illegal offset type"); + zend_type_error("Illegal offset type"); break; } @@ -737,7 +737,7 @@ try_again: dim = Z_REFVAL_P(dim); goto try_again; default: - zend_error(E_WARNING, "Illegal offset type"); + zend_type_error("Illegal offset type"); break; } diff --git a/ext/opcache/tests/jit/assign_dim_002.phpt b/ext/opcache/tests/jit/assign_dim_002.phpt index 73792defa9..bd241ae2e5 100644 --- a/ext/opcache/tests/jit/assign_dim_002.phpt +++ b/ext/opcache/tests/jit/assign_dim_002.phpt @@ -58,7 +58,11 @@ function foo4() { $array[0][1] = 1; var_dump($array); - $array[function() {}] = 2; + try { + $array[function() {}] = 2; + } catch (Error $e) { + echo $e->getMessage(), "\n"; + } var_dump($array); $array2[][] = 3; @@ -106,8 +110,7 @@ array(1) { int(1) } } - -Warning: Illegal offset type in %sassign_dim_002.php on line 51 +Illegal offset type array(1) { [0]=> array(2) { @@ -127,5 +130,5 @@ array(1) { } } -Warning: Cannot use a scalar value as an array in %sassign_dim_002.php on line 61 +Warning: Cannot use a scalar value as an array in %sassign_dim_002.php on line 65 int(1) diff --git a/ext/session/tests/session_encode_error2.phpt b/ext/session/tests/session_encode_error2.phpt index 1a87eb14a3..4b2be79ff0 100644 --- a/ext/session/tests/session_encode_error2.phpt +++ b/ext/session/tests/session_encode_error2.phpt @@ -84,7 +84,11 @@ $iterator = 1; foreach($inputs as $input) { echo "\n-- Iteration $iterator --\n"; var_dump(session_start()); - $_SESSION[$input] = "Hello World!"; + try { + $_SESSION[$input] = "Hello World!"; + } catch (Error $e) { + echo $e->getMessage(), "\n"; + } var_dump(session_encode()); var_dump(session_destroy()); $iterator++; @@ -225,8 +229,7 @@ bool(true) -- Iteration 21 -- bool(true) - -Warning: Illegal offset type in %s on line 82 +Illegal offset type bool(false) bool(true) diff --git a/ext/spl/tests/iterator_to_array_nonscalar_keys.phpt b/ext/spl/tests/iterator_to_array_nonscalar_keys.phpt index 4ca9485faf..1920b31639 100644 --- a/ext/spl/tests/iterator_to_array_nonscalar_keys.phpt +++ b/ext/spl/tests/iterator_to_array_nonscalar_keys.phpt @@ -12,20 +12,12 @@ function gen() { yield new stdClass => 5; } -var_dump(iterator_to_array(gen())); +try { + var_dump(iterator_to_array(gen())); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} ?> ---EXPECTF-- -Warning: Illegal offset type in %s on line %d - -Warning: Illegal offset type in %s on line %d -array(4) { - ["foo"]=> - int(0) - [1]=> - int(1) - [2]=> - int(2) - [""]=> - int(3) -} +--EXPECT-- +Illegal offset type diff --git a/ext/standard/tests/array/array_combine_variation4.phpt b/ext/standard/tests/array/array_combine_variation4.phpt index a7ea0a9dc4..125221cac8 100644 --- a/ext/standard/tests/array/array_combine_variation4.phpt +++ b/ext/standard/tests/array/array_combine_variation4.phpt @@ -60,10 +60,10 @@ $arrays = array ( array("hello", $heredoc => "string"), // heredoc // array with object, unset variable and resource variable -/*10*/ array(new classA() => 11, @$unset_var => "hello", $fp => 'resource'), +/*10*/ array(@$unset_var => "hello", $fp => 'resource'), // array with mixed keys -/*11*/ array('hello' => 1, new classA() => 2, "fruit" => 2.2, +/*11*/ array('hello' => 1, "fruit" => 2.2, $fp => 'resource', 133 => "int", 444.432 => "float", @$unset_var => "unset", $heredoc => "heredoc") ); @@ -71,7 +71,7 @@ $arrays = array ( // array to be passsed to $arr2 argument $arr2 = array(0 => 0, 2 => "float", 4 => "f3", 33333333 => "f4", "\tHello" => 111, 2.2, 'color', "Hello world" => "string", - "pen\n" => 33, new classA() => 11, 133 => "int"); + "pen\n" => 33, 133 => "int"); // loop through each sub-array within $arrays to check the behavior of array_combine() // same arrays are passed to both $keys and $values @@ -90,15 +90,9 @@ echo "Done"; --EXPECTF-- *** Testing array_combine() : assoc array with diff keys to both $keys and $values argument *** -Warning: Illegal offset type in %s on line %d - Notice: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d -Warning: Illegal offset type in %s on line %d - Notice: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d - -Warning: Illegal offset type in %s on line %d -- Iteration 1 -- array(0) { } diff --git a/ext/standard/tests/array/array_keys_error.phpt b/ext/standard/tests/array/array_keys_error.phpt deleted file mode 100644 index 0febae29c7..0000000000 --- a/ext/standard/tests/array/array_keys_error.phpt +++ /dev/null @@ -1,29 +0,0 @@ ---TEST-- -Test array_keys() function (error conditions) ---FILE-- -<?php - -echo "\n*** Testing error conditions ***\n"; -try { - var_dump(array_keys(new stdclass)); // object -} catch (TypeError $e) { - echo $e->getMessage(), "\n"; -} -var_dump(array_keys(array(1,2,3, new stdClass => array()))); // (W)illegal offset - -echo "Done\n"; -?> ---EXPECTF-- -*** Testing error conditions *** -array_keys() expects parameter 1 to be array, object given - -Warning: Illegal offset type in %s on line %d -array(3) { - [0]=> - int(0) - [1]=> - int(1) - [2]=> - int(2) -} -Done diff --git a/ext/standard/tests/array/array_map_variation4.phpt b/ext/standard/tests/array/array_map_variation4.phpt index e5b4c062c1..08599e0567 100644 --- a/ext/standard/tests/array/array_map_variation4.phpt +++ b/ext/standard/tests/array/array_map_variation4.phpt @@ -58,10 +58,10 @@ $arrays = array ( array("hello", $heredoc => "string"), // heredoc // array with object, unset variable and resource variable - array(new classA() => 11, @$unset_var => "hello", $fp => 'resource'), + array(@$unset_var => "hello", $fp => 'resource'), // array with mixed values -/*11*/ array('hello' => 1, new classA() => 2, "fruit" => 2.2, +/*11*/ array('hello' => 1, "fruit" => 2.2, $fp => 'resource', 133 => "int", 444.432 => "float", @$unset_var => "unset", $heredoc => "heredoc") ); @@ -79,12 +79,8 @@ echo "Done"; --EXPECTF-- *** Testing array_map() : associative array with diff. keys for 'arr1' argument *** -Warning: Illegal offset type in %s on line %d - Notice: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d -Warning: Illegal offset type in %s on line %d - Notice: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d -- Iteration 1 -- array(0) { diff --git a/ext/standard/tests/array/array_merge_recursive_variation4.phpt b/ext/standard/tests/array/array_merge_recursive_variation4.phpt index f2c1e82a0c..151a515205 100644 --- a/ext/standard/tests/array/array_merge_recursive_variation4.phpt +++ b/ext/standard/tests/array/array_merge_recursive_variation4.phpt @@ -50,7 +50,7 @@ $arrays = array ( array("hello", $heredoc => array("heredoc", 'string'), "string"), // array with object, unset variable and resource variable -/*8*/ array(new classA() => 11, @$unset_var => array("unset"), $fp => 'resource', 11, "hello") +/*8*/ array(@$unset_var => array("unset"), $fp => 'resource', 11, "hello") ); // initialise the second array @@ -80,8 +80,6 @@ echo "Done"; --EXPECTF-- *** Testing array_merge_recursive() : assoc. array with diff. keys to $arr1 argument *** -Warning: Illegal offset type in %s on line %d - Notice: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d -- Iteration 1 -- -- With default argument -- diff --git a/ext/standard/tests/array/array_reverse_variation4.phpt b/ext/standard/tests/array/array_reverse_variation4.phpt index 09b2eb4bee..f6e98dae82 100644 --- a/ext/standard/tests/array/array_reverse_variation4.phpt +++ b/ext/standard/tests/array/array_reverse_variation4.phpt @@ -54,10 +54,10 @@ $arrays = array ( array("hello", $heredoc => "string"), // heredoc // array with object, unset variable and resource variable - array(new classA() => 11, @$unset_var => "hello", $fp => 'resource'), + array(@$unset_var => "hello", $fp => 'resource'), // array with mixed values -/*11*/ array('hello' => 1, new classA() => 2, "fruit" => 2.2, $fp => 'resource', 133 => "int", 444.432 => "float", @$unset_var => "unset", $heredoc => "heredoc") +/*11*/ array('hello' => 1, "fruit" => 2.2, $fp => 'resource', 133 => "int", 444.432 => "float", @$unset_var => "unset", $heredoc => "heredoc") ); // loop through the various elements of $arrays to test array_reverse() @@ -83,12 +83,8 @@ echo "Done"; --EXPECTF-- *** Testing array_reverse() : usage variations *** -Warning: Illegal offset type in %s on line %d - Notice: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d -Warning: Illegal offset type in %s on line %d - Notice: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d -- Iteration 1 -- - default argument - diff --git a/ext/standard/tests/array/array_unique_variation3.phpt b/ext/standard/tests/array/array_unique_variation3.phpt index 205bc3a576..e80df1fb65 100644 --- a/ext/standard/tests/array/array_unique_variation3.phpt +++ b/ext/standard/tests/array/array_unique_variation3.phpt @@ -50,7 +50,7 @@ $inputs = array ( array("hello", $heredoc => "string", "string"), // array with object, unset variable and resource variable -/*8*/ array(new classA() => 11, @$unset_var => "hello", $fp => 'resource', 11, "hello"), +/*8*/ array(@$unset_var => "hello", $fp => 'resource', 11, "hello"), ); // loop through each sub-array of $inputs to check the behavior of array_unique() @@ -68,8 +68,6 @@ echo "Done"; --EXPECTF-- *** Testing array_unique() : assoc. array with diff. keys passed to $input argument *** -Warning: Illegal offset type in %s on line %d - Notice: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d -- Iteration 1 -- array(1) { diff --git a/ext/standard/tests/array/array_unshift_variation4.phpt b/ext/standard/tests/array/array_unshift_variation4.phpt index 7f507c98d0..ee91bba180 100644 --- a/ext/standard/tests/array/array_unshift_variation4.phpt +++ b/ext/standard/tests/array/array_unshift_variation4.phpt @@ -63,10 +63,10 @@ $arrays = array ( array("hello", $heredoc => "string"), // heredoc // array with object, unset variable and resource variable - array(new classA() => 11, @$unset_var => "hello", $fp => 'resource'), + array(@$unset_var => "hello", $fp => 'resource'), // array with mixed keys -/*11*/ array('hello' => 1, new classA() => 2, "fruit" => 2.2, +/*11*/ array('hello' => 1, "fruit" => 2.2, $fp => 'resource', 133 => "int", 444.432 => "float", @$unset_var => "unset", $heredoc => "heredoc") ); @@ -101,12 +101,8 @@ echo "Done"; --EXPECTF-- *** Testing array_unshift() : associative array with different keys *** -Warning: Illegal offset type in %s on line %d - Notice: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d -Warning: Illegal offset type in %s on line %d - Notice: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d -- Iteration 1 -- int(1) diff --git a/tests/classes/tostring_001.phpt b/tests/classes/tostring_001.phpt index 418aa1fc25..ba2bc3eb53 100644 --- a/tests/classes/tostring_001.phpt +++ b/tests/classes/tostring_001.phpt @@ -56,7 +56,11 @@ echo $o , $o; echo "====test7====\n"; $ar = array(); $ar[$o->__toString()] = "ERROR"; -echo $ar[$o]; +try { + echo $ar[$o]; +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} echo "====test8====\n"; var_dump(trim($o)); @@ -76,7 +80,7 @@ try { ?> ====DONE==== ---EXPECTF-- +--EXPECT-- ====test1==== test1 Object ( @@ -114,8 +118,7 @@ test2::__toString() Converted ====test7==== test2::__toString() - -Warning: Illegal offset type in %s on line %d +Illegal offset type ====test8==== test2::__toString() string(9) "Converted" @@ -125,7 +128,7 @@ string(9) "Converted" test2::__toString() Converted ====test10==== -object(test3)#1 (0) { +object(test3)#2 (0) { } test3::__toString() Method test3::__toString() must return a string value |