SKYRAY_METHOD(stream_client, __construct) { zval *protocol_creator = NULL; zval *reactor = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|zz", &protocol_creator, &reactor) == FAILURE) { return; } if (protocol_creator && Z_TYPE_P(protocol_creator) != IS_NULL && !zend_is_callable(protocol_creator, 0, NULL)) { skyray_throw_exception("The parameter $protocolCreator is not a valid callable"); return; } skyray_stream_client_t *intern = skyray_stream_client_from_obj(Z_OBJ_P(getThis())); if (protocol_creator && Z_TYPE_P(protocol_creator) != IS_NULL) { intern->protocol_creator = emalloc(sizeof(zval)); ZVAL_COPY(intern->protocol_creator, protocol_creator); } if (reactor && Z_TYPE_P(reactor) != IS_NULL) { intern->reactor = emalloc(sizeof(zval)); ZVAL_COPY(intern->reactor, reactor); } }
static PHP_METHOD(SQLite, sqliteCreateAggregate) { struct pdo_sqlite_func *func; zval *step_callback, *fini_callback; char *func_name; size_t func_name_len; zend_long argc = -1; zend_string *cbname = NULL; pdo_dbh_t *dbh; pdo_sqlite_db_handle *H; int ret; ZEND_PARSE_PARAMETERS_START(3, 4) Z_PARAM_STRING(func_name, func_name_len) Z_PARAM_ZVAL_DEREF(step_callback) Z_PARAM_ZVAL_DEREF(fini_callback) Z_PARAM_OPTIONAL Z_PARAM_LONG(argc) ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE); dbh = Z_PDO_DBH_P(getThis()); PDO_CONSTRUCT_CHECK; if (!zend_is_callable(step_callback, 0, &cbname)) { php_error_docref(NULL, E_WARNING, "function '%s' is not callable", ZSTR_VAL(cbname)); zend_string_release(cbname); RETURN_FALSE; } zend_string_release(cbname); if (!zend_is_callable(fini_callback, 0, &cbname)) { php_error_docref(NULL, E_WARNING, "function '%s' is not callable", ZSTR_VAL(cbname)); zend_string_release(cbname); RETURN_FALSE; } zend_string_release(cbname); H = (pdo_sqlite_db_handle *)dbh->driver_data; func = (struct pdo_sqlite_func*)ecalloc(1, sizeof(*func)); ret = sqlite3_create_function(H->db, func_name, argc, SQLITE_UTF8, func, NULL, php_sqlite3_func_step_callback, php_sqlite3_func_final_callback); if (ret == SQLITE_OK) { func->funcname = estrdup(func_name); ZVAL_COPY(&func->step, step_callback); ZVAL_COPY(&func->fini, fini_callback); func->argc = argc; func->next = H->funcs; H->funcs = func; RETURN_TRUE; } efree(func); RETURN_FALSE; }
int ion_ipc_create(zval * one, zval * two, zval * ctx1, zval * ctx2, uint32_t flags) { ion_buffer * buffer_one = NULL; ion_buffer * buffer_two = NULL; ion_process_ipc * ipc1; ion_process_ipc * ipc2; if(!ion_buffer_pair(&buffer_one, &buffer_two)) { return FAILURE; } object_init_ex(one, ion_ce_ION_Process_IPC); object_init_ex(two, ion_ce_ION_Process_IPC); ipc1 = ION_ZVAL_OBJECT_P(one, ion_process_ipc); ipc2 = ION_ZVAL_OBJECT_P(two, ion_process_ipc); bufferevent_setcb(buffer_one, ion_process_ipc_incoming, NULL, ion_process_ipc_notification, ipc1); bufferevent_setcb(buffer_two, ion_process_ipc_incoming, NULL, ion_process_ipc_notification, ipc2); ipc1->buffer = buffer_one; ipc2->buffer = buffer_two; ipc1->flags |= ION_IPC_CONNECTED | flags; ipc2->flags |= ION_IPC_CONNECTED | flags; if(ctx1) { ZVAL_COPY(&ipc1->ctx, ctx1); } if(ctx2) { ZVAL_COPY(&ipc2->ctx, ctx2); } return SUCCESS; }
ds_pair_t *ds_pair_clone(ds_pair_t *pair) { ds_pair_t *clone = ds_pair(); ZVAL_COPY(&clone->key, &pair->key); ZVAL_COPY(&clone->value, &pair->value); return clone; }
static PHP_METHOD(SQLite, sqliteCreateAggregate) { struct pdo_sqlite_func *func; zval *step_callback, *fini_callback; char *func_name; size_t func_name_len; zend_long argc = -1; zend_string *cbname = NULL; pdo_dbh_t *dbh; pdo_sqlite_db_handle *H; int ret; if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "szz|l", &func_name, &func_name_len, &step_callback, &fini_callback, &argc)) { RETURN_FALSE; } dbh = Z_PDO_DBH_P(getThis()); PDO_CONSTRUCT_CHECK; if (!zend_is_callable(step_callback, 0, &cbname)) { php_error_docref(NULL, E_WARNING, "function '%s' is not callable", ZSTR_VAL(cbname)); zend_string_release(cbname); RETURN_FALSE; } zend_string_release(cbname); if (!zend_is_callable(fini_callback, 0, &cbname)) { php_error_docref(NULL, E_WARNING, "function '%s' is not callable", ZSTR_VAL(cbname)); zend_string_release(cbname); RETURN_FALSE; } zend_string_release(cbname); H = (pdo_sqlite_db_handle *)dbh->driver_data; func = (struct pdo_sqlite_func*)ecalloc(1, sizeof(*func)); ret = sqlite3_create_function(H->db, func_name, argc, SQLITE_UTF8, func, NULL, php_sqlite3_func_step_callback, php_sqlite3_func_final_callback); if (ret == SQLITE_OK) { func->funcname = estrdup(func_name); ZVAL_COPY(&func->step, step_callback); ZVAL_COPY(&func->fini, fini_callback); func->argc = argc; func->next = H->funcs; H->funcs = func; RETURN_TRUE; } efree(func); RETURN_FALSE; }
ds_pair_t *ds_pair_ex(zval *key, zval *value) { ds_pair_t *pair = ds_pair(); ZVAL_COPY(&pair->key, key); ZVAL_COPY(&pair->value, value); return pair; }
void stream_client_do_connect_nonblocking( skyray_stream_client_t *self, zend_object *protocol_obj, zend_string *host, zend_long port, zval *return_value) { skyray_reactor_t *reactor = skyray_reactor_from_obj(Z_OBJ_P(self->reactor)); zval zstream; object_init_ex(&zstream, skyray_ce_Stream); skyray_stream_t * stream = skyray_stream_from_obj(Z_OBJ(zstream)); skyray_stream_init_nonblocking(stream, SR_TCP, reactor, protocol_obj); struct sockaddr_in addr; uv_ip4_addr(host->val, port, &addr); uv_connect_t *req = (uv_connect_t*)emalloc(sizeof(uv_connect_t)); req->type = UV_TCP; req->data = stream; uv_tcp_connect(req, &stream->tcp, (struct sockaddr*)&addr, on_connected); ZVAL_COPY(return_value, &zstream); }
PHPAPI void var_push_dtor(php_unserialize_data_t *var_hashx, zval *rval) { var_dtor_entries *var_hash; if (!var_hashx || !*var_hashx) { return; } var_hash = (*var_hashx)->last_dtor; #if VAR_ENTRIES_DBG fprintf(stderr, "var_push_dtor(%ld): %d\n", var_hash?var_hash->used_slots:-1L, Z_TYPE_PP(rval)); #endif if (!var_hash || var_hash->used_slots == VAR_ENTRIES_MAX) { var_hash = emalloc(sizeof(var_dtor_entries)); var_hash->used_slots = 0; var_hash->next = 0; if (!(*var_hashx)->first_dtor) { (*var_hashx)->first_dtor = var_hash; } else { ((var_dtor_entries *) (*var_hashx)->last_dtor)->next = var_hash; } (*var_hashx)->last_dtor = var_hash; } ZVAL_COPY(&var_hash->data[var_hash->used_slots], rval); var_hash->used_slots++; }
static void spl_ptr_llist_shift(spl_ptr_llist *llist, zval *ret) /* {{{ */ { spl_ptr_llist_element *head = llist->head; if (head == NULL) { ZVAL_UNDEF(ret); return; } if (head->next) { head->next->prev = NULL; } else { llist->tail = NULL; } llist->head = head->next; llist->count--; ZVAL_COPY(ret, &head->data); if (llist->dtor) { llist->dtor(head); } ZVAL_UNDEF(&head->data); SPL_LLIST_DELREF(head); }
static void spl_ptr_llist_pop(spl_ptr_llist *llist, zval *ret) /* {{{ */ { spl_ptr_llist_element *tail = llist->tail; if (tail == NULL) { ZVAL_UNDEF(ret); return; } if (tail->prev) { tail->prev->next = NULL; } else { llist->head = NULL; } llist->tail = tail->prev; llist->count--; ZVAL_COPY(ret, &tail->data); if (llist->dtor) { llist->dtor(tail); } ZVAL_UNDEF(&tail->data); SPL_LLIST_DELREF(tail); }
static void ast_create_virtual_node( zval *zv, zend_ast_kind kind, zend_ast *ast, zend_long version) { zval tmp_zv, tmp_zv2; object_init_ex(zv, ast_node_ce); ZVAL_LONG(&tmp_zv, kind); ast_update_property(zv, AST_STR(kind), &tmp_zv, AST_CACHE_SLOT_KIND); ZVAL_LONG(&tmp_zv, ast->attr); ast_update_property(zv, AST_STR(flags), &tmp_zv, AST_CACHE_SLOT_FLAGS); ZVAL_LONG(&tmp_zv, zend_ast_get_lineno(ast)); ast_update_property(zv, AST_STR(lineno), &tmp_zv, AST_CACHE_SLOT_LINENO); array_init(&tmp_zv); ast_update_property(zv, AST_STR(children), &tmp_zv, AST_CACHE_SLOT_CHILDREN); ZVAL_COPY(&tmp_zv2, zend_ast_get_zval(ast)); if (version >= 30) { zend_hash_add_new(Z_ARRVAL(tmp_zv), ast_kind_child_name(kind, 0), &tmp_zv2); } else { zend_hash_next_index_insert(Z_ARRVAL(tmp_zv), &tmp_zv2); } }
static inline void spl_fixedarray_object_write_dimension_helper(spl_fixedarray_object *intern, zval *offset, zval *value) /* {{{ */ { zend_long index; if (!offset) { /* '$array[] = value' syntax is not supported */ zend_throw_exception(spl_ce_RuntimeException, "Index invalid or out of range", 0); return; } if (Z_TYPE_P(offset) != IS_LONG) { index = spl_offset_convert_to_long(offset); } else { index = Z_LVAL_P(offset); } if (index < 0 || intern->array == NULL || index >= intern->array->size) { zend_throw_exception(spl_ce_RuntimeException, "Index invalid or out of range", 0); return; } else { if (!Z_ISUNDEF(intern->array->elements[index])) { zval_ptr_dtor(&(intern->array->elements[index])); } ZVAL_DEREF(value); ZVAL_COPY(&intern->array->elements[index], value); } }
/* {{{ proto mixed SplHeap::top() Peek at the top element of the heap */ SPL_METHOD(SplHeap, top) { zval *value; spl_heap_object *intern; if (zend_parse_parameters_none() == FAILURE) { return; } intern = Z_SPLHEAP_P(getThis()); if (intern->heap->flags & SPL_HEAP_CORRUPTED) { zend_throw_exception(spl_ce_RuntimeException, "Heap is corrupted, heap properties are no longer ensured.", 0); return; } value = spl_ptr_heap_top(intern->heap); if (!value) { zend_throw_exception(spl_ce_RuntimeException, "Can't peek at an empty heap", 0); return; } ZVAL_DEREF(value); ZVAL_COPY(return_value, value); }
static void ra_index_change_keys(const char *cmd, zval *z_keys, zval *z_redis) { int i, argc; zval z_fun, z_ret, *z_args; /* alloc */ argc = 1 + zend_hash_num_elements(Z_ARRVAL_P(z_keys)); z_args = emalloc(argc * sizeof(zval*)); /* prepare first parameters */ ZVAL_STRING(&z_fun, cmd); z_args = safe_emalloc(sizeof(zval), argc, 0); ZVAL_STRING(&z_args[0], PHPREDIS_INDEX_NAME); /* prepare keys */ for (i = 0; i < argc - 1; ++i) { zval *zpp; zpp = zend_hash_index_find(Z_ARRVAL_P(z_keys), i); ZVAL_COPY(&z_args[i+1], zpp); } /* run cmd */ call_user_function(&redis_ce->function_table, z_redis, &z_fun, &z_ret, argc, z_args); /* don't dtor z_ret, since we're returning z_redis */ /* free index name zval */ for (i = 0; i < argc; i++) { zval_ptr_dtor(&z_args[i]); efree(&z_args[i]); /* free index name zval */ } efree(z_args); /* free container */ }
void uopz_get_property(zval *object, zval *member, zval *value) { /* {{{ */ zend_class_entry *scope = uopz_get_scope(1); zend_class_entry *ce = Z_OBJCE_P(object); zend_property_info *info; zval *prop, rv; do { uopz_set_scope(ce); info = zend_get_property_info(ce, Z_STR_P(member), 1); if (info && info != ZEND_WRONG_PROPERTY_INFO) { break; } ce = ce->parent; } while (ce); if (info && info != ZEND_WRONG_PROPERTY_INFO) { uopz_set_scope(info->ce); } else { uopz_set_scope(Z_OBJCE_P(object)); } prop = Z_OBJ_HT_P(object) ->read_property(object, member, BP_VAR_R, NULL, &rv); uopz_set_scope(scope); if (!prop) { return; } ZVAL_COPY(value, prop); } /* }}} */
/* {{{ proto mixed SplDoublyLinkedList::offsetGet(mixed index) Returns the value at the specified $index. */ SPL_METHOD(SplDoublyLinkedList, offsetGet) { zval *zindex; zend_long index; spl_dllist_object *intern; spl_ptr_llist_element *element; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &zindex) == FAILURE) { return; } intern = Z_SPLDLLIST_P(getThis()); index = spl_offset_convert_to_long(zindex); if (index < 0 || index >= intern->llist->count) { zend_throw_exception(spl_ce_OutOfRangeException, "Offset invalid or out of range", 0); return; } element = spl_ptr_llist_offset(intern->llist, index, intern->flags & SPL_DLLIST_IT_LIFO); if (element != NULL) { zval *value = &element->data; ZVAL_DEREF(value); ZVAL_COPY(return_value, value); } else { zend_throw_exception(spl_ce_OutOfRangeException, "Offset invalid", 0); } } /* }}} */
/* {{{ resourcebundle_get_iterator */ zend_object_iterator *resourcebundle_get_iterator( zend_class_entry *ce, zval *object, int byref ) { ResourceBundle_object *rb = Z_INTL_RESOURCEBUNDLE_P(object ); ResourceBundle_iterator *iterator = emalloc( sizeof( ResourceBundle_iterator ) ); if (byref) { php_error( E_ERROR, "ResourceBundle does not support writable iterators" ); } zend_iterator_init(&iterator->intern); ZVAL_COPY(&iterator->intern.data, object); iterator->intern.funcs = &resourcebundle_iterator_funcs; iterator->subject = rb; /* The iterated rb can only be either URES_TABLE or URES_ARRAY * All other types are returned as php primitives! */ iterator->is_table = (ures_getType( rb->me ) == URES_TABLE); iterator->length = ures_getSize( rb->me ); ZVAL_UNDEF(&iterator->current); iterator->currentkey = NULL; iterator->i = 0; return (zend_object_iterator *) iterator; }
zend_object_iterator *php_com_saproxy_iter_get(zend_class_entry *ce, zval *object, int by_ref) { php_com_saproxy *proxy = SA_FETCH(object); php_com_saproxy_iter *I; int i; if (by_ref) { zend_throw_error(NULL, "An iterator cannot be used with foreach by reference"); return NULL; } I = ecalloc(1, sizeof(*I)); I->iter.funcs = &saproxy_iter_funcs; Z_PTR(I->iter.data) = I; I->proxy = proxy; ZVAL_COPY(&I->proxy_obj, object); I->indices = safe_emalloc(proxy->dimensions + 1, sizeof(LONG), 0); for (i = 0; i < proxy->dimensions; i++) { convert_to_long(&proxy->indices[i]); I->indices[i] = (LONG)Z_LVAL(proxy->indices[i]); } SafeArrayGetLBound(V_ARRAY(&proxy->obj->v), proxy->dimensions, &I->imin); SafeArrayGetUBound(V_ARRAY(&proxy->obj->v), proxy->dimensions, &I->imax); I->key = I->imin; return &I->iter; }
void php_filter_callback(PHP_INPUT_FILTER_PARAM_DECL) { zval retval; zval args[1]; int status; if (!option_array || !zend_is_callable(option_array, IS_CALLABLE_CHECK_NO_ACCESS, NULL)) { php_error_docref(NULL, E_WARNING, "First argument is expected to be a valid callback"); zval_ptr_dtor(value); ZVAL_NULL(value); return; } ZVAL_COPY(&args[0], value); status = call_user_function_ex(EG(function_table), NULL, option_array, &retval, 1, args, 0, NULL); if (status == SUCCESS && !Z_ISUNDEF(retval)) { zval_ptr_dtor(value); ZVAL_COPY_VALUE(value, &retval); } else { zval_ptr_dtor(value); ZVAL_NULL(value); } zval_ptr_dtor(&args[0]); }
void skyray_promise_do_resolve(skyray_promise_t *self, zval *value, zend_bool is_copy_required) { zval *result, tmp; if (Z_TYPE(self->result) != IS_UNDEF) { return; } if (skyray_is_promise_instance(value)) { result = skyray_promise_unwrap_zval(value); } else { skyray_fulfilled_promise_t *promise = skyray_fulfilled_promise_new(value, is_copy_required); ZVAL_OBJ(&tmp, &promise->std); result = &tmp; } if (skyray_is_promise_instance(result)) { ZVAL_COPY_VALUE(&self->result, result); } else { ZVAL_COPY(&self->result, result); } if (skyray_is_resolved_promise(result)) { call_resolved_handlers(self, &self->on_fulfilled, &self->on_rejcted); } else { skyray_promise_t *result_promsie = skyray_promise_from_obj(Z_OBJ_P(result)); zend_hash_copy(&result_promsie->on_fulfilled, &self->on_fulfilled, (copy_ctor_func_t)context_copy_func); zend_hash_copy(&result_promsie->on_rejcted, &self->on_rejcted, (copy_ctor_func_t)context_copy_func); zend_hash_destroy(&self->on_fulfilled); zend_hash_destroy(&self->on_rejcted); } }
/* {{{ php_xsl_create_object */ void php_xsl_create_object(xsltStylesheetPtr obj, zval *wrapper_in, zval *return_value ) { zval *wrapper; zend_class_entry *ce; if (!obj) { wrapper = wrapper_in; ZVAL_NULL(wrapper); return; } if ((wrapper = xsl_object_get_data((void *) obj))) { ZVAL_COPY(wrapper, wrapper_in); return; } if (!wrapper_in) { wrapper = return_value; } else { wrapper = wrapper_in; } ce = xsl_xsltprocessor_class_entry; if (!wrapper_in) { object_init_ex(wrapper, ce); } php_xsl_set_object(wrapper, (void *) obj); return; }
/* {{{ proto mixed SplPriorityQueue::top() Peek at the top element of the priority queue */ SPL_METHOD(SplPriorityQueue, top) { zval *value, *value_out; spl_heap_object *intern; if (zend_parse_parameters_none() == FAILURE) { return; } intern = Z_SPLHEAP_P(getThis()); if (intern->heap->flags & SPL_HEAP_CORRUPTED) { zend_throw_exception(spl_ce_RuntimeException, "Heap is corrupted, heap properties are no longer ensured.", 0); return; } value = spl_ptr_heap_top(intern->heap); if (!value) { zend_throw_exception(spl_ce_RuntimeException, "Can't peek at an empty heap", 0); return; } value_out = spl_pqueue_extract_helper(value, intern->flags); if (!value_out) { zend_error(E_RECOVERABLE_ERROR, "Unable to extract from the PriorityQueue node"); return; } ZVAL_DEREF(value_out); ZVAL_COPY(return_value, value_out); }
void uopz_get_static_property(zend_class_entry *ce, zend_string *property, zval *value) { /* {{{ */ zend_class_entry *scope = uopz_get_scope(1); zend_class_entry *seek = ce; zend_property_info *info; zval *prop; do { uopz_set_scope(seek); info = zend_get_property_info(seek, property, 1); if (info && info != ZEND_WRONG_PROPERTY_INFO) { break; } seek = seek->parent; } while (seek); if (info && info != ZEND_WRONG_PROPERTY_INFO) { uopz_set_scope(info->ce); } else { uopz_set_scope(ce); } prop = zend_std_get_static_property(uopz_get_scope(0), property, 1); uopz_set_scope(scope); if (!prop) { return; } ZVAL_COPY(value, prop); } /* }}} */
/* {{{ mysqli_read_property */ zval *mysqli_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv) { zval tmp_member; zval *retval; mysqli_object *obj; mysqli_prop_handler *hnd = NULL; obj = Z_MYSQLI_P(object); if (Z_TYPE_P(member) != IS_STRING) { ZVAL_COPY(&tmp_member, member); convert_to_string(&tmp_member); member = &tmp_member; } if (obj->prop_handler != NULL) { hnd = zend_hash_find_ptr(obj->prop_handler, Z_STR_P(member)); } if (hnd) { retval = hnd->read_func(obj, rv); if (retval == NULL) { retval = &EG(uninitialized_zval); } } else { zend_object_handlers *std_hnd = zend_get_std_object_handlers(); retval = std_hnd->read_property(object, member, type, cache_slot, rv); } if (member == &tmp_member) { zval_dtor(member); } return retval; }
/** * Returns the paths using positions as keys and names as values * * @return array */ PHP_METHOD(Test_Router_Route, getReversedPaths) { zend_string *_3; zend_ulong _2; zval reversed, path, position, _0, *_1; ZEPHIR_INIT_THIS(); ZVAL_UNDEF(&reversed); ZVAL_UNDEF(&path); ZVAL_UNDEF(&position); ZVAL_UNDEF(&_0); ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(&reversed); array_init(&reversed); zephir_read_property(&_0, this_ptr, SL("_paths"), PH_NOISY_CC | PH_READONLY); zephir_is_iterable(&_0, 0, "test/router/route.zep", 478); ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_0), _2, _3, _1) { ZEPHIR_INIT_NVAR(&path); if (_3 != NULL) { ZVAL_STR_COPY(&path, _3); } else { ZVAL_LONG(&path, _2); } ZEPHIR_INIT_NVAR(&position); ZVAL_COPY(&position, _1); zephir_array_update_zval(&reversed, &position, &path, PH_COPY | PH_SEPARATE); } ZEND_HASH_FOREACH_END();
/* {{{ mysqli_write_property */ void mysqli_write_property(zval *object, zval *member, zval *value, void **cache_slot) { zval tmp_member; mysqli_object *obj; mysqli_prop_handler *hnd = NULL; if (Z_TYPE_P(member) != IS_STRING) { ZVAL_COPY(&tmp_member, member); convert_to_string(&tmp_member); member = &tmp_member; } obj = Z_MYSQLI_P(object); if (obj->prop_handler != NULL) { hnd = zend_hash_find_ptr(obj->prop_handler, Z_STR_P(member)); } if (hnd) { hnd->write_func(obj, value); } else { zend_object_handlers *std_hnd = zend_get_std_object_handlers(); std_hnd->write_property(object, member, value, cache_slot); } if (member == &tmp_member) { zval_dtor(member); } }
static void spl_fixedarray_copy(spl_fixedarray *to, spl_fixedarray *from) /* {{{ */ { int i; for (i = 0; i < from->size; i++) { ZVAL_COPY(&to->elements[i], &from->elements[i]); } }
static int zephir_update_static_property_ex(zend_class_entry *scope, const char *name, int name_length, zval *value, zend_property_info **property_info) { zval garbage; zval *property; zend_class_entry *old_scope; #if PHP_VERSION_ID >= 70100 old_scope = EG(fake_scope); EG(fake_scope) = scope; #else old_scope = EG(scope); EG(scope) = scope; #endif property = zephir_std_get_static_property(scope, name, name_length, 0, property_info); #if PHP_VERSION_ID >= 70100 EG(fake_scope) = old_scope; #else EG(scope) = old_scope; #endif if (!property) { return FAILURE; } else { ZVAL_COPY_VALUE(&garbage, property); if (Z_ISREF_P(value)) { SEPARATE_ZVAL(value); } ZVAL_COPY(property, value); zval_ptr_dtor(&garbage); return SUCCESS; } }
PHP_METHOD(Test_Flow, testFor1) { int c = 0; zval v, b, _0, *_1; ZEPHIR_INIT_THIS(); ZVAL_UNDEF(&v); ZVAL_UNDEF(&b); ZVAL_UNDEF(&_0); ZEPHIR_MM_GROW(); c = 0; ZEPHIR_INIT_VAR(&b); zephir_create_array(&b, 4, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(&_0); ZVAL_LONG(&_0, 1); zephir_array_fast_append(&b, &_0); ZEPHIR_INIT_NVAR(&_0); ZVAL_LONG(&_0, 2); zephir_array_fast_append(&b, &_0); ZEPHIR_INIT_NVAR(&_0); ZVAL_LONG(&_0, 3); zephir_array_fast_append(&b, &_0); ZEPHIR_INIT_NVAR(&_0); ZVAL_LONG(&_0, 4); zephir_array_fast_append(&b, &_0); zephir_is_iterable(&b, 0, "test/flow.zep", 443); ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&b), _1) { ZEPHIR_INIT_NVAR(&v); ZVAL_COPY(&v, _1); c += zephir_get_numberval(&v); } ZEND_HASH_FOREACH_END();
zend_object_iterator *spl_dllist_get_iterator(zend_class_entry *ce, zval *object, int by_ref) /* {{{ */ { spl_dllist_it *iterator; spl_dllist_object *dllist_object = Z_SPLDLLIST_P(object); if (by_ref) { zend_throw_exception(spl_ce_RuntimeException, "An iterator cannot be used with foreach by reference", 0); return NULL; } iterator = emalloc(sizeof(spl_dllist_it)); zend_iterator_init((zend_object_iterator*)iterator); ZVAL_COPY(&iterator->intern.it.data, object); iterator->intern.it.funcs = &spl_dllist_it_funcs; iterator->intern.ce = ce; iterator->traverse_position = dllist_object->traverse_position; iterator->traverse_pointer = dllist_object->traverse_pointer; iterator->flags = dllist_object->flags & SPL_DLLIST_IT_MASK; ZVAL_UNDEF(&iterator->intern.value); SPL_LLIST_CHECK_ADDREF(iterator->traverse_pointer); return &iterator->intern.it; }