Index: array.c =================================================================== RCS file: /repository/php-src/ext/standard/array.c,v retrieving revision 1.291 diff -u -p -d -r1.291 array.c --- array.c 18 Feb 2005 13:37:23 -0000 1.291 +++ array.c 21 Feb 2005 22:45:45 -0000 @@ -319,6 +319,10 @@ PHP_FUNCTION(count) RETURN_LONG (php_count_recursive (array, mode TSRMLS_CC)); break; case IS_OBJECT: { + HashTable *properties; + HashPosition pos; + zval **value; + long prop_count = 0; #if HAVE_SPL /* it the object implements Countable we call its count() method */ zval *retval; @@ -337,6 +341,20 @@ PHP_FUNCTION(count) return; } } + else { + if (Z_OBJ_HT(*array)->get_properties == NULL) { + RETURN_FALSE; + } + + properties = Z_OBJ_HT(*array)->get_properties(array TSRMLS_CC); + zend_hash_internal_pointer_reset_ex(properties, &pos); + + while (zend_hash_get_current_data_ex(properties, (void **) &value, &pos) == SUCCESS) { + prop_count++; + zend_hash_move_forward_ex(properties, &pos); + } + RETURN_LONG(prop_count); + } } default: RETURN_LONG(1);