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

From: Date: Mon, 09 Mar 2020 08:14:39 +0000
Subject: Re: Bug Wrong resolution of "Late Static Binding" after self::method()
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-108904@lists.php.net to get a copy of this message
On Mon, Mar 9, 2020 at 6:38 AM Marc <marc@mabe.berlin> wrote: > Hi, > > > On 08.03.20 17:54, Matthew Brown wrote: > > This is expected behaviour given my understanding of how late static > binding works: > > > > If there is a chain of “self::” calls that ultimately ends in > “static::someMethod”, then PHP behaves as if every preceding call was a > call to “static::”, not “self::”. In your second call you’re explicitly > overriding that resolution by changing using (self::class)::someMethod, > which PHP always treats as A::someMethod, thus producing the expected > output. > > Thanks for explaining. > > I couldn't find any information for this behavior in the documentation - > Is that documented anywhere? > > 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? > > > Sorry for all these questions. > > Sometimes the world could be so simple until it turns out it isn't for > no reason. > > > Thanks, > > Marc > See https://wiki.php.net/rfc/lsb_parentself_forwarding, which is the RFC that added this behavior. Nikita

« previous php.internals (#108904) next »