xref: /PHP-8.1/Zend/tests/bug61767.phpt (revision 7aacc705)
1--TEST--
2Bug #61767 (Shutdown functions not called in certain error situation)
3--FILE--
4<?php
5set_error_handler(function($code, $msg, $file = null, $line = null) {
6    echo "Error handler called ($msg)\n";
7    throw new \ErrorException($msg, $code, 0, $file, $line);
8});
9
10register_shutdown_function(function(){
11    echo "Shutting down\n";
12    print_r(error_get_last());
13});
14
15//$undefined = null; // defined variable does not cause problems
16$undefined->foo();
17?>
18--EXPECTF--
19Error handler called (Undefined variable $undefined)
20
21Fatal error: Uncaught ErrorException: Undefined variable $undefined in %sbug61767.php:%d
22Stack trace:
23#0 %sbug61767.php(%d): {closure}(%s, 'Undefined varia...', '%s', %d)
24#1 {main}
25  thrown in %sbug61767.php on line %d
26Shutting down
27Array
28(
29    [type] => 1
30    [message] => %a
31    [file] => %sbug61767.php
32    [line] => %d
33)
34