[RFC] Modify resolution order of count_elements handler
| From: | Etienne Kneuss | Date: | Wed, 02 Jul 2008 11:57:06 +0000 |
| Subject: | [RFC] Modify resolution order of count_elements handler | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-38701@lists.php.net to get a copy of this message | ||
Hi,
I'd like to fix the resolution order of Countable::count() vs
count_elements handler.
Currently, things are done like this:
1) check if the object implements countable, if so, call it's method
2) if not, check if count_elements handler is defined, if so, use it.
This is a problematic order of resolution, and I'd like to inverse it.
Why? Because :
1) it is inconsistent with other handlers
2) it makes it impossible to be userland friendly while saving a
method call when it's possible.
Currently, there are 3 possibilities:
1) the internal class doesn't use count_elements handler
-> No problem with the change
2) the internal class uses only the handler
-> It's not userland friendly, the change won't help, so it needs to
be fixed anyway
3) both the handler and the method are used
-> the handler was never called directly, such classes will need a fix
after that resolution order change.
Userland classes are not affected.
I can and will take care of every problems occuring in classes in
php-src (2 or 3, mostly SPL).
Patches and details:
http://wiki.php.net/rfc/array_count_handlers
Regards
--
Etienne Kneuss
http://www.colder.ch
Men never do evil so completely and cheerfully as
when they do it from a religious conviction.
-- Pascal