lithium\core\ErrorHandler::reset PHP Method

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.
public static reset ( )
    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);
        };
    }

Usage Example

 public function setUp()
 {
     if (!ErrorHandler::isRunning()) {
         ErrorHandler::run();
     }
     ErrorHandler::reset();
     $this->errors = array();
 }
All Usage Examples Of lithium\core\ErrorHandler::reset