php-src/Zend/tests/exception_before_fatal.phpt
Dmitry Stogov 1c94ff0595 Implement engine exceptions
RFC: https://wiki.php.net/rfc/engine_exceptions_for_php7

Pending changes regarding naming of BaseException and whether it
should be an interface.
2015-03-09 14:01:32 +01:00

65 lines
1.0 KiB
PHP

--TEST--
Exceptions before fatal error
--FILE--
<?php
function exception_error_handler($code, $msg) {
throw new Exception($msg);
}
set_error_handler("exception_error_handler");
try {
$foo->a();
} catch(BaseException $e) {
var_dump($e->getMessage());
}
try {
new $foo();
} catch(BaseException $e) {
var_dump($e->getMessage());
}
try {
throw $foo;
} catch(BaseException $e) {
var_dump($e->getMessage());
}
try {
$foo();
} catch(BaseException $e) {
var_dump($e->getMessage());
}
try {
$foo::b();
} catch(BaseException $e) {
var_dump($e->getMessage());
}
try {
$b = clone $foo;
} catch(BaseException $e) {
var_dump($e->getMessage());
}
class b {
}
try {
b::$foo();
} catch(BaseException $e) {
var_dump($e->getMessage());
}
?>
--EXPECT--
string(23) "Undefined variable: foo"
string(23) "Undefined variable: foo"
string(23) "Undefined variable: foo"
string(23) "Undefined variable: foo"
string(23) "Undefined variable: foo"
string(23) "Undefined variable: foo"
string(23) "Undefined variable: foo"