Re: Use of 'self' in static function in subclass

From: Date: Thu, 03 Jun 2004 08:01:15 +0000
Subject: Re: Use of 'self' in static function in subclass
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-10255@lists.php.net to get a copy of this message
I don't agree as I don't think static methods should be virtual. This is what $this-> exists for. Re-design...! Andi At 03:11 PM 6/1/2004 +0200, Bert Slagter wrote:
Hi All, I have a class and a subclass, both with a static method: <?php 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. Is this 'self'-behaviour intended? Bert -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.internals (#10255) next »