public static function checks($checks = array())
 {
     if ($checks) {
         static::$_checks = $checks;
     }
     return static::$_checks;
 }
Exemplo n.º 2
0
 /**
  * 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 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);
     };
 }
Exemplo n.º 3
0
 /**
  * Wipes out all configuration and resets the error handler to its initial state when loaded.
  * Mainly used for testing.
  *
  * @return void
  */
 public static function reset()
 {
     static::$_config = array();
     static::$_checks = array();
     static::$_handlers = array();
     static::$_exceptionHandler = null;
     static::__init();
 }