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

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

Reply via email to