Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:10230 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 80307 invoked by uid 1010); 1 Jun 2004 19:18:45 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 80281 invoked from network); 1 Jun 2004 19:18:45 -0000 Received: from unknown (HELO moutng.kundenserver.de) (212.227.126.188) by pb1.pair.com with SMTP; 1 Jun 2004 19:18:45 -0000 Received: from [212.227.126.155] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 1BVEma-0006iW-00 for internals@lists.php.net; Tue, 01 Jun 2004 21:18:44 +0200 Received: from [80.139.17.172] (helo=[80.139.17.172]) by mrelayng.kundenserver.de with asmtp (Exim 3.35 #1) id 1BVEmZ-0006ss-00 for internals@lists.php.net; Tue, 01 Jun 2004 21:18:44 +0200 To: internals@lists.php.net In-Reply-To: <20040601131122.36657.qmail@pb1.pair.com> References: <20040601131122.36657.qmail@pb1.pair.com> Content-Type: text/plain Message-ID: <1086117233.281.15.camel@localhost> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Tue, 01 Jun 2004 21:13:54 +0200 Content-Transfer-Encoding: 7bit X-Provags-ID: kundenserver.de abuse@kundenserver.de auth:e958292ea7b1c44e51b2b9ca0a9da460 Subject: Re: [PHP-DEV] Use of 'self' in static function in subclass From: thekid@thekid.de (Timm Friebe) On Tue, 2004-06-01 at 15:11, Bert Slagter wrote: > Hi All, > > I have a class and a subclass, both with a static method: [...] > Somehow this behaviour seems logical, on the other hand I don't think > it's desired. I think that 'self' should point to the current class, > even if the static method resides in a parent class. > > Is this 'self'-behaviour intended? Yes: self is bound at compiletime. It would need to be changed to evaluation at runtime und would be far more useful then. This has been reported a couple of times, in slight variations: http://zend.com/lists/engine2/200307/msg00033.html http://zend.com/lists/engine2/200307/msg00036.html http://zend.com/lists/engine2/200309/msg00024.html In one of these, Marcus suggested a new keyword "this" which would behave like a run-time self, e.g: class Test { public static function getInstance() { return new this(); } } class Foo extends Test { } var_dump(Foo::getInstance()); would output "object(foo)" instead of "object(test)". I wouldn't mind chaning self in the first place, though. - Timm