public static function reset()
{
static::$_config = array();
static::$_checks = array();
static::$_exceptionHandler = null;
static::$_checks = array('type' => function ($config, $info) {
return (bool) array_filter((array) $config['type'], function ($type) use($info) {
return $type === $info['type'] || is_subclass_of($info['type'], $type);
});
}, 'code' => function ($config, $info) {
return $config['code'] & $info['code'];
}, 'stack' => function ($config, $info) {
return (bool) array_intersect((array) $config['stack'], $info['stack']);
}, 'message' => function ($config, $info) {
return preg_match($config['message'], $info['message']);
});
$self = get_called_class();
static::$_exceptionHandler = function ($exception, $return = false) use($self) {
if (ob_get_length()) {
ob_end_clean();
}
$info = compact('exception') + array('type' => get_class($exception), 'stack' => $self::trace($exception->getTrace()));
foreach (array('message', 'file', 'line', 'trace') as $key) {
$method = 'get' . ucfirst($key);
$info[$key] = $exception->{$method}();
}
return $return ? $info : $self::handle($info);
};
}