lithium\core\ErrorHandler::reset()

public static method

Setup basic error handling checks/types, as well as register the error and exception handlers and wipes out all configuration and resets the error handler to its initial state when loaded. Mainly used for testing.

Source

	public static function reset() {
		static::$_config = [];
		static::$_checks = [];
		static::$_exceptionHandler = null;
		static::$_checks = [
			'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']);
			}
		];
		static::$_exceptionHandler = function(Throwable $exception, $return = false) {
			if (ob_get_length()) {
				ob_end_clean();
			}
			$info = compact('exception') + [
				'type' => get_class($exception),
				'stack' => static::trace($exception->getTrace())
			];
			foreach (['message', 'file', 'line', 'trace'] as $key) {
				$method = 'get' . ucfirst($key);
				$info[$key] = $exception->{$method}();
			}
			return $return ? $info : static::handle($info);
		};
	}