if (opcode == ZEND_ASSIGN_OBJ) {
Z_OBJ_HT_P(object)->write_property(object, property, value TSRMLS_CC);
} else {
+ if (!Z_OBJ_HT_P(object)->write_dimension) {
+ zend_error(E_ERROR, "Cannot use object as array");
+ }
Z_OBJ_HT_P(object)->write_dimension(object, property, value TSRMLS_CC);
}
if (property == &tmp) {
break;
case IS_OBJECT:
if (type == BP_VAR_R) {
- zval *dim = get_zval_ptr(op2, Ts, &EG(free_op2), BP_VAR_R);
- zval *overloaded_result = Z_OBJ_HT_P(container)->read_dimension(container, dim TSRMLS_CC);
-
- *retval = &overloaded_result;
- AI_USE_PTR(T(result->u.var).var);
- FREE_OP(Ts, op2, EG(free_op2));
- SELECTIVE_PZVAL_LOCK(**retval, result);
+ if (!Z_OBJ_HT_P(container)->read_dimension) {
+ zend_error(E_ERROR, "Cannot use object as array");
+ } else {
+ zval *dim = get_zval_ptr(op2, Ts, &EG(free_op2), BP_VAR_R);
+ zval *overloaded_result = Z_OBJ_HT_P(container)->read_dimension(container, dim TSRMLS_CC);
+
+ *retval = &overloaded_result;
+ AI_USE_PTR(T(result->u.var).var);
+ FREE_OP(Ts, op2, EG(free_op2));
+ SELECTIVE_PZVAL_LOCK(**retval, result);
+ }
}
break;
default: {
}
+
int zend_unset_dim_obj_handler(ZEND_OPCODE_HANDLER_ARGS)
{
zval **container = get_obj_zval_ptr_ptr(&EX(opline)->op1, EX(Ts), BP_VAR_R TSRMLS_CC);
if (container) {
HashTable *ht;
- if ((*container)->type == IS_ARRAY) {
- ht = (*container)->value.ht;
- } else {
- ht = NULL;
- if ((*container)->type == IS_OBJECT) {
- Z_OBJ_HT_P(*container)->unset_property(*container, offset TSRMLS_CC);
- }
+ switch (EX(opline)->opcode) {
+ case ZEND_UNSET_DIM:
+ switch (Z_TYPE_PP(container)) {
+ case IS_ARRAY:
+ ht = Z_ARRVAL_PP(container);
+ break;
+ case IS_OBJECT:
+ ht = NULL;
+ if (!Z_OBJ_HT_P(*container)->unset_dimension) {
+ zend_error(E_ERROR, "Cannot use object as array");
+ }
+ Z_OBJ_HT_P(*container)->unset_dimension(*container, offset TSRMLS_CC);
+ break;
+ default:
+ ht = NULL;
+ break;
+ }
+ break;
+ case ZEND_UNSET_OBJ:
+ ht = NULL;
+ if (Z_TYPE_PP(container) == IS_OBJECT) {
+ Z_OBJ_HT_P(*container)->unset_property(*container, offset TSRMLS_CC);
+ }
+ break;
}
if (ht) {
switch (offset->type) {
zend_opcode_handlers[ZEND_INCLUDE_OR_EVAL] = zend_include_or_eval_handler;
zend_opcode_handlers[ZEND_UNSET_VAR] = zend_unset_var_handler;
- zend_opcode_handlers[ZEND_UNSET_DIM_OBJ] = zend_unset_dim_obj_handler;
+ zend_opcode_handlers[ZEND_UNSET_DIM] = zend_unset_dim_obj_handler;
+ zend_opcode_handlers[ZEND_UNSET_OBJ] = zend_unset_dim_obj_handler;
zend_opcode_handlers[ZEND_FE_RESET] = zend_fe_reset_handler;
zend_opcode_handlers[ZEND_FE_FETCH] = zend_fe_fetch_handler;
}
}
+
+static void zend_std_unset_dimension(zval *object, zval *offset TSRMLS_DC)
+{
+ zend_error(E_ERROR, "Cannot use object as array");
+}
+
+
static void zend_std_call_user_call(INTERNAL_FUNCTION_PARAMETERS)
{
zval ***args;
NULL, /* set */
zend_std_has_property, /* has_property */
zend_std_unset_property, /* unset_property */
+ zend_std_unset_dimension, /* unset_dimension */
zend_std_get_properties, /* get_properties */
zend_std_get_method, /* get_method */
NULL, /* call_method */
/* Used to remove a property of the object */
typedef void (*zend_object_unset_property_t)(zval *object, zval *member TSRMLS_DC);
+/* Used to remove a property of the object */
+typedef void (*zend_object_unset_dimension_t)(zval *object, zval *offset TSRMLS_DC);
+
/* Used to get hash of the properties of the object, as hash of zval's */
typedef HashTable *(*zend_object_get_properties_t)(zval *object TSRMLS_DC);
zend_object_set_t set;
zend_object_has_property_t has_property;
zend_object_unset_property_t unset_property;
+ zend_object_unset_dimension_t unset_dimension;
zend_object_get_properties_t get_properties;
zend_object_get_method_t get_method;
zend_object_call_method_t call_method;