blob: 874f57cb2461accde24d6fdbf094e67e0b7a1159 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
--TEST--
Convert errors to exceptions from method calls on non-objects raise recoverable errors
--FILE--
<?php
set_error_handler(function($code, $message) {
echo "Raising...\n";
if (0 === strncmp('Call', $message, 4)) {
throw new BadMethodCallException($message);
} else if (0 === strncmp('Argument', $message, 8)) {
throw new InvalidArgumentException($message);
} else {
trigger_error($message, E_USER_ERROR);
}
}, E_RECOVERABLE_ERROR);
$x= null;
echo "Calling...\n";
try {
$x->method();
} catch (BadMethodCallException $e) {
echo "Caught expected ", $e->getMessage(), "!\n";
}
echo "Alive\n";
?>
--EXPECTF--
Calling...
Raising...
Caught expected Call to a member function method() on null!
Alive
|