fork download
  1. <?php
  2.  
  3. class Foo
  4. {
  5. function test(int $a, int $b)
  6. {
  7. echo $a + $b;
  8. echo PHP_EOL;
  9. }
  10.  
  11. function test2(int $a, $b)
  12. {
  13. echo $a + $b;
  14. echo PHP_EOL;
  15. }
  16.  
  17. function test3(int $a, int $b = null)
  18. {
  19. echo $a + $b;
  20. echo PHP_EOL;
  21. }
  22. }
  23.  
  24. $foo = new Foo;
  25. $a = 1;
  26. $b = 2;
  27. $foo->test($a, $b);
  28.  
  29.  
Runtime error #stdin #stdout 0.02s 13064KB
stdin
Standard input is empty
stdout
Catchable fatal error: Argument 1 passed to Foo::test() must be an instance of int, integer given, called in /home/3AGXqc/prog.php on line 27 and defined in /home/3AGXqc/prog.php on line 5