public static function PHPUnit_Util_ErrorHandler::handleError

Parameters

integer $errno:

string $errstr:

string $errfile:

integer $errline:

Throws

PHPUnit_Framework_Error

File

drupal/core/vendor/phpunit/phpunit/PHPUnit/Util/ErrorHandler.php, line 85

Class

PHPUnit_Util_ErrorHandler
Error handler that converts PHP errors and warnings to exceptions.

Code

public static function handleError($errno, $errstr, $errfile, $errline) {
  if (!($errno & error_reporting())) {
    return FALSE;
  }
  self::$errorStack[] = array(
    $errno,
    $errstr,
    $errfile,
    $errline,
  );
  $trace = debug_backtrace(FALSE);
  array_shift($trace);
  foreach ($trace as $frame) {
    if ($frame['function'] == '__toString') {
      return FALSE;
    }
  }
  if ($errno == E_NOTICE || $errno == E_USER_NOTICE || $errno == E_STRICT) {
    if (PHPUnit_Framework_Error_Notice::$enabled !== TRUE) {
      return FALSE;
    }
    $exception = 'PHPUnit_Framework_Error_Notice';
  }
  else {
    if ($errno == E_WARNING || $errno == E_USER_WARNING) {
      if (PHPUnit_Framework_Error_Warning::$enabled !== TRUE) {
        return FALSE;
      }
      $exception = 'PHPUnit_Framework_Error_Warning';
    }
    else {
      if ($errno == E_DEPRECATED || $errno == E_USER_DEPRECATED) {
        if (PHPUnit_Framework_Error_Deprecated::$enabled !== TRUE) {
          return FALSE;
        }
        $exception = 'PHPUnit_Framework_Error_Deprecated';
      }
      else {
        $exception = 'PHPUnit_Framework_Error';
      }
    }
  }
  throw new $exception($errstr, $errno, $errfile, $errline);
}