type converters
[m6w6/ext-pq] / src / php_pq_object.c
index 78db20f2c56d04be1f55d08a3ac1c73965ef197e..e6640def71a3dc97422bc7d5403995c75eb94644 100644 (file)
@@ -70,7 +70,7 @@ static int apply_pi_to_ht(void *p TSRMLS_DC, int argc, va_list argv, zend_hash_k
        if (addref) {
                Z_ADDREF_P(property);
        }
-       zend_hash_add(ht, pi->name, pi->name_length + 1, (void *) &property, sizeof(zval *), NULL);
+       zend_hash_update(ht, pi->name, pi->name_length + 1, (void *) &property, sizeof(zval *), NULL);
 
        return ZEND_HASH_APPLY_KEEP;
 }
@@ -89,6 +89,16 @@ HashTable *php_pq_object_debug_info(zval *object, int *temp TSRMLS_DC)
        return ht;
 }
 
+HashTable *php_pq_object_properties(zval *object TSRMLS_DC)
+{
+       HashTable *ht = zend_get_std_object_handlers()->get_properties(object TSRMLS_CC);
+       php_pq_object_t *obj = zend_object_store_get_object(object TSRMLS_CC);
+
+       zend_hash_apply_with_arguments(&obj->zo.ce->properties_info TSRMLS_CC, apply_pi_to_ht, 4, ht, object, obj, 1);
+
+       return ht;
+}
+
 zend_class_entry *ancestor(zend_class_entry *ce)
 {
        while (ce->parent) {
@@ -101,7 +111,7 @@ zval *php_pq_object_read_prop(zval *object, zval *member, int type, const zend_l
 {
        php_pq_object_t *obj = zend_object_store_get_object(object TSRMLS_CC);
        php_pq_object_prophandler_t *handler;
-       zval *return_value;
+       zval *return_value = NULL;
 
        if (!obj->intern) {
                zend_error(E_WARNING, "%s not initialized", ancestor(obj->zo.ce)->name);
@@ -114,7 +124,6 @@ zval *php_pq_object_read_prop(zval *object, zval *member, int type, const zend_l
                        handler->read(object, obj, return_value TSRMLS_CC);
                } else {
                        zend_error(E_ERROR, "Cannot access %s properties by reference or array key/index", ancestor(obj->zo.ce)->name);
-                       return_value = NULL;
                }
        } else {
                return_value = zend_get_std_object_handlers()->read_property(object, member, type, key TSRMLS_CC);