Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:33439 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 10521 invoked by uid 1010); 26 Nov 2007 13:11:42 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 10506 invoked from network); 26 Nov 2007 13:11:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Nov 2007 13:11:42 -0000 X-Host-Fingerprint: 24.247.219.180 24-247-219-180.dhcp.cdwr.mi.charter.com Received: from [24.247.219.180] ([24.247.219.180:13886] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F8/01-01739-C06CA474 for ; Mon, 26 Nov 2007 08:11:41 -0500 Message-ID: To: internals@lists.php.net Date: Mon, 26 Nov 2007 08:08:30 -0500 User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 References: <4740C654.3020302@digitalsandwich.com> <47417C65.8010708@iamjochem.com> <474130B3.9070303@digitalsandwich.com> <4741DC81.6000506@zend.com> <4741D574.2020800@digitalsandwich.com> <474247A2.5050301@zend.com> <4741D9D1.6030106@digitalsandwich.com> <47424B4F.2@zend.com> <4743CED7.5050402@avalon.aut.bme.hu> <4749F328.8080506@digitalsandwich.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 24.247.219.180 Subject: Re: [PHP-DEV] [PATCH] late binding for parent (and other options) - Was Re: [PHP-DEV] late static binding php6 From: emsmith@elizabethmariesmith.com (Elizabeth Smith) Alexey Zakhlestin wrote: > On 11/26/07, Mike Lively wrote: >> I have come up with three different patches that allow us to work around >> the issue of parent:: being considered an 'explicit class reference' and >> thus disallowing static:: to effectively used. >> >> The patches are against 5.3. I also have patches against HEAD but I was >> having problems getting run-tests.php to run against that code base (it >> would hang on the first test no matter which set of tests I ws running.) >> >> All three patches have different levels of intrusiveness to the engine >> and all three patches have been tested against (and pass) the existing >> lsb tests in Zend/tests/lsb_*.phpt >> >> 1.) lsb.parent-forwarding.patch >> This patch modifies the behavior of only parent:: to not change >> EG(called_class) to the parent of the current scope. With this change. >> >> > >> class A { >> public static function test() { >> echo get_called_class()."\n"; >> } >> } >> >> class B extends A { >> public static function test() { >> parent::test(); >> } >> } >> >> A::test(); >> B::test(); >> >> ?> >> will output: >> A >> B >> >> It should be noticed that with this patch parent:: will always resolve >> to the parent of the current scope, it will just not make any changes to >> the called_scope (effectively) > > I believe this first patch is the proper way to go. It feels > "natural", "intuitive", etc. > I also think this is the proper way to handle parent:: in a static context - I shudder to think of the number of "bogus" bug reports that'll pop up if lsb DOESN'T work this way. People using a parent:: call in a class don't think of it as static, they think of it as call the class that this one extends, where as a explicit Class::method(); call means "call this static method", so they expect them to work differently.