diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2018-10-04 13:58:35 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2018-10-10 10:39:10 +0200 |
commit | 7ec8087f8097955bfc6b97d1a916c6ffc39908f4 (patch) | |
tree | 7f56e3c0030c1135bdc84c1a2f1e26724e2f0f3b /Zend/zend_operators.c | |
parent | 77c85b3119cc3aacbe2642c974bf88e512abd187 (diff) | |
download | php-git-7ec8087f8097955bfc6b97d1a916c6ffc39908f4.tar.gz |
Introduce get_properties_for() handler
This handler allows getting the object properties for a particular
purpose, such as array casting, serialization, etc.
Diffstat (limited to 'Zend/zend_operators.c')
-rw-r--r-- | Zend/zend_operators.c | 36 |
1 files changed, 12 insertions, 24 deletions
diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 71663ae31c..79ccffab5f 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -610,32 +610,20 @@ try_again: if (Z_OBJCE_P(op) == zend_ce_closure) { convert_scalar_to_array(op); } else { - if (Z_OBJ_HT_P(op)->get_properties) { - HashTable *obj_ht = Z_OBJ_HT_P(op)->get_properties(op); - if (obj_ht) { - /* fast copy */ - obj_ht = zend_proptable_to_symtable(obj_ht, - (Z_OBJCE_P(op)->default_properties_count || - Z_OBJ_P(op)->handlers != &std_object_handlers || - GC_IS_RECURSIVE(obj_ht))); - zval_ptr_dtor(op); - ZVAL_ARR(op, obj_ht); - return; - } + HashTable *obj_ht = zend_get_properties_for(op, ZEND_PROP_PURPOSE_ARRAY_CAST); + if (obj_ht) { + HashTable *new_obj_ht = zend_proptable_to_symtable(obj_ht, + (Z_OBJCE_P(op)->default_properties_count || + Z_OBJ_P(op)->handlers != &std_object_handlers || + GC_IS_RECURSIVE(obj_ht))); + zval_ptr_dtor(op); + ZVAL_ARR(op, new_obj_ht); + zend_release_properties(obj_ht); } else { - zval dst; - convert_object_to_type(op, &dst, IS_ARRAY, convert_to_array); - - if (Z_TYPE(dst) == IS_ARRAY) { - zval_ptr_dtor(op); - ZVAL_COPY_VALUE(op, &dst); - return; - } + zval_ptr_dtor(op); + /*ZVAL_EMPTY_ARRAY(op);*/ + array_init(op); } - - zval_ptr_dtor(op); - /*ZVAL_EMPTY_ARRAY(op);*/ - array_init(op); } break; case IS_NULL: |