Hi,
I'd like to fix the resolution order of Countable::count() vs
count_elements handler.
Currently, things are done like this:
- check if the object implements countable, if so, call it's method
- 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 :
- it is inconsistent with other handlers
- it makes it impossible to be userland friendly while saving a
method call when it's possible.
Currently, there are 3 possibilities:
-
the internal class doesn't use count_elements handler
-> No problem with the change -
the internal class uses only the handler
-> It's not userland friendly, the change won't help, so it needs to
be fixed anyway -
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
Hello Etienne,
Wednesday, July 2, 2008, 1:57:06 PM, you wrote:
Hi,
I'd like to fix the resolution order of Countable::count() vs
count_elements handler.
Currently, things are done like this:
- check if the object implements countable, if so, call it's method
- 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 :
- it is inconsistent with other handlers
- it makes it impossible to be userland friendly while saving a
method call when it's possible.
Sounds good to me and while you're at it. You can get rid of HAVE_SPL
checks as SPL is always present now.
Currently, there are 3 possibilities:
- the internal class doesn't use count_elements handler
->> No problem with the change
- the internal class uses only the handler
->> It's not userland friendly, the change won't help, so it needs to
be fixed anyway
- 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.
Sounds like the interface_gets_implemented handler of the interface should
check that the count_elements handler is not set or is already set to the
same value anyway and throw an exception/issue an error otherwise.
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
Best regards,
Marcus