@@ -162,6 +162,33 @@ static HashTable* php_phongo_std_get_gc(zend_object* object, zval** table, int*
162
162
return object -> handlers -> get_properties (object );
163
163
}
164
164
165
+ static zval * php_phongo_read_property (zend_object * object , zend_string * member , int type , void * * cache_slot , zval * rv )
166
+ {
167
+ return zend_hash_find (object -> handlers -> get_properties (object ), member );
168
+ }
169
+
170
+ static zval * php_phongo_write_property (zend_object * zobj , zend_string * name , zval * value , void * * cache_slot )
171
+ {
172
+ return zend_hash_add_new (zobj -> handlers -> get_properties (zobj ), name , value );
173
+ }
174
+ static int php_phongo_has_property (zend_object * zobj , zend_string * name , int has_set_exists , void * * cache_slot )
175
+ {
176
+ zval * value = zend_hash_find (zobj -> handlers -> get_properties (zobj ), name );
177
+ if (value ) {
178
+ if (has_set_exists == ZEND_PROPERTY_NOT_EMPTY ) {
179
+ return zend_is_true (value );
180
+ }
181
+ if (has_set_exists < ZEND_PROPERTY_NOT_EMPTY ) {
182
+ ZEND_ASSERT (has_set_exists == ZEND_PROPERTY_ISSET );
183
+ ZVAL_DEREF (value );
184
+ return (Z_TYPE_P (value ) != IS_NULL );
185
+ }
186
+ ZEND_ASSERT (has_set_exists == ZEND_PROPERTY_EXISTS );
187
+ return true;
188
+ }
189
+ return false;
190
+ }
191
+
165
192
PHP_MINIT_FUNCTION (mongodb ) /* {{{ */
166
193
{
167
194
bson_mem_vtable_t bson_mem_vtable = {
@@ -200,6 +227,9 @@ PHP_MINIT_FUNCTION(mongodb) /* {{{ */
200
227
/* Ensure that get_gc delegates to zend_std_get_properties directly in case
201
228
* our class defines a get_properties handler for debugging purposes. */
202
229
phongo_std_object_handlers .get_gc = php_phongo_std_get_gc ;
230
+ phongo_std_object_handlers .read_property = php_phongo_read_property ;
231
+ phongo_std_object_handlers .write_property = php_phongo_write_property ;
232
+ phongo_std_object_handlers .has_property = php_phongo_has_property ;
203
233
204
234
/* Initialize zend_class_entry dependencies.
205
235
*
0 commit comments