xref: /php-src/Zend/tests/bug45805.phpt (revision 2f1f3495)
1--TEST--
2Bug #45805 (Crash on throwing exception from error handler)
3--FILE--
4<?php
5class PHPUnit_Util_ErrorHandler
6{
7    public static function handleError($errno, $errstr, $errfile, $errline)
8    {
9        throw new RuntimeException;
10    }
11}
12
13class A {
14    public function getX() {
15        return NULL;
16    }
17}
18
19class B {
20    public function foo() {
21        $obj    = new A;
22        $source = &$obj->getX();
23    }
24
25    public function bar() {
26        $m = new ReflectionMethod('B', 'foo');
27        $m->invoke($this);
28    }
29}
30
31set_error_handler(
32  array('PHPUnit_Util_ErrorHandler', 'handleError'), E_ALL
33);
34
35$o = new B;
36$o->bar();
37?>
38--EXPECTF--
39Fatal error: Uncaught RuntimeException in %sbug45805.php:%d
40Stack trace:
41#0 %sbug45805.php(%d): PHPUnit_Util_ErrorHandler::handleError(8, 'Only variables ...', '%s', %d)
42#1 [internal function]: B->foo()
43#2 %sbug45805.php(%d): ReflectionMethod->invoke(Object(B))
44#3 %sbug45805.php(%d): B->bar()
45#4 {main}
46  thrown in %sbug45805.php on line %d
47