2014-04-19 13:32:16 +00:00
|
|
|
--TEST--
|
|
|
|
Convert errors to exceptions from method calls on non-objects raise recoverable errors
|
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
set_error_handler(function($code, $message) {
|
2014-07-06 12:48:42 +00:00
|
|
|
echo "Raising...\n";
|
2014-04-19 13:32:16 +00:00
|
|
|
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;
|
2014-07-06 12:48:42 +00:00
|
|
|
echo "Calling...\n";
|
2014-04-19 13:32:16 +00:00
|
|
|
try {
|
|
|
|
$x->method();
|
|
|
|
} catch (BadMethodCallException $e) {
|
|
|
|
echo "Caught expected ", $e->getMessage(), "!\n";
|
|
|
|
}
|
|
|
|
echo "Alive\n";
|
|
|
|
?>
|
|
|
|
--EXPECTF--
|
2014-07-06 12:48:42 +00:00
|
|
|
Calling...
|
|
|
|
Raising...
|
2014-07-06 15:07:41 +00:00
|
|
|
Caught expected Call to a member function method() on null!
|
2014-04-19 13:32:16 +00:00
|
|
|
Alive
|