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.

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

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to