Skip to content

Commit f5eb7a2

Browse files
committed
Zend: Fix JIT and consistent error message for using object as array
1 parent 7db1904 commit f5eb7a2

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

Zend/tests/offsets/objects/const_dimension/object_offset_behaviour.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
--TEST--
22
Object offset behaviour
3-
--XFAIL--
4-
Attempt to assign property of non-object warning on read before write is emitted with const offset
53
--FILE--
64
<?php
75

Zend/tests/offsets/objects/expect.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Cannot use object of type stdClass as array
55
Read:
66
Cannot use object of type stdClass as array
77
Read-Write:
8-
Cannot use object as array
8+
Cannot use object of type stdClass as array
99
isset():
1010
Cannot use object of type stdClass as array
1111
empty():

Zend/zend_execute.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,9 +1504,9 @@ ZEND_API bool zend_never_inline zend_verify_class_constant_type(zend_class_const
15041504
return 1;
15051505
}
15061506

1507-
static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_use_object_as_array(void)
1507+
static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_use_object_as_array(const zend_object *object)
15081508
{
1509-
zend_throw_error(NULL, "Cannot use object as array");
1509+
zend_throw_error(NULL, "Cannot use object of type %s as array", ZSTR_VAL(object->ce->name));
15101510
}
15111511

15121512
static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_illegal_array_offset_access(const zval *offset)
@@ -1584,7 +1584,7 @@ static zend_never_inline void zend_binary_assign_op_obj_dim(zend_object *obj, zv
15841584
}
15851585
zval_ptr_dtor(&res);
15861586
} else {
1587-
zend_use_object_as_array();
1587+
zend_use_object_as_array(obj);
15881588
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
15891589
ZVAL_NULL(EX_VAR(opline->result.var));
15901590
}

ext/opcache/jit/zend_jit_helpers.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1582,7 +1582,9 @@ static void ZEND_FASTCALL zend_jit_assign_dim_op_helper(zval *container, zval *d
15821582
}
15831583
zval_ptr_dtor(&res);
15841584
} else {
1585-
zend_error(E_WARNING, "Attempt to assign property of non-object");
1585+
/* Exception is thrown in this case */
1586+
GC_DELREF(obj);
1587+
return;
15861588
}
15871589
if (UNEXPECTED(GC_DELREF(obj) == 0)) {
15881590
zend_objects_store_del(obj);

0 commit comments

Comments
 (0)