You are here

public static function PHPUnit_Util_ErrorHandler::handleError in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpunit/phpunit/src/Util/ErrorHandler.php \PHPUnit_Util_ErrorHandler::handleError()

Parameters

int $errno:

string $errstr:

string $errfile:

int $errline:

Throws

PHPUnit_Framework_Error

File

vendor/phpunit/phpunit/src/Util/ErrorHandler.php, line 45

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';
  }
  elseif ($errno == E_WARNING || $errno == E_USER_WARNING) {
    if (PHPUnit_Framework_Error_Warning::$enabled !== true) {
      return false;
    }
    $exception = 'PHPUnit_Framework_Error_Warning';
  }
  elseif ($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);
}