fork download
  1. <?php
  2. function m(Bar $x) {
  3. $x->m('Error Processing Request');
  4. }
  5. class Bar {
  6. public function m($message) {
  7. echo "Bar\n";
  8. var_dump($message);
  9. }
  10. }
  11. class Foo extends Bar {
  12. public function m($message, $code, $timer) {
  13. var_dump($code, $timer);
  14. echo "Foo\n";
  15. parent::m($message);
  16. }
  17. }
  18. m(new Foo);
  19.  
  20. //https://pt.stackoverflow.com/q/174414/101
Runtime error #stdin #stdout #stderr 0.02s 24492KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Warning:  Declaration of Foo::m($message, $code, $timer) should be compatible with Bar::m($message) in /home/QNop1T/prog.php on line 17
PHP Fatal error:  Uncaught ArgumentCountError: Too few arguments to function Foo::m(), 1 passed in /home/QNop1T/prog.php on line 3 and exactly 3 expected in /home/QNop1T/prog.php:12
Stack trace:
#0 /home/QNop1T/prog.php(3): Foo->m('Error Processin...')
#1 /home/QNop1T/prog.php(18): m(Object(Foo))
#2 {main}
  thrown in /home/QNop1T/prog.php on line 12