php-src/Zend/tests/bug45805.phpt
Nikita Popov 3ae995f03c Tweak uncaught exception message display
This implements a reduced variant of #1226 with just the following
change:

-Fatal error: Uncaught exception 'EngineException' with message 'Call to private method foo::bar() from context ''' in %s:%d
+Fatal error: Uncaught EngineException: Call to private method foo::bar() from context '' in %s:%d

The '' wrapper around messages is very weird if the exception
message itself contains ''. Futhermore having the message wrapped
in '' doesn't work for the "and defined" suffix of
TypeExceptions.
2015-05-17 18:47:06 +02:00

49 lines
1.1 KiB
PHP

--TEST--
Bug #45805 (Crash on throwing exception from error handler)
--SKIPIF--
<?php extension_loaded('reflection') or die('skip'); ?>
--FILE--
<?php
class PHPUnit_Util_ErrorHandler
{
public static function handleError($errno, $errstr, $errfile, $errline)
{
throw new RuntimeException;
}
}
class A {
public function getX() {
return NULL;
}
}
class B {
public function foo() {
$obj = new A;
$source = &$obj->getX();
}
public function bar() {
$m = new ReflectionMethod('B', 'foo');
$m->invoke($this);
}
}
set_error_handler(
array('PHPUnit_Util_ErrorHandler', 'handleError'), E_ALL | E_STRICT
);
$o = new B;
$o->bar();
?>
--EXPECTF--
Fatal error: Uncaught RuntimeException in %sbug45805.php:%d
Stack trace:
#0 %sbug45805.php(%d): PHPUnit_Util_ErrorHandler::handleError(8, 'Only variables ...', '%s', %d, Array)
#1 [internal function]: B->foo()
#2 %sbug45805.php(%d): ReflectionMethod->invoke(Object(B))
#3 %sbug45805.php(%d): B->bar()
#4 {main}
thrown in %sbug45805.php on line %d