redo PHP 8 compatibility
authorMichael Wallner <mike@php.net>
Thu, 24 Sep 2020 07:55:35 +0000 (09:55 +0200)
committerMichael Wallner <mike@php.net>
Thu, 24 Sep 2020 07:55:35 +0000 (09:55 +0200)
src/php_pq_misc.c
src/php_pq_misc.h
src/php_pq_object.c
src/php_pq_object.h
src/php_pqconn.c
src/php_pqlob.c
src/php_pqres.c
src/php_pqtypes.c

index dee39d6913932c6466427a565ed6eba17f7c9438..3e334c6e5e6fcbbe47c1804bf9aac6275131e968 100644 (file)
@@ -103,11 +103,8 @@ const char *php_pq_strmode(long mode)
        }
 }
 
-int php_pq_compare_index_80(Bucket *lptr, Bucket *rptr)
+static inline int compare_index(zend_ulong l, zend_ulong r)
 {
-       zend_ulong l = lptr->h;
-       zend_ulong r = rptr->h;
-
        if (l < r) {
                return -1;
        }
@@ -116,9 +113,16 @@ int php_pq_compare_index_80(Bucket *lptr, Bucket *rptr)
        }
        return 0;
 }
-int php_pq_compare_index_70(const void *lptr, const void *rptr) {
-       return php_pq_compare_index_80((Bucket *) lptr, (Bucket *) rptr);
+#if PHP_VERSION_ID >= 80000
+int php_pq_compare_index(Bucket *lptr, Bucket *rptr)
+{
+       return compare_index(lptr->h, rptr->h);
 }
+#else
+int php_pq_compare_index(const void *lptr, const void *rptr) {
+       return compare_index(((const Bucket *) lptr)->h, ((const Bucket *) rptr)->h);
+}
+#endif
 
 void php_pq_hash_ptr_dtor(zval *p)
 {
index 1672567d844fb9ec7f71f9e5f18cb0e4c5265df5..8c0ea235e10b80b3e1ae1c6c9dad71e09d07b670 100644 (file)
@@ -42,12 +42,10 @@ extern const char *php_pq_strmode(long mode);
 
 /* compare array index */
 #if PHP_VERSION_ID >= 80000
-# define php_pq_compare_index php_pq_compare_index_80
+extern int php_pq_compare_index(Bucket *lptr, Bucket *rptr);
 #else
-# define php_pq_compare_index php_pq_compare_index_70
+extern int php_pq_compare_index(const void *lptr, const void *rptr);
 #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);
@@ -92,10 +90,14 @@ extern HashTable *php_pq_parse_array(php_pqres_t *res, const char *val_str, size
 #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)))
+# if PHP_VERSION_ID <= 70200
+zval *zend_std_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv);
+# endif
 #endif
 
 
 
+
 extern PHP_MINIT_FUNCTION(pq_misc);
 
 #endif
index 27d740eba2369776771804b8ee95073d422c73de..ae22738fc4f37afa4c240d26914280acfae4f0cc 100644 (file)
@@ -17,6 +17,7 @@
 #include <php.h>
 
 #include "php_pq_object.h"
+#include "php_pq_misc.h"
 
 void *php_pq_object_create(zend_class_entry *ce, void *intern, size_t obj_size, zend_object_handlers *oh, HashTable *ph)
 {
@@ -82,6 +83,8 @@ struct apply_pi_to_ht_arg {
        unsigned gc:1;
 };
 
+static inline int php_pq_object_read_prop_ex(zend_object *object, zend_string *member, int type, zval *return_value);
+
 static int apply_pi_to_ht(zval *p, void *a)
 {
        zend_property_info *pi = Z_PTR_P(p);
@@ -91,23 +94,29 @@ static int apply_pi_to_ht(zval *p, void *a)
                php_pq_object_prophandler_t *handler;
 
                if ((handler = zend_hash_find_ptr(arg->pq_obj->prophandler, pi->name)) && handler->gc) {
-                       zval member, return_value;
+                       zval return_value;
 
-                       ZVAL_STR(&member, pi->name);
                        ZVAL_ARR(&return_value, arg->ht);
                        handler->gc(arg->pq_obj, &return_value);
                }
        } else {
-               zval tmp_prop, *property = NULL;
+               zval tmp_prop, *property;
+#if PHP_VERSION_ID < 80000
+               zval zobj, zprop;
 
-               property = php_pq_object_read_prop_80(&arg->pq_obj->zo, pi->name, BP_VAR_R, NULL, &tmp_prop);
+               ZVAL_OBJ(&zobj, &arg->pq_obj->zo);
+               ZVAL_STR(&zprop, pi->name);
+               property = php_pq_object_read_prop(&zobj, &zprop, BP_VAR_R, NULL, &tmp_prop);
+#else
+               property = php_pq_object_read_prop(&arg->pq_obj->zo, pi->name, BP_VAR_R, NULL, &tmp_prop);
+#endif
                zend_hash_update(arg->ht, pi->name, property);
        }
 
        return ZEND_HASH_APPLY_KEEP;
 }
 
-HashTable *php_pq_object_debug_info_80(zend_object *object, int *temp)
+static inline HashTable *php_pq_object_debug_info_ex(zend_object *object, int *temp)
 {
        struct apply_pi_to_ht_arg arg = {NULL};
 
@@ -122,10 +131,17 @@ HashTable *php_pq_object_debug_info_80(zend_object *object, int *temp)
 
        return arg.ht;
 }
-HashTable *php_pq_object_debug_info_70(zval *object, int *temp)
+#if PHP_VERSION_ID >= 80000
+HashTable *php_pq_object_debug_info(zend_object *object, int *temp)
+{
+       return php_pq_object_debug_info_ex(object, temp);
+}
+#else
+HashTable *php_pq_object_debug_info(zval *object, int *temp)
 {
-       return php_pq_object_debug_info_80(Z_OBJ_P(object), temp);
+       return php_pq_object_debug_info_ex(Z_OBJ_P(object), temp);
 }
+#endif
 
 static inline HashTable *php_pq_object_properties_ex(zend_object *object, HashTable *props)
 {
@@ -139,14 +155,17 @@ static inline HashTable *php_pq_object_properties_ex(zend_object *object, HashTa
 
        return arg.ht;
 }
-HashTable *php_pq_object_properties_80(zend_object *object)
+#if PHP_VERSION_ID >= 80000
+HashTable *php_pq_object_properties(zend_object *object)
 {
        return php_pq_object_properties_ex(object, zend_std_get_properties(object));
 }
-HashTable *php_pq_object_properties_70(zval *object)
+#else
+HashTable *php_pq_object_properties(zval *object)
 {
        return php_pq_object_properties_ex(Z_OBJ_P(object), zend_std_get_properties(object));
 }
+#endif
 
 static inline HashTable *php_pq_object_get_gc_ex(zend_object *object, HashTable *props, zval **table, int *n)
 {
@@ -165,14 +184,17 @@ static inline HashTable *php_pq_object_get_gc_ex(zend_object *object, HashTable
 
        return arg.ht;
 }
-HashTable *php_pq_object_get_gc_80(zend_object *object, zval **table, int *n)
+#if PHP_VERSION_ID >= 80000
+HashTable *php_pq_object_get_gc(zend_object *object, zval **table, int *n)
 {
        return php_pq_object_get_gc_ex(object, zend_std_get_properties(object), table, n);
 }
-HashTable *php_pq_object_get_gc_70(zval *object, zval **table, int *n)
+#else
+HashTable *php_pq_object_get_gc(zval *object, zval **table, int *n)
 {
        return php_pq_object_get_gc_ex(Z_OBJ_P(object), zend_std_get_properties(object), table, n);
 }
+#endif
 
 zend_class_entry *ancestor(zend_class_entry *ce)
 {
@@ -182,11 +204,10 @@ zend_class_entry *ancestor(zend_class_entry *ce)
        return ce;
 }
 
-zval *php_pq_object_read_prop_ex(zend_object *object, zend_string *member, int type, void **cache_slot, zval *tmp, zval *def)
+static inline int php_pq_object_read_prop_ex(zend_object *object, zend_string *member, int type, zval *return_value)
 {
        php_pq_object_t *obj = PHP_PQ_OBJ(NULL, object);
        php_pq_object_prophandler_t *handler;
-       zval *return_value = def;
 
        if (!obj->intern) {
                php_error(E_RECOVERABLE_ERROR, "%s not initialized", ancestor(obj->zo.ce)->name->val);
@@ -195,80 +216,104 @@ zval *php_pq_object_read_prop_ex(zend_object *object, zend_string *member, int t
        } 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(obj, tmp);
-               zend_get_std_object_handlers()->write_property(object, member, tmp, cache_slot);
-               return_value = tmp;
-
-               if (cache_slot) {
-                       *cache_slot = NULL;
-               }
+               handler->read(obj, return_value);
+               return SUCCESS;
        }
 
-       return return_value;
+       return FAILURE;
 }
-zval *php_pq_object_read_prop_80(zend_object *object, zend_string *member, int type, void **cache_slot, zval *tmp)
+#if PHP_VERSION_ID >= 80000
+zval *php_pq_object_read_prop(zend_object *object, zend_string *member, int type, void **cache_slot, zval *tmp)
 {
-       return php_pq_object_read_prop_ex(object, member, type, cache_slot, tmp, zend_std_read_property(object, member, type, cache_slot, tmp));
+       if (SUCCESS != php_pq_object_read_prop_ex(object, member, type, tmp)) {
+               return zend_std_read_property(object, member, type, cache_slot, tmp);
+       }
+
+       tmp = zend_std_write_property(object, member, tmp, cache_slot);
+       if (cache_slot) {
+               *cache_slot = NULL;
+       }
+       return tmp;
 }
-zval *php_pq_object_read_prop_70(zval *object, zval *member, int type, void **cache_slot, zval *tmp)
+#else
+zval *php_pq_object_read_prop(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_ex(Z_OBJ_P(object), member_str, type, cache_slot, tmp, zend_std_read_property(object, member, type, cache_slot, tmp));
+
+       if (SUCCESS != php_pq_object_read_prop_ex(Z_OBJ_P(object), member_str, type, tmp)) {
+               zend_string_release(member_str);
+               return zend_std_read_property(object, member, type, cache_slot, tmp);
+       }
        zend_string_release(member_str);
-       return return_value;
+
+#if PHP_VERSON_ID >= 70400
+       tmp =
+#endif
+                       zend_std_write_property(object, member, tmp, cache_slot);
+       if (cache_slot) {
+               *cache_slot = NULL;
+       }
+       return tmp;
 }
+#endif
 
-zval *php_pq_object_write_prop_ex(zend_object *object, zend_string *member, zval *value, void **cache_slot, int *update_std)
+static inline int php_pq_object_write_prop_ex(zend_object *object, zend_string *member, zval *value)
 {
        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);
-               *update_std = 1;
-       } else if ((handler = zend_hash_find_ptr(obj->prophandler, member))) {
+       } else if (!(handler = zend_hash_find_ptr(obj->prophandler, member))) {
+               /* default handler */
+       } else {
                if (handler->write) {
                        handler->write(obj, value);
                }
-               *update_std = 0;
-       } else {
-               *update_std = 1;
+               return SUCCESS;
        }
-       return value;
+       return FAILURE;
 }
-zval *php_pq_object_write_prop_80(zend_object *object, zend_string *member, zval *value, void **cache_slot)
+#if PHP_VERSION_ID >= 80000
+zval *php_pq_object_write_prop(zend_object *object, zend_string *member, zval *value, void **cache_slot)
 {
-       int update_std = 0;
-       zval *return_value = php_pq_object_write_prop_ex(object, member, value, cache_slot, &update_std);
-       if (update_std) {
-               return_value = zend_std_write_property(object, member, value, cache_slot);
+       if (SUCCESS != php_pq_object_write_prop_ex(object, member, value)) {
+               return zend_std_write_property(object, member, value, cache_slot);
        }
-       return return_value;
+       return value;
 }
-zval *php_pq_object_write_prop_74(zval *object, zval *member, zval *value, void **cache_slot)
+#elif PHP_VERSION_ID >= 70400
+zval *php_pq_object_write_prop(zval *object, zval *member, zval *value, void **cache_slot)
 {
-       int update_std = 0;
        zend_string *member_str = zval_get_string(member);
-       zval *return_value = php_pq_object_write_prop_ex(Z_OBJ_P(object), member_str, value, cache_slot, &update_std);
-       zend_string_release(member_str);
-       if (update_std) {
-               return_value = zend_std_write_property(object, member, value, cache_slot);
+       if (SUCCESS != php_pq_object_write_prop_ex(Z_OBJ_P(object), member_str, value)) {
+               value = zend_std_write_property(object, member, value, cache_slot);
        }
-       return return_value;
+       zend_string_release(member_str);
+       return value;
 }
-void php_pq_object_write_prop_70(zval *object, zval *member, zval *value, void **cache_slot)
+#else
+void php_pq_object_write_prop(zval *object, zval *member, zval *value, void **cache_slot)
 {
-       (void) php_pq_object_write_prop_74(object, member, value, cache_slot);
+       zend_string *member_str = zval_get_string(member);
+       if (SUCCESS != php_pq_object_write_prop_ex(Z_OBJ_P(object), member_str, value)) {
+               zend_std_write_property(object, member, value, cache_slot);
+       }
+       zend_string_release(member_str);
 }
+#endif
 
-zval *php_pq_object_get_prop_ptr_null_80(zend_object *object, zend_string *member, int type, void **cache_slot)
+#if PHP_VERSION_ID >= 80000
+zval *php_pq_object_get_prop_ptr_null(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)
+#else
+zval *php_pq_object_get_prop_ptr_null(zval *object, zval *member, int type, void **cache_slot)
 {
        return NULL;
 }
+#endif
 
 void php_pq_object_prophandler_dtor(zval *zv) {
        pefree(Z_PTR_P(zv), 1);
index f8aba1b144dc6fc2cc5d69201ba8b5d24c64fc19..0d86883148ddae90a354574f229a1c781cd8df4b 100644 (file)
@@ -50,55 +50,24 @@ extern void php_pq_object_addref(void *o);
 extern void php_pq_object_delref(void *o);
 
 #if PHP_VERSION_ID >= 80000
-# define php_pq_object_debug_info php_pq_object_debug_info_80
+extern HashTable *php_pq_object_debug_info(zend_object *object, int *temp);
+extern HashTable *php_pq_object_properties(zend_object *object);
+extern HashTable *php_pq_object_get_gc(zend_object *object, zval **table, int *n);
+extern zval *php_pq_object_read_prop(zend_object *object, zend_string *member, int type, void **cache_slot, zval *tmp);
+extern zval *php_pq_object_write_prop(zend_object *object, zend_string *member, zval *value, void **cache_slot);
+extern zval *php_pq_object_get_prop_ptr_null(zend_object *object, zend_string *member, int type, void **cache_slot);
 #else
-# define php_pq_object_debug_info php_pq_object_debug_info_70
+extern HashTable *php_pq_object_debug_info(zval *object, int *temp);
+extern HashTable *php_pq_object_properties(zval *object);
+extern HashTable *php_pq_object_get_gc(zval *object, zval **table, int *n);
+extern zval *php_pq_object_read_prop(zval *object, zval *member, int type, void **cache_slot, zval *tmp);
+# if PHP_VERSION_ID >= 70400
+extern zval *php_pq_object_write_prop(zval *object, zval *member, zval *value, void **cache_slot);
+# else
+extern void php_pq_object_write_prop(zval *object, zval *member, zval *value, void **cache_slot);
+# endif
+extern zval *php_pq_object_get_prop_ptr_null(zval *object, zval *member, int type, void **cache_slot);
 #endif
-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
-#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_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
 
index da07ff339a7e1b89dfe9d9f97be983a897e2e592..fd5ec64b8f60084e2010836188ffcca484a1f666 100644 (file)
@@ -515,9 +515,9 @@ static ZEND_RESULT_CODE php_pqconn_update_socket(zval *zobj, php_pqconn_object_t
                retval = FAILURE;
        }
 #if PHP_VERSION_ID >= 80000
-       zend_get_std_object_handlers()->write_property(Z_OBJ_P(zobj), Z_STR(zmember), &zsocket, NULL);
+       zend_std_write_property(Z_OBJ_P(zobj), Z_STR(zmember), &zsocket, NULL);
 #else
-       zend_get_std_object_handlers()->write_property(zobj, &zmember, &zsocket, NULL);
+       zend_std_write_property(zobj, &zmember, &zsocket, NULL);
 #endif
        zval_ptr_dtor(&zsocket);
        zval_ptr_dtor(&zmember);
index f183337c361de0cf04fad89eb61f6f86f615368e..0c1fc288242ffc88bec2f1d815e649b756bfb861 100644 (file)
@@ -202,10 +202,10 @@ static void php_pqlob_object_update_stream(php_pqlob_object_t *obj, zval *zstrea
        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);
+       zend_std_write_property(&obj->zo, Z_STR(zmember), zstream, NULL);
 #else
        ZVAL_OBJ(&zobj, &obj->zo);
-       zend_get_std_object_handlers()->write_property(&zobj, &zmember, zstream, NULL);
+       zend_std_write_property(&zobj, &zmember, zstream, NULL);
 #endif
        zval_ptr_dtor(&zmember);
 }
index e9608efc8024b1fe5a6dc4c13f5bde97090a8f82..7e51271a5d8800badf9e7e1c88aae43b8d2eb73c 100644 (file)
@@ -383,12 +383,7 @@ static zend_object_iterator_funcs php_pqres_iterator_funcs = {
 #endif
 };
 
-#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)
+static inline ZEND_RESULT_CODE php_pqres_count_elements_ex(zend_object *object, long *count)
 {
        php_pqres_object_t *obj = PHP_PQ_OBJ(NULL, object);
 
@@ -399,10 +394,17 @@ static ZEND_RESULT_CODE php_pqres_count_elements_80(zend_object *object, long *c
                return SUCCESS;
        }
 }
-static ZEND_RESULT_CODE php_pqres_count_elements_70(zval *object, long *count)
+#if PHP_VERSION_ID >= 80000
+static ZEND_RESULT_CODE php_pqres_count_elements(zend_object *object, long *count)
+{
+       return php_pqres_count_elements_ex(object, count);
+}
+#else
+static ZEND_RESULT_CODE php_pqres_count_elements(zval *object, long *count)
 {
-       return php_pqres_count_elements_80(Z_OBJ_P(object), count);
+       return php_pqres_count_elements_ex(Z_OBJ_P(object), count);
 }
+#endif
 
 ZEND_RESULT_CODE php_pqres_success(PGresult *res)
 {
@@ -1157,7 +1159,7 @@ static PHP_METHOD(pqres, count) {
        if (SUCCESS == rv) {
                long count;
 
-               if (SUCCESS != php_pqres_count_elements_70(getThis(), &count)) {
+               if (SUCCESS != php_pqres_count_elements_ex(Z_OBJ_P(getThis()), &count)) {
                        throw_exce(EX_UNINITIALIZED, "pq\\Result not initialized");
                } else {
                        RETVAL_LONG(count);
@@ -1191,6 +1193,7 @@ static PHP_METHOD(pqres, desc) {
        }
 }
 
+#if PHP_VERSION_ID >= 80000
 ZEND_BEGIN_ARG_INFO_EX(ai_pqres_getIterator, 0, 0, 0)
 ZEND_END_ARG_INFO();
 static PHP_METHOD(pqres, getIterator)
@@ -1212,6 +1215,7 @@ static PHP_METHOD(pqres, getIterator)
                }
        }
 }
+#endif
 
 static zend_function_entry php_pqres_methods[] = {
        PHP_ME(pqres, bind, ai_pqres_bind, ZEND_ACC_PUBLIC)
@@ -1223,7 +1227,9 @@ static zend_function_entry php_pqres_methods[] = {
        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)
+#if PHP_VERSION_ID >= 80000
        PHP_ME(pqres, getIterator, ai_pqres_getIterator, ZEND_ACC_PUBLIC)
+#endif
        {0}
 };
 
@@ -1242,7 +1248,11 @@ PHP_MINIT_FUNCTION(pqres)
        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;
+#if PHP_VERSION_ID >= 80000
        zend_class_implements(php_pqres_class_entry, 2, zend_ce_aggregate, spl_ce_Countable);
+#else
+       zend_class_implements(php_pqres_class_entry, 2, zend_ce_traversable, spl_ce_Countable);
+#endif
 
        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);
index 01e4e321b3604fec460a914bdc713511632beab0..b1f36cf27e5fb2aa4b6bb2b62c81e7455f26981a 100644 (file)
@@ -69,7 +69,7 @@ static void php_pqtypes_object_gc_connection(void *o, zval *return_value)
        add_next_index_zval(return_value, &zconn);
 }
 
-static int has_dimension(HashTable *ht, zval *member, zend_string **key, zend_long *index)
+static inline int has_dimension(HashTable *ht, zval *member, zend_string **key, zend_long *index)
 {
        if (Z_TYPE_P(member) == IS_LONG) {
                *index = Z_LVAL_P(member);
@@ -94,12 +94,7 @@ static int has_dimension(HashTable *ht, zval *member, zend_string **key, zend_lo
        }
 }
 
-#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)
+static inline int php_pqtypes_object_has_dimension_ex(zend_object *object, zval *member, int check_empty)
 {
        php_pqtypes_object_t *obj = PHP_PQ_OBJ(NULL, object);
        zend_string *key = NULL;
@@ -128,17 +123,19 @@ static int php_pqtypes_object_has_dimension_80(zend_object *object, zval *member
 
        return 0;
 }
-static int php_pqtypes_object_has_dimension_70(zval *object, zval *member, int check_empty)
+#if PHP_VERSION_ID >= 80000
+static int php_pqtypes_object_has_dimension(zend_object *object, zval *member, int check_empty)
 {
-       return php_pqtypes_object_has_dimension_80(Z_OBJ_P(object), member, check_empty);
+       return php_pqtypes_object_has_dimension_ex(object, member, check_empty);
 }
-
-#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
+static int php_pqtypes_object_has_dimension(zval *object, zval *member, int check_empty)
+{
+       return php_pqtypes_object_has_dimension_ex(Z_OBJ_P(object), member, check_empty);
+}
 #endif
-static zval *php_pqtypes_object_read_dimension_80(zend_object *object, zval *member, int type, zval *rv)
+
+static inline zval *php_pqtypes_object_read_dimension_ex(zend_object *object, zval *member, int type, zval *rv)
 {
        php_pqtypes_object_t *obj = PHP_PQ_OBJ(NULL, object);
        zend_string *key = NULL;
@@ -156,38 +153,41 @@ static zval *php_pqtypes_object_read_dimension_80(zend_object *object, zval *mem
 
        return data;
 }
-static zval *php_pqtypes_object_read_dimension_70(zval *object, zval *member, int type, zval *rv)
+#if PHP_VERSION_ID >= 80000
+static zval *php_pqtypes_object_read_dimension(zend_object *object, zval *member, int type, zval *rv)
 {
-       return php_pqtypes_object_read_dimension_80(Z_OBJ_P(object), member, type, rv);
+       return php_pqtypes_object_read_dimension_ex(object, member, type, rv);
 }
-
-#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
+static zval *php_pqtypes_object_read_dimension(zval *object, zval *member, int type, zval *rv)
+{
+       return php_pqtypes_object_read_dimension_ex(Z_OBJ_P(object), member, type, rv);
+}
 #endif
-static void php_pqtypes_object_write_dimension_80(zend_object *object, zval *offset, zval *value)
+
+#if PHP_VERSION_ID >= 80000
+static void php_pqtypes_object_write_dimension(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)
+#else
+static void php_pqtypes_object_write_dimension(zval *object, zval *offset, zval *value)
 {
        throw_exce(EX_RUNTIME, "pq\\Types object must not be modified");
 }
+#endif
 
 #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)
+static void php_pqtypes_object_unset_dimension(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)
+#else
+static void php_pqtypes_object_unset_dimension(zval *object, zval *offset)
 {
        throw_exce(EX_RUNTIME, "pq\\Types object must not be modified");
 }
+#endif
 
 ZEND_BEGIN_ARG_INFO_EX(ai_pqtypes_construct, 0, 0, 1)
        ZEND_ARG_OBJ_INFO(0, connection, pq\\Connection, 0)