function DeprecationListenerTrait::registerErrorHandler
Same name and namespace in other branches
- 8.9.x core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php \Drupal\Tests\Listeners\DeprecationListenerTrait::registerErrorHandler()
Registers an error handler that wraps Symfony's DeprecationErrorHandler.
See also
\Symfony\Bridge\PhpUnit\DeprecationErrorHandler
\Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait
2 calls to DeprecationListenerTrait::registerErrorHandler()
- DrupalListener::startTest in core/
tests/ Drupal/ Tests/ Listeners/ DrupalListener.php - DrupalListener::startTestSuite in core/
tests/ Drupal/ Tests/ Listeners/ DrupalListener.php
File
-
core/
tests/ Drupal/ Tests/ Listeners/ DeprecationListenerTrait.php, line 158
Class
- DeprecationListenerTrait
- Removes deprecations that we are yet to fix.
Namespace
Drupal\Tests\ListenersCode
protected function registerErrorHandler() {
if ($this->previousHandler || 'disabled' === getenv('SYMFONY_DEPRECATIONS_HELPER')) {
return;
}
$deprecation_handler = function ($type, $msg, $file, $line, $context = []) {
// Skip listed deprecations.
if (($type === E_USER_DEPRECATED || $type === E_DEPRECATED) && static::isDeprecationSkipped($msg)) {
return;
}
// Drupal 9 uses PHP syntax that's deprecated in PHP 8.2.
if (PHP_VERSION_ID >= 80200 && $type === E_DEPRECATED) {
return;
}
return call_user_func($this->previousHandler, $type, $msg, $file, $line, $context);
};
$this->previousHandler = set_error_handler($deprecation_handler);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.