Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:38788 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 34193 invoked from network); 6 Jul 2008 11:01:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Jul 2008 11:01:39 -0000 Authentication-Results: pb1.pair.com smtp.mail=helly@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=helly@php.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 85.214.94.56 as permitted sender) X-PHP-List-Original-Sender: helly@php.net X-Host-Fingerprint: 85.214.94.56 aixcept.net Linux 2.6 Received: from [85.214.94.56] ([85.214.94.56:40908] helo=h1149922.serverkompetenz.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 74/25-03792-216A0784 for ; Sun, 06 Jul 2008 07:01:39 -0400 Received: from MBOERGER-ZRH.corp.google.com (59-123.106-92.cust.bluewin.ch [92.106.123.59]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by h1149922.serverkompetenz.net (Postfix) with ESMTP id EA55A11F10B; Sun, 6 Jul 2008 13:01:35 +0200 (CEST) Date: Sun, 6 Jul 2008 13:01:14 +0200 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <915668038.20080706130114@marcus-boerger.de> To: "Etienne Kneuss" CC: "PHP internals" In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] [RFC] Modify resolution order of count_elements handler From: helly@php.net (Marcus Boerger) 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: > 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. 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: > 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. 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