function BootstrapErrorHandler::__invoke

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/TestTools/ErrorHandler/BootstrapErrorHandler.php \Drupal\TestTools\ErrorHandler\BootstrapErrorHandler::__invoke()

Executes when the object is called as a function.

Parameters

int $errorNumber: The level of the error raised.

string $errorString: The error message.

string $errorFile: The filename that the error was raised in.

int $errorLine: The line number the error was raised at.

Return value

bool TRUE to stop error handling, FALSE to let the normal error handler continue.

File

core/tests/Drupal/TestTools/ErrorHandler/BootstrapErrorHandler.php, line 51

Class

BootstrapErrorHandler
Drupal's PHPUnit base error handler.

Namespace

Drupal\TestTools\ErrorHandler

Code

public function __invoke(int $errorNumber, string $errorString, string $errorFile, int $errorLine) : bool {
  if (!DeprecationHandler::isEnabled()) {
    throw new \RuntimeException(__METHOD__ . '() must not be called if the deprecation handler is not enabled.');
  }
  // If the deprecation handled is one of those in the ignore list, we keep
  // running.
  if ((E_USER_DEPRECATED === $errorNumber || E_DEPRECATED === $errorNumber) && DeprecationHandler::isIgnoredDeprecation($errorString)) {
    return TRUE;
  }
  // In all other cases (errors, warnings, deprecations to be reported), we
  // fall back to PHPUnit's error handler, an instance of which was created
  // when this error handler was created.
  try {
    call_user_func($this->phpUnitErrorHandler, $errorNumber, $errorString, $errorFile, $errorLine);
  } catch (NoTestCaseObjectOnCallStackException) {
    // If we end up here, it's likely because a test's processing has
    // finished already and we are processing an error that occurred while
    // dealing with STDOUT rewinding or truncating. Do nothing.
  }
  return TRUE;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.