fork download
  1. <?php
  2.  
  3. namespace Example;
  4.  
  5. class Parent_ {
  6. public function whoAmI(): array
  7. {
  8. return [__CLASS__, self::class, static::class];
  9. }
  10. }
  11.  
  12. class Child extends Parent_ {}
  13.  
  14. $parent = new Parent_();
  15. $child = new Child();
  16.  
  17. var_dump($parent->whoAmI(), $child->whoAmI());
Success #stdin #stdout 0.02s 25936KB
stdin
Standard input is empty
stdout
array(3) {
  [0]=>
  string(15) "Example\Parent_"
  [1]=>
  string(15) "Example\Parent_"
  [2]=>
  string(15) "Example\Parent_"
}
array(3) {
  [0]=>
  string(15) "Example\Parent_"
  [1]=>
  string(15) "Example\Parent_"
  [2]=>
  string(13) "Example\Child"
}