You are here

protected function DeprecationListenerTrait::registerErrorHandler in Drupal 9

Same name and namespace in other branches
  1. 8 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 133

Class

DeprecationListenerTrait
Removes deprecations that we are yet to fix.

Namespace

Drupal\Tests\Listeners

Code

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 && static::isDeprecationSkipped($msg)) {
      return;
    }
    return call_user_func($this->previousHandler, $type, $msg, $file, $line, $context);
  };
  $this->previousHandler = set_error_handler($deprecation_handler);
}