summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
Diffstat (limited to 'Zend')
-rw-r--r--Zend/tests/036.phpt21
-rw-r--r--Zend/tests/038.phpt12
-rw-r--r--Zend/tests/assign_dim_obj_null_return.phpt42
-rw-r--r--Zend/tests/bug36303.phpt2
-rw-r--r--Zend/tests/bug52237.phpt2
-rw-r--r--Zend/tests/constant_expressions_invalid_offset_type_error.phpt2
-rw-r--r--Zend/tests/offset_array.phpt20
-rw-r--r--Zend/tests/offset_string.phpt30
-rw-r--r--Zend/zend_API.c2
-rw-r--r--Zend/zend_ast.c2
-rw-r--r--Zend/zend_execute.c4
-rw-r--r--Zend/zend_vm_def.h2
-rw-r--r--Zend/zend_vm_execute.h12
13 files changed, 92 insertions, 61 deletions
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)) {