Hi,

I have reported a bug in Mai 2019 but did not get any response here https://bugs.php.net/bug.php?id=77985.


The problem is that "static::class" as well as "get_called_class()" used within a method resolves to a different class if this method was called with "self::method". Interestingly it works as expected if the method got called with "ClassName::method".


I send it here because fixing this could result in a hard to find BC break and it could be a good idea to handle this in 8.0.


https://3v4l.org/NSdB8

class A {
    static function call() {
        self::method();

        $self = self::class;
        $self::method();
    }
    static function method() { echo static::class; }
}

class B extends A {}

B::call(); // displays "BA" instead of "AA"


In case this is "Not a Bug" please explain to me why the result of "self::method()" is different then "$self = self::class; $self::method();".


Thanks,

Marc

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

Reply via email to