fork(2) download
  1. <?php
  2. trait A {
  3. public function smallTalk() {
  4. echo 'a';
  5. }
  6. public function bigTalk() {
  7. echo 'A';
  8. }
  9. }
  10.  
  11. trait B {
  12. public function smallTalk() {
  13. echo 'b';
  14. }
  15. public function bigTalk() {
  16. echo 'B';
  17. }
  18. }
  19.  
  20. class Talker {
  21. use A, B {
  22. B::smallTalk insteadof A;
  23. A::bigTalk insteadof B;
  24. }
  25. }
  26.  
  27. class Aliased_Talker {
  28. use A, B {
  29. B::smallTalk insteadof A;
  30. A::bigTalk insteadof B;
  31. B::bigTalk as talk;
  32. }
  33. }
  34.  
  35. $obj = new Aliased_Talker();
  36. echo $obj->smallTalk();
  37. echo $obj->bigTalk();
  38. echo $obj->talk();
Success #stdin #stdout 0s 52488KB
stdin
Standard input is empty
stdout
bAB