]> granicus.if.org Git - php/commitdiff
Convert "Illegal offset type" warnings to exceptions
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 26 Sep 2019 14:45:54 +0000 (16:45 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 27 Sep 2019 11:00:07 +0000 (13:00 +0200)
26 files changed:
UPGRADING
Zend/tests/036.phpt
Zend/tests/038.phpt
Zend/tests/assign_dim_obj_null_return.phpt
Zend/tests/bug36303.phpt
Zend/tests/bug52237.phpt
Zend/tests/constant_expressions_invalid_offset_type_error.phpt
Zend/tests/offset_array.phpt
Zend/tests/offset_string.phpt
Zend/zend_API.c
Zend/zend_ast.c
Zend/zend_execute.c
Zend/zend_vm_def.h
Zend/zend_vm_execute.h
ext/opcache/jit/zend_jit_helpers.c
ext/opcache/tests/jit/assign_dim_002.phpt
ext/session/tests/session_encode_error2.phpt
ext/spl/tests/iterator_to_array_nonscalar_keys.phpt
ext/standard/tests/array/array_combine_variation4.phpt
ext/standard/tests/array/array_keys_error.phpt [deleted file]
ext/standard/tests/array/array_map_variation4.phpt
ext/standard/tests/array/array_merge_recursive_variation4.phpt
ext/standard/tests/array/array_reverse_variation4.phpt
ext/standard/tests/array/array_unique_variation3.phpt
ext/standard/tests/array/array_unshift_variation4.phpt
tests/classes/tostring_001.phpt

index 805e23163f6b3286eec118a750898617ad0afeca..a44f2f7786475f3cb690dd5feb371bde7c176d1f 100644 (file)
--- a/UPGRADING
+++ b/UPGRADING
@@ -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
index 3ff522b16f06e782136713179026c286c2bc6657..6b6549d9358e3738759b5cc6a5833aa453b87b0d 100644 (file)
@@ -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
index 963e73f9eaaf5bc4ed0301a7a5341b0b1678b790..e55757bbcd41757d01a2aa476b06cecff5466bdb 100644 (file)
@@ -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
index e09c753d4a5e4472489e11e35624a075159d1f96..074b7ed23917d3e264cbd247d3a07273ebab1e41 100644 (file)
@@ -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
index 50c473d320c0a1efd12937b1df9ccb1965ee34c0..80f2aa1bfc7e5a3b2451f6ae287cec11380ee01b 100644 (file)
@@ -1,5 +1,7 @@
 --TEST--
 Bug #36303 (foreach on error_zval produces segfault)
+--XFAIL--
+TODO: ERROR zval still possible?
 --FILE--
 <?php
 $x = [];
index 97ea6d9ead44782fb16dba359754bddbdeafa68c..3e1ac042fdeb418158847338fc12b073ef9e0c5d 100644 (file)
@@ -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 = [];
index 52d2194e2617c0f2ad0368eb3d5180e4e67736d7..649c3a325a0c29c9b0015cf4c649f3b43ffca0d8 100644 (file)
@@ -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
index a1d0a43c69a99e57059fe964921c31a6b503f09f..00e6cb05e7e23a89d6ec78083ca184d7e6d5875b 100644 (file)
@@ -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
index 3ad48e7412115db1ab00021e6d314b7ff7bfcab8..01b0815ea0bb9a632e16ed1b1776bec456f0288d 100644 (file)
@@ -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
index 34fcf1506a2cbf357f220fb40ca432e924809da3..e3953acfcc56cb2251a53e9533439cb901f5fa8b 100644 (file)
@@ -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;
        }
 
index 0692993490da8303d8c073dfab9344b0d7416273..660e6d5b6f11d3ad53a43939a89d04554983dbf8 100644 (file)
@@ -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;
index f8f252725672a9e2126af1b5f7630148eea1d71b..fa2cb944400e9f8af12e9a09715fda35010b8cfe 100644 (file)
@@ -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;
        }
 }
index 22d302f9c0a841adb6923ec05dcbe88bc20ae7d7..430df91bce91a457b1c73f69bf9d801ed0364173 100644 (file)
@@ -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)) {
index 4b27d0d26a7619bcfb9f5e2603d3ea073785024e..c92ae3a8c3a2ab0d038a13c707abd78bdee33001 100644 (file)
@@ -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)) {
index 54b888a132f3b3708167bc8988e574ea46192ad1..4883d526bb5b18af609d4d6848252e203da22b0f 100644 (file)
@@ -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;
                }
 
index 73792defa9dfff85a8d749c784e20286b7f2017d..bd241ae2e5271515af8c0317cbfb9ba2dd32e749 100644 (file)
@@ -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)
index 1a87eb14a31c3619d53a96c425f7b2c0f45bfae2..4b2be79ff0bee531b9d2f6f3b88c1fe87c65981b 100644 (file)
@@ -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)
 
index 4ca9485faf550cdf37c41d75feefc3dda7b5b451..1920b31639b1e896ea5162be628d7d13d816e91c 100644 (file)
@@ -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
index a7ea0a9dc4768d0fee0065c53b6cde43108d8fe0..125221cac82ed9c661ee1b5b313bec8be2ef3a10 100644 (file)
@@ -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 (file)
index 0febae2..0000000
+++ /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
index e5b4c062c1094d1451b310c4b04b4000c9f16af3..08599e0567126552660aec8d7127dae2cbdae3d1 100644 (file)
@@ -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) {
index f2c1e82a0cf7b303f4fe1930489e38ea598a5646..151a515205e7af6f9d53989b22ebf2a4279ab693 100644 (file)
@@ -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 --
index 09b2eb4beec95ce393b93ddf3991494a1dfdb903..f6e98dae8223d74c7bbffb645be059de1ef1383d 100644 (file)
@@ -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 -
index 205bc3a576c5f048524dafb7893c49ecc7ebb533..e80df1fb65e106316d88e354df851ae0489fc79a 100644 (file)
@@ -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) {
index 7f507c98d0e980206f15f7b864873bd5da2d58a5..ee91bba18065c39a6aba1297338c93a2cca9c017 100644 (file)
@@ -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)
index 418aa1fc257e6bed2e5777a610c2cda92fa691d3..ba2bc3eb5382db71dbdcab862a2e275309d734c4 100644 (file)
@@ -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