Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:10237 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 53517 invoked by uid 1010); 2 Jun 2004 00:35:06 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 53460 invoked from network); 2 Jun 2004 00:35:06 -0000 Received: from unknown (HELO mta205-rme.xtra.co.nz) (210.86.15.187) by pb1.pair.com with SMTP; 2 Jun 2004 00:35:06 -0000 Received: from web3-rme.xtra.co.nz ([210.86.15.143]) by mta205-rme.xtra.co.nz with ESMTP id <20040602003504.JDOE29515.mta205-rme.xtra.co.nz@web3-rme.xtra.co.nz> for ; Wed, 2 Jun 2004 12:35:04 +1200 Received: from galaxy ([219.89.128.128]) by web3-rme.xtra.co.nz with ESMTP id <20040602003503.GQQN3371.web3-rme.xtra.co.nz@galaxy> for ; Wed, 2 Jun 2004 12:35:03 +1200 Message-ID: <00b001c44839$a52f4210$0a00a8c0@home.jevon.org> To: References: <20040601131122.36657.qmail@pb1.pair.com> <40BCF985.26931.1418D27@localhost> <40BD1706.1010202@velum.net> <1086135985.2774.4.camel@localhost> Date: Wed, 2 Jun 2004 12:36:26 +1200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 Subject: Re: [PHP-DEV] Use of 'self' in static function in subclass From: jevon@jevon.org ("Jevon Wright") It's something I noticed, too. Consider this: class A { function a() { return $this::b(); } function b() { return 1; } } class B extends A { function b() { return 2; } } If I call $b = new B(); echo $b->a(); No matter what combination of this, self, parent, ... - I could never get B's property. I was led to believe that this is actually normal for OO designs (is it? If so, ignore me). But it would be awesome if self or $this (ONLY one of them, if they currently perform the same function) actually referred to the top class - ie. B::b() in this case. Is this what this suggestion would suggest? Thanks, Jevon ----- Original Message ----- From: "Adam Bregenzer" To: "Hans Lellelid" Cc: "Ferdinand Beyer" ; "Timm Friebe" ; Sent: Wednesday, June 02, 2004 12:26 PM Subject: Re: [PHP-DEV] Use of 'self' in static function in subclass > On Tue, 2004-06-01 at 19:53, Hans Lellelid wrote: > > Yeah +1 on self:: binding at runtime. I can't really imagine a case > > where you would want to refer to 'self' as the class that contains the > > method *and not* the overridden method in invoked class (if it exists). > > Binding this at runtime will introduce many new design possibilities > > with static classes and will also make self:: consistent with $this-> > > behavior for objects. > > +1, I agree completely. I think it is critical to have a way to be able > to have a static method call another static method in the same class > that respects inheritance. If a developer wanted a call to not respect > inheritance the class's name can be used instead of self with the same > results (increased code maintenance should the class name change > notwithstanding). > > -- > Adam Bregenzer > adam@bregenzer.net > http://adam.bregenzer.net/ > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >