function TestErrorHandler::__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/ TestErrorHandler.php, line 54
Class
- TestErrorHandler
- Drupal's PHPUnit test level 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 are within a test execution. If we have a deprecation and the test is
// a deprecation test, than we just collect the deprecation and return to
// execution, since deprecations are expected.
if ((E_USER_DEPRECATED === $errorNumber || E_DEPRECATED === $errorNumber) && DeprecationHandler::isDeprecationTest($this->testCase)) {
$prefix = error_reporting() & $errorNumber ? 'Unsilenced deprecation: ' : '';
DeprecationHandler::collectActualDeprecation($prefix . $errorString);
return TRUE;
}
// In all other cases (errors, warnings, deprecations in normal tests), we
// fall back to the parent error handler, which is the one that was
// registered in the test runner bootstrap (BootstrapErrorHandler).
call_user_func($this->parentHandler, $errorNumber, $errorString, $errorFile, $errorLine);
return TRUE;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.