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

From: Date: Mon, 09 Mar 2020 05:38:02 +0000
Subject: Re: Bug Wrong resolution of "Late Static Binding" after self::method()
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-108903@lists.php.net to get a copy of this message
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

« previous php.internals (#108903) next »