Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:10202 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 34427 invoked by uid 1010); 1 Jun 2004 13:43:06 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 34349 invoked from network); 1 Jun 2004 13:43:05 -0000 Received: from unknown (HELO dydimus.dreamhost.com) (66.33.197.17) by pb1.pair.com with SMTP; 1 Jun 2004 13:43:05 -0000 Received: from [192.168.0.152] (mail.appliedsec.com [69.17.65.231]) by dydimus.dreamhost.com (Postfix) with ESMTP id AF6C84F88D; Tue, 1 Jun 2004 06:43:04 -0700 (PDT) Message-ID: <40BC87E6.9090102@velum.net> Date: Tue, 01 Jun 2004 09:43:02 -0400 User-Agent: Mozilla Thunderbird 0.6 (Windows/20040502) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Bert Slagter Cc: internals@lists.php.net References: <20040601131122.36657.qmail@pb1.pair.com> In-Reply-To: <20040601131122.36657.qmail@pb1.pair.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: Use of 'self' in static function in subclass From: hans@velum.net (Hans Lellelid) Bert Slagter wrote: > Hi All, > > I have a class and a subclass, both with a static method: > > class Foo > { > static function Bar() > { > self::Baz(); > } > } > > class Foo2 extends Foo > { > static function Baz() > { > echo 'Baz'; > } > } > > Foo2::Bar(); > ?> > > In this case I expect to find 'Baz' on my screen, but I get the > following: "Fatal error: Call to undefined method Foo::baz() in > d:\htdocs_php5\ProBase2\TRUNK\probase\libsys\test5.php on line 7". > > This is in PHP5 RC2. > > 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. Yeah, this probably should change to be consistent. I've been living fine with the current behavior, but considering self::*() will automatically invoke the parent class' method if none is defined in current class, then it should probably also work the other way around. My .02, Hans