xref: /PHP-7.2/Zend/tests/bug38047.phpt (revision 12ee17d5)
1--TEST--
2Bug #38047 ("file" and "line" sometimes not set in backtrace from inside error handler)
3--FILE--
4<?php
5error_reporting(E_ALL);
6set_error_handler('kalus_error_handler');
7ini_set("display_errors", "on");
8
9class A {
10  function A_ftk($a) {
11  }
12}
13
14function kalus_error_handler($error_code, $error_string, $filename, $line, $symbols) {
15  echo "$error_string\n";
16  get_error_context();
17}
18
19function get_error_context() {
20  $backtrace = debug_backtrace();
21  $n = 1;
22  foreach ($backtrace as $call) {
23  	echo $n++." ";
24  	if (isset($call["file"])) {
25  		echo $call["file"];
26  		if (isset($call["line"])) {
27  			echo ":".$call["line"];
28  		}
29  	}
30  	if (isset($call["function"])) {
31  		echo " ".$call["function"]."()";
32  	}
33  	echo "\n";
34  }
35  echo "\n";
36}
37
38//This will not create file and line items for the call into the error handler
39$page["name"] = A::A_ftk();
40?>
41--EXPECTF--
42Non-static method A::A_ftk() should not be called statically
431 %sbug38047.php:13 get_error_context()
442 %sbug38047.php:36 kalus_error_handler()
45
46
47Fatal 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
48Stack trace:
49#0 %sbug38047.php(36): A::A_ftk()
50#1 {main}
51  thrown in %sbug38047.php on line 7
52