Extends
lithium\core\StaticObject
Setup basic error handling checks/types, as well as register the error and exception
handlers.
Called on static class initialization (i.e. when first loaded).
Returns
voidSource
public static function __init() {
static::$_checks = array(
'type' => function($config, $info) {
return (boolean) 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 (boolean) 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);
};
}