bug38047.phpt 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. --TEST--
  2. Bug #38047 ("file" and "line" sometimes not set in backtrace from inside error handler)
  3. --FILE--
  4. <?php
  5. error_reporting(E_ALL);
  6. set_error_handler('kalus_error_handler');
  7. ini_set("display_errors", "on");
  8. class A {
  9. function A_ftk($a) {
  10. }
  11. }
  12. function kalus_error_handler($error_code, $error_string, $filename, $line, $symbols) {
  13. echo "$error_string\n";
  14. get_error_context();
  15. }
  16. function get_error_context() {
  17. $backtrace = debug_backtrace();
  18. $n = 1;
  19. foreach ($backtrace as $call) {
  20. echo $n++." ";
  21. if (isset($call["file"])) {
  22. echo $call["file"];
  23. if (isset($call["line"])) {
  24. echo ":".$call["line"];
  25. }
  26. }
  27. if (isset($call["function"])) {
  28. echo " ".$call["function"]."()";
  29. }
  30. echo "\n";
  31. }
  32. echo "\n";
  33. }
  34. //This will not create file and line items for the call into the error handler
  35. $page["name"] = A::A_ftk();
  36. ?>
  37. --EXPECTF--
  38. Non-static method A::A_ftk() should not be called statically
  39. 1 %sbug38047.php:13 get_error_context()
  40. 2 %sbug38047.php:36 kalus_error_handler()
  41. Fatal error: Uncaught ArgumentCountError: Too few arguments to function A::A_ftk(), 0 passed in %sbug38047.php on line 36 and exactly 1 expected in %sbug38047.php:7
  42. Stack trace:
  43. #0 %sbug38047.php(36): A::A_ftk()
  44. #1 {main}
  45. thrown in %sbug38047.php on line 7