Marcus,
I didn't see discussion about this. How much is such a countable interface really needed? Is this only for SPL or is this supposed to be general purpose. I would prefer to only see it in SPL but I see you made some changes to array.c. This might lead to inconsistency with the rest of PHP where this interface works in some situations and not others.
If you see this being similar to __get, __sleep and friends then maybe the method which has to be implemented should be __count?
Anyway, what do you think? Can we keep this SPL only? (I apologize for being so late on my emails but I'm catching up now).
Andi
At 09:06 PM 11/1/2004 +0000, Marcus Boerger wrote:
helly Mon Nov 1 16:06:42 2004 EDT
Modified files: /php-src/ext/standard array.c Log: - Add some comment
http://cvs.php.net/diff.php/php-src/ext/standard/array.c?r1=1.280&r2=1.281&ty=u Index: php-src/ext/standard/array.c diff -u php-src/ext/standard/array.c:1.280 php-src/ext/standard/array.c:1.281 --- php-src/ext/standard/array.c:1.280 Mon Nov 1 15:57:22 2004 +++ php-src/ext/standard/array.c Mon Nov 1 16:06:42 2004 @@ -21,7 +21,7 @@ +----------------------------------------------------------------------+ */
-/* $Id: array.c,v 1.280 2004/11/01 20:57:22 helly Exp $ */ +/* $Id: array.c,v 1.281 2004/11/01 21:06:42 helly Exp $ */
#include "php.h"
#include "php_ini.h"
@@ -326,6 +326,7 @@
break;
case IS_OBJECT: {
#if HAVE_SPL
+ /* it the object implements Countable we call its count() method */
zval *retval;
if (instanceof_function(Z_OBJCE_P(array), spl_ce_Countable TSRMLS_CC)) {
@@ -335,6 +336,7 @@
return;
}
#endif
+ /* if not we return the number of properties (not taking visibility into account) */
if (Z_OBJ_HT(*array)->count_elements) {
RETVAL_LONG(1);
if (SUCCESS == Z_OBJ_HT(*array)->count_elements(array, &Z_LVAL_P(return_value) TSRMLS_CC)) {
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php