Skip to content

Commit d056b25

Browse files
committed
Add count_elements handler for overloaded objects.
1 parent 5b5b10f commit d056b25

File tree

4 files changed

+8
-1
lines changed

4 files changed

+8
-1
lines changed

Zend/zend_iterators.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ static zend_object_handlers iterator_object_handlers = {
4444
NULL, /* get_ce */
4545
NULL, /* get class name */
4646
NULL, /* compare */
47-
NULL /* cast */
47+
NULL, /* cast */
48+
NULL /* count */
4849
};
4950

5051
ZEND_API void zend_register_iterator_wrapper(TSRMLS_D)

Zend/zend_object_handlers.c

+1
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,7 @@ ZEND_API zend_object_handlers std_object_handlers = {
972972
zend_std_object_get_class_name, /* get_class_name */
973973
zend_std_compare_objects, /* compare_objects */
974974
NULL, /* cast_object */
975+
NULL, /* count_elements */
975976
};
976977

977978
/*

Zend/zend_object_handlers.h

+4
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ typedef int (*zend_object_get_class_name_t)(zval *object, char **class_name, zen
9393
typedef int (*zend_object_compare_t)(zval *object1, zval *object2 TSRMLS_DC);
9494
typedef int (*zend_object_cast_t)(zval *readobj, zval *writeobj, int type, int should_free TSRMLS_DC);
9595

96+
/* updates *count to hold the number of elements present and returns SUCCESS.
97+
* Returns FAILURE if the object does not have any sense of overloaded dimensions */
98+
typedef int (*zend_object_count_elements_t)(zval *object, long *count TSRMLS_DC);
9699

97100
typedef struct _zend_object_handlers {
98101
/* general object functions */
@@ -119,6 +122,7 @@ typedef struct _zend_object_handlers {
119122
zend_object_get_class_name_t get_class_name;
120123
zend_object_compare_t compare_objects;
121124
zend_object_cast_t cast_object;
125+
zend_object_count_elements_t count_elements;
122126
} zend_object_handlers;
123127

124128
extern ZEND_API zend_object_handlers std_object_handlers;

Zend/zend_objects_API.c

+1
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ static zend_object_handlers zend_object_proxy_handlers = {
284284
NULL, /* get_class_name */
285285
NULL, /* compare_objects */
286286
NULL, /* cast_object */
287+
NULL, /* count_elements */
287288
};
288289

289290

0 commit comments

Comments
 (0)