fork(4) download
  1. <?php
  2.  
  3. abstract class A {
  4.  
  5. public function response($a, $b) {
  6. var_dump('A');
  7. return $a+$b;
  8. }
  9. }
  10.  
  11. trait B {
  12. public function response($a) {
  13. var_dump('B');
  14. return $a;
  15. }
  16. }
  17.  
  18. class C extends A {
  19. use B {
  20. response as response2;
  21. }
  22. }
  23.  
  24. $c = new C();
  25. var_dump($c->response(1, 2));
  26. var_dump($c->response2(1));
  27.  
Success #stdin #stdout #stderr 0.02s 23412KB
stdin
Standard input is empty
stdout
string(1) "B"
int(1)
string(1) "B"
int(1)
stderr
PHP Warning:  Declaration of B::response($a) should be compatible with A::response($a, $b) in /home/5CrFOY/prog.php on line 18