function 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 53
Class
- BootstrapErrorHandler
- Drupal's PHPUnit base error handler.
Namespace
Drupal\TestTools\ErrorHandlerCode
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.');
}
// We collect a deprecation no matter what.
if (E_USER_DEPRECATED === $errorNumber || E_DEPRECATED === $errorNumber) {
$prefix = error_reporting() & $errorNumber ? 'Unsilenced deprecation: ' : '';
DeprecationHandler::collectActualDeprecation($prefix . $errorString);
}
// 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.