Re: Bug Wrong resolution of "Late Static Binding" after self::method()

From: Date: Mon, 09 Mar 2020 18:49:38 +0000
Subject: Re: Bug Wrong resolution of "Late Static Binding" after self::method()
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-108915@lists.php.net to get a copy of this message
Thank you all for explaining. This helps a lot! Marc On 09.03.20 10:27, Rowan Tommins wrote:
On Mon, 9 Mar 2020 at 05:38, Marc <marc@mabe.berlin> wrote:
Does it make sense? -> I have read "self::" all time as a shortcut for "MyClass::" until I noticed this is not the case and I expect most PHP devs would explain it this way. Is there a reason why self:: doesn't reset the internal "static" reference?
A reasonably intuitive parallel that occurred to me is that $this is also maintained through self:: calls (as long as they're not to a method declared static). So if you replace the static:: call in my previous example with a $this-> call, you get the same result: # https://3v4l.org/deRcD class A {
     function call() {
         self::method1();
     }
     function method1() {
         $this->method2();
     }
     function method2() {
         echo 'Base definition';
     }
} class B extends A {
     function method2() {
         echo 'Override';
     }
} (new B)->call(); # echoes 'Override' Regards,


« previous php.internals (#108915) next »