Here is an example from Java. It uses the default methods of Java 8 and getClass() . I bet it works with classes too:
interface A { default String name() { return getClass().getName(); } } class B implements A {} public class LateBinding { public static void main(String[] args) {
Results:
$ javac LateBinding.java && java LateBinding LateBinding$1 B
As you can see, this method knows in both cases when it works, although it is defined in A This example is not static because you cannot call getClass() statically, but LSB in PHP is not really limited to static contexts.
Dmitry Minkovsky
source share