struct php_pq_callback *recursion;
} php_pq_callback_t;
+#define PHP_PQ_CALLBACK_INIT {{0},{0},NULL}
+
extern void php_pq_callback_dtor(php_pq_callback_t *cb);
extern void php_pq_callback_addref(php_pq_callback_t *cb);
extern zval *php_pq_callback_to_zval(php_pq_callback_t *cb, zval *tmp);
}
}
-int php_pq_compare_index(const void *lptr, const void *rptr)
+int php_pq_compare_index_80(Bucket *lptr, Bucket *rptr)
{
- zend_ulong l = ((const Bucket *) lptr)->h;
- zend_ulong r = ((const Bucket *) rptr)->h;
+ zend_ulong l = lptr->h;
+ zend_ulong r = rptr->h;
if (l < r) {
return -1;
}
return 0;
}
+int php_pq_compare_index_70(const void *lptr, const void *rptr) {
+ return php_pq_compare_index_80((Bucket *) lptr, (Bucket *) rptr);
+}
void php_pq_hash_ptr_dtor(zval *p)
{
zval rv, tmp;
ZVAL_NULL(&rv);
- zend_call_method_with_1_params(getThis(), php_pqdt_class_entry, NULL, "format", &rv,
- zend_read_property(php_pqdt_class_entry, getThis(), ZEND_STRL("format"), 0, &tmp));
+ php_pq_call_method(getThis(), "format", 1, &rv, php_pq_read_property(getThis(), "format", &tmp));
RETVAL_ZVAL(&rv, 1, 1);
}
{0}
};
-zval *php_pqdt_from_string(zval *zv, char *input_fmt, char *dt_str, size_t dt_len, char *output_fmt, zval *ztimezone)
+zval *php_pqdt_from_string(zval *zv, char *input_fmt, char *dt_str, size_t dt_len, const char *output_fmt, zval *ztimezone)
{
php_date_obj *dobj;
zval_dtor(zv);
ZVAL_NULL(zv);
} else if (output_fmt) {
- zend_update_property_string(php_pqdt_class_entry, zv, ZEND_STRL("format"), output_fmt);
+ zval fmt;
+ ZVAL_STRING(&fmt, output_fmt);
+ php_pq_update_property(zv, "format", &fmt);
+ zval_ptr_dtor(&fmt);
}
return zv;
ZVAL_NULL(&rv);
- if (Z_OBJ_HT_P(zdt)->cast_object
- && SUCCESS == Z_OBJ_HT_P(zdt)->cast_object(zdt, &rv, IS_STRING)
- ) {
+ if (php_pq_cast_object(zdt, IS_STRING, &rv)) {
return Z_STR(rv);
} else if (instanceof_function(Z_OBJCE_P(zdt), php_date_get_date_ce())) {
zval rv, zfmt;
ZVAL_NULL(&rv);
ZVAL_STRING(&zfmt, format);
- zend_call_method_with_1_params(zdt, Z_OBJCE_P(zdt), NULL, "format", &rv, &zfmt);
+ php_pq_call_method(zdt, "format", 1, &rv, &zfmt);
zval_ptr_dtor(&zfmt);
if (Z_TYPE(rv) == IS_STRING) {
extern const char *php_pq_strmode(long mode);
/* compare array index */
-extern int php_pq_compare_index(const void *lptr, const void *rptr);
+#if PHP_VERSION_ID >= 80000
+# define php_pq_compare_index php_pq_compare_index_80
+#else
+# define php_pq_compare_index php_pq_compare_index_70
+#endif
+extern int php_pq_compare_index_80(Bucket *lptr, Bucket *rptr);
+extern int php_pq_compare_index_70(const void *lptr, const void *rptr);
/* free zval ptr values (as hash dtor) */
extern void php_pq_hash_ptr_dtor(zval *p);
#define PHP_PQresultErrorMessage(r) php_pq_rtrim(PQresultErrorMessage((r)))
extern zend_class_entry *php_pqdt_class_entry;
-extern zval *php_pqdt_from_string(zval *zv, char *input_fmt, char *dt_str, size_t dt_len, char *output_fmt, zval *ztimezone);
+extern zval *php_pqdt_from_string(zval *zv, char *input_fmt, char *dt_str, size_t dt_len, const char *output_fmt, zval *ztimezone);
extern zend_string *php_pqdt_to_string(zval *zdt, const char *format);
extern zend_class_entry *php_pqconv_class_entry;
extern HashTable *php_pq_parse_array(php_pqres_t *res, const char *val_str, size_t val_len, Oid typ);
+/* ZE compat */
+#if PHP_VERSION_ID >= 80000
+# define php_pq_call_method(objval_ptr, method_name, num_args, ...) \
+ zend_call_method_with_ ## num_args ## _params( \
+ Z_OBJ_P(objval_ptr), Z_OBJCE_P(objval_ptr), NULL, \
+ (method_name), __VA_ARGS__)
+# define php_pq_read_property(objval_ptr, prop_name, tmpval_ptr) \
+ zend_read_property(Z_OBJCE_P(objval_ptr), Z_OBJ_P(objval_ptr), \
+ (prop_name), strlen(prop_name), 0, (tmpval_ptr))
+# define php_pq_update_property(objval_ptr, prop_name, newval_ptr) \
+ zend_update_property(Z_OBJCE_P(objval_ptr), Z_OBJ_P(objval_ptr), \
+ (prop_name), strlen(prop_name), (newval_ptr))
+#define php_pq_cast_object(objval_ptr, cast_type, retval_ptr) \
+ (Z_OBJ_HT_P(objval_ptr)->cast_object && \
+ SUCCESS == Z_OBJ_HT_P(objval_ptr)->cast_object(Z_OBJ_P(objval_ptr), (retval_ptr), (cast_type)))
+#else
+# define php_pq_call_method(objval_ptr, method_name, num_args, ...) \
+ zend_call_method_with_ ## num_args ## _params( \
+ (objval_ptr), NULL, NULL, \
+ (method_name), __VA_ARGS__)
+# define php_pq_read_property(objval_ptr, prop_name, tmpval_ptr) \
+ zend_read_property(Z_OBJCE_P(objval_ptr), (objval_ptr), \
+ (prop_name), strlen(prop_name), 0, (tmpval_ptr))
+# define php_pq_update_property(objval_ptr, prop_name, newval_ptr) \
+ zend_update_property(Z_OBJCE_P(objval_ptr), (objval_ptr), \
+ (prop_name), strlen(prop_name), (newval_ptr))
+#define php_pq_cast_object(objval_ptr, cast_type, retval_ptr) \
+ (Z_OBJ_HT_P(objval_ptr)->cast_object && \
+ SUCCESS == Z_OBJ_HT_P(objval_ptr)->cast_object(objval_ptr, (retval_ptr), (cast_type)))
+#endif
+
+
extern PHP_MINIT_FUNCTION(pq_misc);
struct apply_pi_to_ht_arg {
HashTable *ht;
- zval *object;
php_pq_object_t *pq_obj;
unsigned gc:1;
};
ZVAL_STR(&member, pi->name);
ZVAL_ARR(&return_value, arg->ht);
- handler->gc(arg->object, arg->pq_obj, &return_value);
+ handler->gc(arg->pq_obj, &return_value);
}
} else {
zval tmp_prop, *property = NULL;
- property = zend_read_property(arg->pq_obj->zo.ce, arg->object, pi->name->val, pi->name->len, 0, &tmp_prop);
+ property = php_pq_object_read_prop_80(&arg->pq_obj->zo, pi->name, BP_VAR_R, NULL, &tmp_prop);
zend_hash_update(arg->ht, pi->name, property);
}
return ZEND_HASH_APPLY_KEEP;
}
-HashTable *php_pq_object_debug_info(zval *object, int *temp)
+HashTable *php_pq_object_debug_info_80(zend_object *object, int *temp)
{
struct apply_pi_to_ht_arg arg = {NULL};
ALLOC_HASHTABLE(arg.ht);
ZEND_INIT_SYMTABLE(arg.ht);
- arg.object = object;
- arg.pq_obj = PHP_PQ_OBJ(object, NULL);
+ arg.pq_obj = PHP_PQ_OBJ(NULL, object);
arg.gc = 0;
zend_hash_apply_with_argument(&arg.pq_obj->zo.ce->properties_info, apply_pi_to_ht, &arg);
return arg.ht;
}
+HashTable *php_pq_object_debug_info_70(zval *object, int *temp)
+{
+ return php_pq_object_debug_info_80(Z_OBJ_P(object), temp);
+}
-HashTable *php_pq_object_properties(zval *object)
+HashTable *php_pq_object_properties_80(zend_object *object)
{
struct apply_pi_to_ht_arg arg = {NULL};
arg.ht = zend_get_std_object_handlers()->get_properties(object);
- arg.object = object;
- arg.pq_obj = PHP_PQ_OBJ(object, NULL);
+ arg.pq_obj = PHP_PQ_OBJ(NULL, object);
arg.gc = 0;
zend_hash_apply_with_argument(&arg.pq_obj->zo.ce->properties_info, apply_pi_to_ht, &arg);
return arg.ht;
+
+}
+HashTable *php_pq_object_properties_70(zval *object)
+{
+ return php_pq_object_properties_80(Z_OBJ_P(object));
}
-HashTable *php_pq_object_get_gc(zval *object, zval **table, int *n)
+HashTable *php_pq_object_get_gc_80(zend_object *object, zval **table, int *n)
{
struct apply_pi_to_ht_arg arg = {NULL};
- arg.object = object;
- arg.pq_obj = PHP_PQ_OBJ(object, NULL);
+ arg.pq_obj = PHP_PQ_OBJ(NULL, object);
arg.ht = &arg.pq_obj->gc;
arg.gc = 1;
return arg.ht;
}
+HashTable *php_pq_object_get_gc_70(zval *object, zval **table, int *n)
+{
+ return php_pq_object_get_gc_80(Z_OBJ_P(object), table, n);
+}
zend_class_entry *ancestor(zend_class_entry *ce)
{
return ce;
}
-zval *php_pq_object_read_prop(zval *object, zval *member, int type, void **cache_slot, zval *tmp)
+zval *php_pq_object_read_prop_80(zend_object *object, zend_string *member, int type, void **cache_slot, zval *tmp)
{
- php_pq_object_t *obj = PHP_PQ_OBJ(object, NULL);
+ php_pq_object_t *obj = PHP_PQ_OBJ(NULL, object);
php_pq_object_prophandler_t *handler;
zval *return_value = NULL;
if (!obj->intern) {
php_error(E_RECOVERABLE_ERROR, "%s not initialized", ancestor(obj->zo.ce)->name->val);
- } else if (!(handler = zend_hash_find_ptr(obj->prophandler, Z_STR_P(member))) || !handler->read) {
+ } else if (!(handler = zend_hash_find_ptr(obj->prophandler, member)) || !handler->read) {
/* default handler */
} else if (type != BP_VAR_R) {
php_error(E_WARNING, "Cannot access %s properties by reference or array key/index", ancestor(obj->zo.ce)->name->val);
} else {
- handler->read(object, obj, tmp);
+ handler->read(obj, tmp);
zend_get_std_object_handlers()->write_property(object, member, tmp, cache_slot);
return_value = tmp;
- /*
- zval dtor;
-
- ZVAL_COPY_VALUE(&dtor, return_value);
-
- ZVAL_ZVAL(return_value, tmp, 0, 0);
- zval_ptr_dtor(&dtor);
-
- */
-
if (cache_slot) {
*cache_slot = NULL;
}
return return_value;
}
+zval *php_pq_object_read_prop_74(zval *object, zval *member, int type, void **cache_slot, zval *tmp)
+{
+ zend_string *member_str = zval_get_string(member);
+ zval *return_value = php_pq_object_read_prop_80(Z_OBJ_P(object), member_str, type, cache_slot, tmp);
+ zend_string_release(member_str);
+ return return_value;
+}
+void php_pq_object_read_prop_70(zval *object, zval *member, int type, void **cache_slot, zval *tmp)
+{
+ (void) php_pq_object_read_prop_74(object, member, type, cache_slot, tmp);
+}
-php_pq_object_write_prop_t php_pq_object_write_prop(zval *object, zval *member, zval *value, void **cache_slot)
+zval *php_pq_object_write_prop_80(zend_object *object, zend_string *member, zval *value, void **cache_slot)
{
- php_pq_object_t *obj = PHP_PQ_OBJ(object, NULL);
+ php_pq_object_t *obj = PHP_PQ_OBJ(NULL, object);
php_pq_object_prophandler_t *handler;
if (!obj->intern) {
php_error(E_RECOVERABLE_ERROR, "%s not initialized", ancestor(obj->zo.ce)->name->val);
zend_get_std_object_handlers()->write_property(object, member, value, cache_slot);
- } else if ((handler = zend_hash_find_ptr(obj->prophandler, Z_STR_P(member)))) {
+ } else if ((handler = zend_hash_find_ptr(obj->prophandler, member))) {
if (handler->write) {
- handler->write(object, obj, value);
+ handler->write(obj, value);
}
} else {
zend_get_std_object_handlers()->write_property(object, member, value, cache_slot);
}
-#if PHP_VERSION_ID >= 70400
return value;
-#endif
+}
+zval *php_pq_object_write_prop_74(zval *object, zval *member, zval *value, void **cache_slot)
+{
+ zend_string *member_str = zval_get_string(member);
+ zval *return_value = php_pq_object_write_prop_80(Z_OBJ_P(object), member_str, value, cache_slot);
+ zend_string_release(member_str);
+ return return_value;
+}
+void php_pq_object_write_prop_70(zval *object, zval *member, zval *value, void **cache_slot)
+{
+ (void) php_pq_object_write_prop_74(object, member, value, cache_slot);
}
-zval *php_pq_object_get_prop_ptr_null(zval *object, zval *member, int type, void **cache_slot)
+zval *php_pq_object_get_prop_ptr_null_80(zend_object *object, zend_string *member, int type, void **cache_slot)
+{
+ return NULL;
+}
+zval *php_pq_object_get_prop_ptr_null_70(zval *object, zval *member, int type, void **cache_slot)
{
return NULL;
}
return (void *) (((char *) zo) - zo->handlers->offset);
}
-typedef void (*php_pq_object_prophandler_func_t)(zval *object, void *o, zval *return_value);
+extern zend_class_entry *ancestor(zend_class_entry *ce);
+
+typedef void (*php_pq_object_prophandler_func_t)(void *o, zval *return_value);
typedef struct php_pq_object_prophandler {
php_pq_object_prophandler_func_t read;
php_pq_object_prophandler_func_t gc;
} php_pq_object_prophandler_t;
+extern void php_pq_object_prophandler_dtor(zval *zv);
+
extern void *php_pq_object_create(zend_class_entry *ce, void *intern, size_t obj_size, zend_object_handlers *oh, HashTable *ph);
extern void php_pq_object_dtor(zend_object *obj);
extern void php_pq_object_to_zval(void *o, zval *zv);
extern void php_pq_object_to_zval_no_addref(void *o, zval *zv);
extern void php_pq_object_addref(void *o);
extern void php_pq_object_delref(void *o);
-extern HashTable *php_pq_object_debug_info(zval *object, int *temp);
-extern HashTable *php_pq_object_properties(zval *object);
-HashTable *php_pq_object_get_gc(zval *object, zval **table, int *n);
-extern zend_class_entry *ancestor(zend_class_entry *ce);
-extern zval *php_pq_object_read_prop(zval *object, zval *member, int type, void **cache_slot, zval *tmp);
-#if PHP_VERSION_ID >= 70400
-typedef zval *php_pq_object_write_prop_t;
+
+#if PHP_VERSION_ID >= 80000
+# define php_pq_object_debug_info php_pq_object_debug_info_80
#else
-typedef void php_pq_object_write_prop_t;
+# define php_pq_object_debug_info php_pq_object_debug_info_70
#endif
-extern php_pq_object_write_prop_t php_pq_object_write_prop(zval *object, zval *member, zval *value, void **cache_slot);
-extern zval *php_pq_object_get_prop_ptr_null(zval *object, zval *member, int type, void **cache_slot);
-extern void php_pq_object_prophandler_dtor(zval *zv);
+extern HashTable *php_pq_object_debug_info_80(zend_object *object, int *temp);
+extern HashTable *php_pq_object_debug_info_70(zval *object, int *temp);
+
+#if PHP_VERSION_ID >= 80000
+# define php_pq_object_properties php_pq_object_properties_80
+#else
+# define php_pq_object_properties php_pq_object_properties_70
+#endif
+extern HashTable *php_pq_object_properties_80(zend_object *object);
+extern HashTable *php_pq_object_properties_70(zval *object);
+
+#if PHP_VERSION_ID >= 80000
+# define php_pq_object_get_gc php_pq_object_get_gc_80
+#else
+# define php_pq_object_get_gc php_pq_object_get_gc_70
+#endif
+extern HashTable *php_pq_object_get_gc_80(zend_object *object, zval **table, int *n);
+extern HashTable *php_pq_object_get_gc_70(zval *object, zval **table, int *n);
+
+#if PHP_VERSION_ID >= 80000
+# define php_pq_object_read_prop php_pq_object_read_prop_80
+#elif PHP_VERSION_ID >= 70400
+# define php_pq_object_read_prop php_pq_object_read_prop_74
+#else
+# define php_pq_object_read_prop php_pq_object_read_prop_70
+#endif
+extern zval *php_pq_object_read_prop_80(zend_object *object, zend_string *member, int type, void **cache_slot, zval *tmp);
+extern zval *php_pq_object_read_prop_74(zval *object, zval *member, int type, void **cache_slot, zval *tmp);
+extern void php_pq_object_read_prop_70(zval *object, zval *member, int type, void **cache_slot, zval *tmp);
+
+#if PHP_VERSION_ID >= 80000
+# define php_pq_object_write_prop php_pq_object_write_prop_80
+#elif PHP_VERSION_ID >= 70400
+# define php_pq_object_write_prop php_pq_object_write_prop_74
+#else
+# define php_pq_object_write_prop php_pq_object_write_prop_70
+#endif
+extern zval *php_pq_object_write_prop_80(zend_object *object, zend_string *member, zval *value, void **cache_slot);
+extern zval *php_pq_object_write_prop_74(zval *object, zval *member, zval *value, void **cache_slot);
+extern void php_pq_object_write_prop_70(zval *object, zval *member, zval *value, void **cache_slot);
+
+#if PHP_VERSION_ID >= 80000
+# define php_pq_object_get_prop_ptr_null php_pq_object_get_prop_ptr_null_80
+#else
+# define php_pq_object_get_prop_ptr_null php_pq_object_get_prop_ptr_null_70
+#endif
+extern zval *php_pq_object_get_prop_ptr_null_80(zend_object *object, zend_string *member, int type, void **cache_slot);
+extern zval *php_pq_object_get_prop_ptr_null_70(zval *object, zval *member, int type, void **cache_slot);
#endif
zval ztype, rv;
ZVAL_LONG(&ztype, arg->type);
- zend_call_method_with_2_params(arg->zconv, NULL, NULL, "converttostring", &rv, zparam, &ztype);
+ php_pq_call_method(arg->zconv, "converttostring", 2, &rv, zparam, &ztype);
tmpstr = zval_get_string(&rv);
zval_ptr_dtor(&rv);
goto append_string;
ZVAL_NULL(&rv);
ZVAL_LONG(&ztype, type);
- zend_call_method_with_2_params(zconv, NULL, NULL, "converttostring", &rv, zpp, &ztype);
+ php_pq_call_method(zconv, "converttostring", 2, &rv, zpp, &ztype);
convert_to_string(&rv);
p->param.strings[index] = Z_STRVAL_P(&rv);
zend_hash_next_index_insert(&p->param.dtor, &rv);
return &php_pqcancel_create_object_ex(class_type, NULL)->zo;
}
-static void php_pqcancel_object_read_connection(zval *object, void *o, zval *return_value)
+static void php_pqcancel_object_read_connection(void *o, zval *return_value)
{
php_pqcancel_object_t *obj = o;
php_pq_object_to_zval(obj->intern->conn, return_value);
}
-static void php_pqcancel_object_gc_connection(zval *object, void *o, zval *return_value)
+static void php_pqcancel_object_gc_connection(void *o, zval *return_value)
{
php_pqcancel_object_t *obj = o;
zval zconn;
return &php_pqconn_create_object_ex(class_type, NULL)->zo;
}
-static void php_pqconn_object_read_status(zval *object, void *o, zval *return_value)
+static void php_pqconn_object_read_status(void *o, zval *return_value)
{
php_pqconn_object_t *obj = o;
RETVAL_LONG(PQstatus(obj->intern->conn));
}
-static void php_pqconn_object_read_transaction_status(zval *object, void *o, zval *return_value)
+static void php_pqconn_object_read_transaction_status(void *o, zval *return_value)
{
php_pqconn_object_t *obj = o;
RETVAL_LONG(PQtransactionStatus(obj->intern->conn));
}
-static void php_pqconn_object_read_error_message(zval *object, void *o, zval *return_value)
+static void php_pqconn_object_read_error_message(void *o, zval *return_value)
{
php_pqconn_object_t *obj = o;
char *error = PHP_PQerrorMessage(obj->intern->conn);
}
}
-static void php_pqconn_object_read_busy(zval *object, void *o, zval *return_value)
+static void php_pqconn_object_read_busy(void *o, zval *return_value)
{
php_pqconn_object_t *obj = o;
RETVAL_BOOL(PQisBusy(obj->intern->conn));
}
-static void php_pqconn_object_read_encoding(zval *object, void *o, zval *return_value)
+static void php_pqconn_object_read_encoding(void *o, zval *return_value)
{
php_pqconn_object_t *obj = o;
RETVAL_STRING(pg_encoding_to_char(PQclientEncoding(obj->intern->conn)));
}
-static void php_pqconn_object_write_encoding(zval *object, void *o, zval *value)
+static void php_pqconn_object_write_encoding(void *o, zval *value)
{
php_pqconn_object_t *obj = o;
zend_string *zenc = zval_get_string(value);
zend_string_release(zenc);
}
-static void php_pqconn_object_read_unbuffered(zval *object, void *o, zval *return_value)
+static void php_pqconn_object_read_unbuffered(void *o, zval *return_value)
{
php_pqconn_object_t *obj = o;
RETVAL_BOOL(obj->intern->unbuffered);
}
-static void php_pqconn_object_write_unbuffered(zval *object, void *o, zval *value)
+static void php_pqconn_object_write_unbuffered(void *o, zval *value)
{
php_pqconn_object_t *obj = o;
obj->intern->unbuffered = z_is_true(value);
}
-static void php_pqconn_object_read_nonblocking(zval *object, void *o, zval *return_value)
+static void php_pqconn_object_read_nonblocking(void *o, zval *return_value)
{
php_pqconn_object_t *obj = o;
RETVAL_BOOL(PQisnonblocking(obj->intern->conn));
}
-static void php_pqconn_object_write_nonblocking(zval *object, void *o, zval *value)
+static void php_pqconn_object_write_nonblocking(void *o, zval *value)
{
php_pqconn_object_t *obj = o;
PQsetnonblocking(obj->intern->conn, z_is_true(value));
}
-static void php_pqconn_object_read_db(zval *object, void *o, zval *return_value)
+static void php_pqconn_object_read_db(void *o, zval *return_value)
{
php_pqconn_object_t *obj = o;
char *db = PQdb(obj->intern->conn);
}
}
-static void php_pqconn_object_read_user(zval *object, void *o, zval *return_value)
+static void php_pqconn_object_read_user(void *o, zval *return_value)
{
php_pqconn_object_t *obj = o;
char *user = PQuser(obj->intern->conn);
}
}
-static void php_pqconn_object_read_pass(zval *object, void *o, zval *return_value)
+static void php_pqconn_object_read_pass(void *o, zval *return_value)
{
php_pqconn_object_t *obj = o;
char *pass = PQpass(obj->intern->conn);
}
}
-static void php_pqconn_object_read_host(zval *object, void *o, zval *return_value)
+static void php_pqconn_object_read_host(void *o, zval *return_value)
{
php_pqconn_object_t *obj = o;
char *host = PQhost(obj->intern->conn);
}
}
-static void php_pqconn_object_read_port(zval *object, void *o, zval *return_value)
+static void php_pqconn_object_read_port(void *o, zval *return_value)
{
php_pqconn_object_t *obj = o;
char *port = PQport(obj->intern->conn);
}
#if HAVE_PQCONNINFO
-static void php_pqconn_object_read_params(zval *object, void *o, zval *return_value)
+static void php_pqconn_object_read_params(void *o, zval *return_value)
{
php_pqconn_object_t *obj = o;
PQconninfoOption *ptr, *params = PQconninfo(obj->intern->conn);
}
#endif
-static void php_pqconn_object_read_options(zval *object, void *o, zval *return_value)
+static void php_pqconn_object_read_options(void *o, zval *return_value)
{
php_pqconn_object_t *obj = o;
char *options = PQoptions(obj->intern->conn);
return ZEND_HASH_APPLY_KEEP;
}
-static void php_pqconn_object_read_event_handlers(zval *object, void *o, zval *return_value)
+static void php_pqconn_object_read_event_handlers(void *o, zval *return_value)
{
php_pqconn_object_t *obj = o;
zend_hash_apply_with_arguments(&obj->intern->eventhandlers, apply_read_callbacks, 1, Z_ARRVAL_P(return_value));
}
-static void php_pqconn_object_gc_event_handlers(zval *object, void *o, zval *return_value)
+static void php_pqconn_object_gc_event_handlers(void *o, zval *return_value)
{
php_pqconn_object_t *obj = o;
zval *evhs;
ZEND_HASH_FOREACH_END();
}
-static void php_pqconn_object_read_listeners(zval *object, void *o, zval *return_value)
+static void php_pqconn_object_read_listeners(void *o, zval *return_value)
{
php_pqconn_object_t *obj = o;
zend_hash_apply_with_arguments(&obj->intern->listeners, apply_read_callbacks, 1, Z_ARRVAL_P(return_value));
}
-static void php_pqconn_object_gc_listeners(zval *object, void *o, zval *return_value)
+static void php_pqconn_object_gc_listeners(void *o, zval *return_value)
{
php_pqconn_object_t *obj = o;
zval *listeners;
ZEND_HASH_FOREACH_END();
}
-static void php_pqconn_object_read_converters(zval *object, void *o, zval *return_value)
+static void php_pqconn_object_read_converters(void *o, zval *return_value)
{
php_pqconn_object_t *obj = o;
zend_hash_copy(Z_ARRVAL_P(return_value), &obj->intern->converters, zval_add_ref);
}
-static void php_pqconn_object_gc_converters(zval *object, void *o, zval *return_value)
+static void php_pqconn_object_gc_converters(void *o, zval *return_value)
{
php_pqconn_object_t *obj = o;
zval *converter;
ZEND_HASH_FOREACH_END();
}
-static void php_pqconn_object_read_def_fetch_type(zval *object, void *o, zval *return_value)
+static void php_pqconn_object_read_def_fetch_type(void *o, zval *return_value)
{
php_pqconn_object_t *obj = o;
RETVAL_LONG(obj->intern->default_fetch_type);
}
-static void php_pqconn_object_write_def_fetch_type(zval *object, void *o, zval *value)
+static void php_pqconn_object_write_def_fetch_type(void *o, zval *value)
{
php_pqconn_object_t *obj = o;
obj->intern->default_fetch_type = zval_get_long(value) & 0x3; /* two bits only */
}
-static void php_pqconn_object_read_def_txn_isolation(zval *object, void *o, zval *return_value)
+static void php_pqconn_object_read_def_txn_isolation(void *o, zval *return_value)
{
php_pqconn_object_t *obj = o;
RETVAL_LONG(obj->intern->default_txn_isolation);
}
-static void php_pqconn_object_write_def_txn_isolation(zval *object, void *o, zval *value)
+static void php_pqconn_object_write_def_txn_isolation(void *o, zval *value)
{
php_pqconn_object_t *obj = o;
obj->intern->default_txn_isolation = zval_get_long(value) & 0x3; /* two bits only */
}
-static void php_pqconn_object_read_def_txn_readonly(zval *object, void *o, zval *return_value)
+static void php_pqconn_object_read_def_txn_readonly(void *o, zval *return_value)
{
php_pqconn_object_t *obj = o;
RETVAL_BOOL(obj->intern->default_txn_readonly);
}
-static void php_pqconn_object_write_def_txn_readonly(zval *object, void *o, zval *value)
+static void php_pqconn_object_write_def_txn_readonly(void *o, zval *value)
{
php_pqconn_object_t *obj = o;
obj->intern->default_txn_readonly = z_is_true(value);
}
-static void php_pqconn_object_read_def_txn_deferrable(zval *object, void *o, zval *return_value)
+static void php_pqconn_object_read_def_txn_deferrable(void *o, zval *return_value)
{
php_pqconn_object_t *obj = o;
RETVAL_BOOL(obj->intern->default_txn_deferrable);
}
-static void php_pqconn_object_write_def_txn_deferrable(zval *object, void *o, zval *value)
+static void php_pqconn_object_write_def_txn_deferrable(void *o, zval *value)
{
php_pqconn_object_t *obj = o;
obj->intern->default_txn_deferrable = zend_is_true(value);
}
-static void php_pqconn_object_read_def_auto_conv(zval *object, void *o, zval *return_value)
+static void php_pqconn_object_read_def_auto_conv(void *o, zval *return_value)
{
php_pqconn_object_t *obj = o;
RETVAL_LONG(obj->intern->default_auto_convert);
}
-static void php_pqconn_object_write_def_auto_conv(zval*object, void *o, zval *value)
+static void php_pqconn_object_write_def_auto_conv(void *o, zval *value)
{
php_pqconn_object_t *obj = o;
ZVAL_NULL(&zsocket);
retval = FAILURE;
}
+#if PHP_VERSION_ID >= 80000
+ zend_get_std_object_handlers()->write_property(Z_OBJ_P(zobj), Z_STR(zmember), &zsocket, NULL);
+#else
zend_get_std_object_handlers()->write_property(zobj, &zmember, &zsocket, NULL);
+#endif
zval_ptr_dtor(&zsocket);
zval_ptr_dtor(&zmember);
zend_error_handling zeh;
char *channel_str = NULL;
size_t channel_len = 0;
- php_pq_callback_t listener = {{0}};
+ php_pq_callback_t listener = PHP_PQ_CALLBACK_INIT;
ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh);
zend_error_handling zeh;
char *channel_str = NULL;
size_t channel_len = 0;
- php_pq_callback_t listener = {{0}};
+ php_pq_callback_t listener = PHP_PQ_CALLBACK_INIT;
ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh);
ZEND_END_ARG_INFO();
static PHP_METHOD(pqconn, execAsync) {
zend_error_handling zeh;
- php_pq_callback_t resolver = {{0}};
+ php_pq_callback_t resolver = PHP_PQ_CALLBACK_INIT;
char *query_str;
size_t query_len;
ZEND_RESULT_CODE rv;
ZEND_END_ARG_INFO();
static PHP_METHOD(pqconn, execParamsAsync) {
zend_error_handling zeh;
- php_pq_callback_t resolver = {{0}};
+ php_pq_callback_t resolver = PHP_PQ_CALLBACK_INIT;
char *query_str;
size_t query_len;
zval *zparams;
zend_error_handling zeh;
char *type_str;
size_t type_len;
- php_pq_callback_t cb = {{0}};
+ php_pq_callback_t cb = PHP_PQ_CALLBACK_INIT;
ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh);
struct apply_set_converter_arg arg = {NULL};
ZVAL_NULL(&zoids);
- zend_call_method_with_0_params(zcnv, NULL, NULL, "converttypes", &zoids);
+ php_pq_call_method(zcnv, "converttypes", 0, &zoids);
ZVAL_DUP(&tmp, &zoids);
convert_to_array(&tmp);
struct apply_set_converter_arg arg = {NULL};
ZVAL_NULL(&zoids);
- zend_call_method_with_0_params(zcnv, NULL, NULL, "converttypes", &zoids);
+ php_pq_call_method(zcnv, "converttypes", 0, &zoids);
ZVAL_DUP(&tmp, &zoids);
convert_to_array(&tmp);
return &php_pqcopy_create_object_ex(class_type, NULL)->zo;
}
-static void php_pqcopy_object_read_connection(zval *object, void *o, zval *return_value)
+static void php_pqcopy_object_read_connection(void *o, zval *return_value)
{
php_pqcopy_object_t *obj = o;
php_pq_object_to_zval(obj->intern->conn, return_value);
}
-static void php_pqcopy_object_gc_connection(zval *object, void *o, zval *return_value)
+static void php_pqcopy_object_gc_connection(void *o, zval *return_value)
{
php_pqcopy_object_t *obj = o;
zval zconn;
add_next_index_zval(return_value, &zconn);
}
-static void php_pqcopy_object_read_direction(zval *object, void *o, zval *return_value)
+static void php_pqcopy_object_read_direction(void *o, zval *return_value)
{
php_pqcopy_object_t *obj = o;
RETVAL_LONG(obj->intern->direction);
}
-static void php_pqcopy_object_read_expression(zval *object, void *o, zval *return_value)
+static void php_pqcopy_object_read_expression(void *o, zval *return_value)
{
php_pqcopy_object_t *obj = o;
RETURN_STRING(obj->intern->expression);
}
-static void php_pqcopy_object_read_options(zval *object, void *o, zval *return_value)
+static void php_pqcopy_object_read_options(void *o, zval *return_value)
{
php_pqcopy_object_t *obj = o;
char *spec_str = "1";
size_t spec_len = 1;
ZEND_RESULT_CODE rv;
- php_pq_callback_t resolver = {{0}};
+ php_pq_callback_t resolver = PHP_PQ_CALLBACK_INIT;
zend_error_handling zeh;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh);
return &php_pqcur_create_object_ex(class_type, NULL)->zo;
}
-static void php_pqcur_object_read_name(zval *object, void *o, zval *return_value)
+static void php_pqcur_object_read_name(void *o, zval *return_value)
{
php_pqcur_object_t *obj = o;
RETVAL_STRING(obj->intern->name);
}
-static void php_pqcur_object_read_connection(zval *object, void *o, zval *return_value)
+static void php_pqcur_object_read_connection(void *o, zval *return_value)
{
php_pqcur_object_t *obj = o;
php_pq_object_to_zval(obj->intern->conn, return_value);
}
-static void php_pqcur_object_gc_connection(zval *object, void *o, zval *return_value)
+static void php_pqcur_object_gc_connection(void *o, zval *return_value)
{
php_pqcur_object_t *obj = o;
zval zconn;
add_next_index_zval(return_value, &zconn);
}
-static void php_pqcur_object_read_query(zval *object, void *o, zval *return_value)
+static void php_pqcur_object_read_query(void *o, zval *return_value)
{
php_pqcur_object_t *obj = o;
RETVAL_STRING(obj->intern->decl + obj->intern->query_offset);
}
-static void php_pqcur_object_read_flags(zval *object, void *o, zval *return_value)
+static void php_pqcur_object_read_flags(void *o, zval *return_value)
{
php_pqcur_object_t *obj = o;
PHP_ME(pqcur, move, ai_pqcur_move, ZEND_ACC_PUBLIC)
PHP_ME(pqcur, fetchAsync, ai_pqcur_fetchAsync, ZEND_ACC_PUBLIC)
PHP_ME(pqcur, moveAsync, ai_pqcur_moveAsync, ZEND_ACC_PUBLIC)
- {NULL, NULL, NULL}
+ {0}
};
PHP_MSHUTDOWN_FUNCTION(pqcur)
return &php_pqlob_create_object_ex(class_type, NULL)->zo;
}
-static void php_pqlob_object_read_transaction(zval *object, void *o, zval *return_value)
+static void php_pqlob_object_read_transaction(void *o, zval *return_value)
{
php_pqlob_object_t *obj = o;
php_pq_object_to_zval(obj->intern->txn, return_value);
}
-static void php_pqlob_object_gc_transaction(zval *object, void *o, zval *return_value)
+static void php_pqlob_object_gc_transaction(void *o, zval *return_value)
{
php_pqlob_object_t *obj = o;
zval ztxn;
add_next_index_zval(return_value, &ztxn);
}
-static void php_pqlob_object_read_oid(zval *object, void *o, zval *return_value)
+static void php_pqlob_object_read_oid(void *o, zval *return_value)
{
php_pqlob_object_t *obj = o;
RETVAL_LONG(obj->intern->loid);
}
-static void php_pqlob_object_update_stream(zval *this_ptr, php_pqlob_object_t *obj, zval *zstream);
+static void php_pqlob_object_update_stream(php_pqlob_object_t *obj, zval *zstream);
-static void php_pqlob_object_read_stream(zval *object, void *o, zval *return_value)
+static void php_pqlob_object_read_stream(void *o, zval *return_value)
{
php_pqlob_object_t *obj = o;
zval zstream;
if (!obj->intern->stream) {
- php_pqlob_object_update_stream(object, obj, &zstream);
+ php_pqlob_object_update_stream(obj, &zstream);
} else {
php_stream_to_zval(obj->intern->stream, &zstream);
}
RETVAL_ZVAL(&zstream, 1, 0);
}
-static size_t php_pqlob_stream_write(php_stream *stream, const char *buffer, size_t length)
+static ssize_t php_pqlob_stream_write(php_stream *stream, const char *buffer, size_t length)
{
php_pqlob_object_t *obj = stream->abstract;
- int written = 0;
+ ssize_t written = 0;
if (obj) {
written = lo_write(obj->intern->txn->intern->conn->intern->conn, obj->intern->lofd, buffer, length);
return written;
}
-static size_t php_pqlob_stream_read(php_stream *stream, char *buffer, size_t length)
+static ssize_t php_pqlob_stream_read(php_stream *stream, char *buffer, size_t length)
{
php_pqlob_object_t *obj = stream->abstract;
- int read = 0;
+ ssize_t read = 0;
if (obj) {
NULL, /* set_option */
};
-static void php_pqlob_object_update_stream(zval *zpqlob, php_pqlob_object_t *obj, zval *zstream)
+static void php_pqlob_object_update_stream(php_pqlob_object_t *obj, zval *zstream)
{
- zval zmember;
+ zval zobj, zmember;
ZVAL_STRINGL(&zmember, "stream", sizeof("stream")-1);
- if (!obj) {
- obj = PHP_PQ_OBJ(zpqlob, NULL);
- }
obj->intern->stream = php_stream_alloc(&php_pqlob_stream_ops, obj, NULL, "r+b");
obj->intern->stream->flags |= PHP_STREAM_FLAG_NO_FCLOSE;
php_stream_to_zval(obj->intern->stream, zstream);
+#if PHP_VERSION_ID >= 80000
+ zend_get_std_object_handlers()->write_property(&obj->zo, Z_STR(zmember), zstream, NULL);
+#else
+ ZVAL_OBJ(&zobj, &obj->zo);
zend_get_std_object_handlers()->write_property(zpqlob, &zmember, zstream, NULL);
+#endif
zval_ptr_dtor(&zmember);
}
iter->zi.funcs = &php_pqres_iterator_funcs;
ZVAL_COPY_VALUE(&iter->zi.data, object);
- zfetch_type = zend_read_property(ce, object, ZEND_STRL("fetchType"), 0, &tmp);
+ zfetch_type = php_pq_read_property(object, "fetchType", &tmp);
iter->fetch_type = zval_get_long(zfetch_type);
#if DBG_GC
fprintf(stderr, "INIT iter(#%d) %p res(#%d) %p\n", iter->zi.std.handle, iter, Z_OBJ_HANDLE_P(object), PHP_PQ_OBJ(object, NULL));
ZVAL_NULL(&rv);
ZVAL_LONG(&ztype, typ);
- zend_call_method_with_2_params(zconv, NULL, NULL, "convertfromstring", &rv, zv, &ztype);
+ php_pq_call_method(zconv, "convertfromstring", 2, &rv, zv, &ztype);
zval_ptr_dtor(zv);
ZVAL_ZVAL(zv, &rv, 0, 0);
php_pqres_iterator_rewind,
/* invalidate current value/key (optional, may be NULL) */
php_pqres_iterator_invalidate
+#if PHP_VERSION_ID >= 80000
+ , NULL
+#endif
};
-static ZEND_RESULT_CODE php_pqres_count_elements(zval *object, long *count)
+#if PHP_VERSION_ID >= 80000
+# define php_pqres_count_elements php_pqres_count_elements_80
+#else
+# define php_pqres_count_elements php_pqres_count_elements_70
+#endif
+static ZEND_RESULT_CODE php_pqres_count_elements_80(zend_object *object, long *count)
{
- php_pqres_object_t *obj = PHP_PQ_OBJ(object, NULL);
+ php_pqres_object_t *obj = PHP_PQ_OBJ(NULL, object);
if (!obj->intern) {
return FAILURE;
return SUCCESS;
}
}
+static ZEND_RESULT_CODE php_pqres_count_elements_70(zval *object, long *count)
+{
+ return php_pqres_count_elements_80(Z_OBJ_P(object), count);
+}
ZEND_RESULT_CODE php_pqres_success(PGresult *res)
{
- zval zexc;
+ zval zexc, zsqlstate;
switch (PQresultStatus(res)) {
case PGRES_BAD_RESPONSE:
case PGRES_NONFATAL_ERROR:
case PGRES_FATAL_ERROR:
ZVAL_OBJ(&zexc, throw_exce(EX_SQL, "%s", PHP_PQresultErrorMessage(res)));
- zend_update_property_string(Z_OBJCE(zexc), &zexc, ZEND_STRL("sqlstate"), PQresultErrorField(res, PG_DIAG_SQLSTATE));
+ ZVAL_STRING(&zsqlstate, PQresultErrorField(res, PG_DIAG_SQLSTATE));
+ php_pq_update_property(&zexc, "sqlstate", &zsqlstate);
+ zval_ptr_dtor(&zsqlstate);
return FAILURE;
default:
return SUCCESS;
return &php_pqres_create_object_ex(class_type, NULL)->zo;
}
-static void php_pqres_object_read_status(zval *object, void *o, zval *return_value)
+static void php_pqres_object_read_status(void *o, zval *return_value)
{
php_pqres_object_t *obj = o;
RETVAL_LONG(PQresultStatus(obj->intern->res));
}
-static void php_pqres_object_read_status_message(zval *object, void *o, zval *return_value)
+static void php_pqres_object_read_status_message(void *o, zval *return_value)
{
php_pqres_object_t *obj = o;
RETVAL_STRING(PQresStatus(PQresultStatus(obj->intern->res))+sizeof("PGRES"));
}
-static void php_pqres_object_read_error_message(zval *object, void *o, zval *return_value)
+static void php_pqres_object_read_error_message(void *o, zval *return_value)
{
php_pqres_object_t *obj = o;
char *error = PHP_PQresultErrorMessage(obj->intern->res);
# define PG_DIAG_SOURCE_FUNCTION 'R'
#endif
-static void php_pqres_object_read_diag(zval *object, void *o, zval *return_value)
+static void php_pqres_object_read_diag(void *o, zval *return_value)
{
php_pqres_object_t *obj = o;
int i;
}
}
-static void php_pqres_object_read_num_rows(zval *object, void *o, zval *return_value)
+static void php_pqres_object_read_num_rows(void *o, zval *return_value)
{
php_pqres_object_t *obj = o;
RETVAL_LONG(PQntuples(obj->intern->res));
}
-static void php_pqres_object_read_num_cols(zval *object, void *o, zval *return_value)
+static void php_pqres_object_read_num_cols(void *o, zval *return_value)
{
php_pqres_object_t *obj = o;
RETVAL_LONG(PQnfields(obj->intern->res));
}
-static void php_pqres_object_read_affected_rows(zval *object, void *o, zval *return_value)
+static void php_pqres_object_read_affected_rows(void *o, zval *return_value)
{
php_pqres_object_t *obj = o;
RETVAL_LONG(atoi(PQcmdTuples(obj->intern->res)));
}
-static void php_pqres_object_read_fetch_type(zval *object, void *o, zval *return_value)
+static void php_pqres_object_read_fetch_type(void *o, zval *return_value)
{
php_pqres_object_t *obj = o;
RETVAL_LONG(php_pqres_fetch_type(obj->intern));
}
-static void php_pqres_object_write_fetch_type(zval *object, void *o, zval *value)
+static void php_pqres_object_write_fetch_type(void *o, zval *value)
{
php_pqres_object_t *obj = o;
if (!obj->intern->iter) {
- php_pqres_internal_iterator_init(object);
+ zval object;
+
+ ZVAL_OBJ(&object, &obj->zo);
+ php_pqres_internal_iterator_init(&object);
}
obj->intern->iter->fetch_type = zval_get_long(value);
}
-static void php_pqres_object_read_auto_conv(zval *object, void *o, zval *return_value)
+static void php_pqres_object_read_auto_conv(void *o, zval *return_value)
{
php_pqres_object_t *obj = o;
RETVAL_LONG(obj->intern->auto_convert);
}
-static void php_pqres_object_write_auto_conv(zval *object, void *o, zval *value)
+static void php_pqres_object_write_auto_conv(void *o, zval *value)
{
php_pqres_object_t *obj = o;
if (SUCCESS == rv) {
long count;
- if (SUCCESS != php_pqres_count_elements(getThis(), &count)) {
+ if (SUCCESS != php_pqres_count_elements_70(getThis(), &count)) {
throw_exce(EX_UNINITIALIZED, "pq\\Result not initialized");
} else {
RETVAL_LONG(count);
}
}
+ZEND_BEGIN_ARG_INFO_EX(ai_pqres_getIterator, 0, 0, 0)
+ZEND_END_ARG_INFO();
+static PHP_METHOD(pqres, getIterator)
+{
+ ZEND_PARSE_PARAMETERS_NONE();
+ zend_create_internal_iterator_zval(return_value, ZEND_THIS);
+}
+
static zend_function_entry php_pqres_methods[] = {
PHP_ME(pqres, bind, ai_pqres_bind, ZEND_ACC_PUBLIC)
PHP_ME(pqres, fetchBound, ai_pqres_fetch_bound, ZEND_ACC_PUBLIC)
PHP_ME(pqres, count, ai_pqres_count, ZEND_ACC_PUBLIC)
PHP_ME(pqres, map, ai_pqres_map, ZEND_ACC_PUBLIC)
PHP_ME(pqres, desc, ai_pqres_desc, ZEND_ACC_PUBLIC)
+ PHP_ME(pqres, getIterator, ai_pqres_getIterator, ZEND_ACC_PUBLIC)
{0}
};
php_pqres_class_entry = zend_register_internal_class_ex(&ce, NULL);
php_pqres_class_entry->create_object = php_pqres_create_object;
php_pqres_class_entry->get_iterator = php_pqres_iterator_init;
- zend_class_implements(php_pqres_class_entry, 2, zend_ce_traversable, spl_ce_Countable);
+ zend_class_implements(php_pqres_class_entry, 2, zend_ce_aggregate, spl_ce_Countable);
memcpy(&php_pqres_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
php_pqres_object_handlers.offset = XtOffsetOf(php_pqres_object_t, zo);
return &php_pqstm_create_object_ex(class_type, NULL)->zo;
}
-static void php_pqstm_object_read_name(zval *object, void *o, zval *return_value)
+static void php_pqstm_object_read_name(void *o, zval *return_value)
{
php_pqstm_object_t *obj = o;
RETVAL_STRING(obj->intern->name);
}
-static void php_pqstm_object_read_connection(zval *object, void *o, zval *return_value)
+static void php_pqstm_object_read_connection(void *o, zval *return_value)
{
php_pqstm_object_t *obj = o;
php_pq_object_to_zval(obj->intern->conn, return_value);
}
-static void php_pqstm_object_gc_connection(zval *object, void *o, zval *return_value)
+static void php_pqstm_object_gc_connection(void *o, zval *return_value)
{
php_pqstm_object_t *obj = o;
zval zconn;
add_next_index_zval(return_value, &zconn);
}
-static void php_pqstm_object_read_query(zval *object, void *o, zval *return_value)
+static void php_pqstm_object_read_query(void *o, zval *return_value)
{
php_pqstm_object_t *obj = o;
RETVAL_STRING(obj->intern->query);
}
-static void php_pqstm_object_read_types(zval *object, void *o, zval *return_value)
+static void php_pqstm_object_read_types(void *o, zval *return_value)
{
int i;
php_pqstm_object_t *obj = o;
static PHP_METHOD(pqstm, execAsync) {
zend_error_handling zeh;
zval *zparams = NULL;
- php_pq_callback_t resolver = {{0}};
+ php_pq_callback_t resolver = PHP_PQ_CALLBACK_INIT;
ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh);
ZEND_END_ARG_INFO();
static PHP_METHOD(pqstm, descAsync) {
zend_error_handling zeh;
- php_pq_callback_t resolver = {{0}};
+ php_pq_callback_t resolver = PHP_PQ_CALLBACK_INIT;
ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh);
return &php_pqtxn_create_object_ex(class_type, NULL)->zo;
}
-static void php_pqtxn_object_read_connection(zval *object, void *o, zval *return_value)
+static void php_pqtxn_object_read_connection(void *o, zval *return_value)
{
php_pqtxn_object_t *obj = o;
php_pq_object_to_zval(obj->intern->conn, return_value);
}
-static void php_pqtxn_object_gc_connection(zval *object, void *o, zval *return_value)
+static void php_pqtxn_object_gc_connection(void *o, zval *return_value)
{
php_pqtxn_object_t *obj = o;
zval zconn;
add_next_index_zval(return_value, &zconn);
}
-static void php_pqtxn_object_read_isolation(zval *object, void *o, zval *return_value)
+static void php_pqtxn_object_read_isolation(void *o, zval *return_value)
{
php_pqtxn_object_t *obj = o;
RETVAL_LONG(obj->intern->isolation);
}
-static void php_pqtxn_object_read_readonly(zval *object, void *o, zval *return_value)
+static void php_pqtxn_object_read_readonly(void *o, zval *return_value)
{
php_pqtxn_object_t *obj = o;
RETVAL_BOOL(obj->intern->readonly);
}
-static void php_pqtxn_object_read_deferrable(zval *object, void *o, zval *return_value)
+static void php_pqtxn_object_read_deferrable(void *o, zval *return_value)
{
php_pqtxn_object_t *obj = o;
RETVAL_BOOL(obj->intern->deferrable);
}
-static void php_pqtxn_object_write_isolation(zval *object, void *o, zval *value)
+static void php_pqtxn_object_write_isolation(void *o, zval *value)
{
php_pqtxn_object_t *obj = o;
php_pqtxn_isolation_t orig = obj->intern->isolation;
}
}
-static void php_pqtxn_object_write_readonly(zval *object, void *o, zval *value)
+static void php_pqtxn_object_write_readonly(void *o, zval *value)
{
php_pqtxn_object_t *obj = o;
PGresult *res;
}
}
-static void php_pqtxn_object_write_deferrable(zval *object, void *o, zval *value)
+static void php_pqtxn_object_write_deferrable(void *o, zval *value)
{
php_pqtxn_object_t *obj = o;
PGresult *res;
return &php_pqtypes_create_object_ex(class_type, NULL)->zo;
}
-static void php_pqtypes_object_read_connection(zval *object, void *o, zval *return_value)
+static void php_pqtypes_object_read_connection(void *o, zval *return_value)
{
php_pqtypes_object_t *obj = o;
php_pq_object_to_zval(obj->intern->conn, return_value);
}
-static void php_pqtypes_object_gc_connection(zval *object, void *o, zval *return_value)
+static void php_pqtypes_object_gc_connection(void *o, zval *return_value)
{
php_pqtypes_object_t *obj = o;
zval zconn;
}
}
-static int php_pqtypes_object_has_dimension(zval *object, zval *member, int check_empty)
+#if PHP_VERSION_ID >= 80000
+# define php_pqtypes_object_has_dimension php_pqtypes_object_has_dimension_80
+#else
+# define php_pqtypes_object_has_dimension php_pqtypes_object_has_dimension_70
+#endif
+static int php_pqtypes_object_has_dimension_80(zend_object *object, zval *member, int check_empty)
{
- php_pqtypes_object_t *obj = PHP_PQ_OBJ(object, NULL);
+ php_pqtypes_object_t *obj = PHP_PQ_OBJ(NULL, object);
zend_string *key = NULL;
zend_long index = 0;
return 0;
}
+static int php_pqtypes_object_has_dimension_70(zval *object, zval *member, int check_empty)
+{
+ return php_pqtypes_object_has_dimension_80(Z_OBJ_P(object), member, check_empty);
+}
-static zval *php_pqtypes_object_read_dimension(zval *object, zval *member, int type, zval *rv)
+#if PHP_VERSION_ID >= 80000
+# define php_pqtypes_object_read_dimension php_pqtypes_object_read_dimension_80
+#else
+# define php_pqtypes_object_read_dimension php_pqtypes_object_read_dimension_70
+#endif
+static zval *php_pqtypes_object_read_dimension_80(zend_object *object, zval *member, int type, zval *rv)
{
- php_pqtypes_object_t *obj = PHP_PQ_OBJ(object, NULL);
+ php_pqtypes_object_t *obj = PHP_PQ_OBJ(NULL, object);
zend_string *key = NULL;
zend_long index = 0;
zval *data = NULL;
return data;
}
+static zval *php_pqtypes_object_read_dimension_70(zval *object, zval *member, int type, zval *rv)
+{
+ return php_pqtypes_object_read_dimension_80(Z_OBJ_P(object), member, type, rv);
+}
-static void php_pqtypes_object_write_dimension(zval *object, zval *offset, zval *value)
+#if PHP_VERSION_ID >= 80000
+# define php_pqtypes_object_write_dimension php_pqtypes_object_write_dimension_80
+#else
+# define php_pqtypes_object_write_dimension php_pqtypes_object_write_dimension_70
+#endif
+static void php_pqtypes_object_write_dimension_80(zend_object *object, zval *offset, zval *value)
+{
+ throw_exce(EX_RUNTIME, "pq\\Types object must not be modified");
+}
+static void php_pqtypes_object_write_dimension_70(zval *object, zval *offset, zval *value)
{
throw_exce(EX_RUNTIME, "pq\\Types object must not be modified");
}
-static void php_pqtypes_object_unset_dimension(zval *object, zval *offset)
+#if PHP_VERSION_ID >= 80000
+# define php_pqtypes_object_unset_dimension php_pqtypes_object_unset_dimension_80
+#else
+# define php_pqtypes_object_unset_dimension php_pqtypes_object_unset_dimension_70
+#endif
+static void php_pqtypes_object_unset_dimension_80(zend_object *object, zval *offset)
+{
+ throw_exce(EX_RUNTIME, "pq\\Types object must not be modified");
+}
+static void php_pqtypes_object_unset_dimension_70(zval *object, zval *offset)
{
throw_exce(EX_RUNTIME, "pq\\Types object must not be modified");
}
zend_hash_init(&obj->intern->types, 512, NULL, ZVAL_PTR_DTOR, 0);
if (znsp) {
- zend_call_method_with_1_params(getThis(), Z_OBJCE_P(getThis()), NULL, "refresh", NULL, znsp);
+ php_pq_call_method(getThis(), "refresh", 1, NULL, znsp);
} else {
- zend_call_method_with_0_params(getThis(), Z_OBJCE_P(getThis()), NULL, "refresh", NULL);
+ php_pq_call_method(getThis(), "refresh", 0, NULL);
}
}
}
try {
new pq\Connection(1,2,3,4);
foo();
-} catch (pq\Exception $e) {
-assert($e->getCode() == pq\Exception::INVALID_ARGUMENT, $e->getCode()."!=".pq\Exception::INVALID_ARGUMENT);
-}
-try {
- new pq\Connection(1,2,3,4);
- foo();
+} catch (ArgumentCountError $e) {
+ // PHP 8
} catch (pq\Exception\InvalidArgumentException $e) {
assert($e->getCode() == pq\Exception::INVALID_ARGUMENT, $e->getCode()."!=".pq\Exception::INVALID_ARGUMENT);
}