You simply implement the interface countable and then your objects can be put into count() to get the count function called. This is very helpful with ArrayObject/ArrayIterator which are array wrappers and thus they should work in count() as expected.
I don't completely agree because I can probably find many other places where this could theoretically have to work. So I'm not quite sure why count() is special (maybe because it's the most straightforward example). I mean it's not the end of the world but these kind of things tend to start at "let's just get count() to work" and then there are incremental patches to put PHP upside down to fix other places.
You never answered about the naming convention? I think in any case, it should be using the standard naming convention for such reserved function, as in __count().
Andi
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php