function Configuration::loadDeprecationIgnorePatterns

Loads the deprecation ignore patterns from the ignore file.

File

core/tests/Drupal/TestTools/Extension/DeprecationBridge/Configuration.php, line 79

Class

Configuration
Configuration for DeprecationHandler.

Namespace

Drupal\TestTools\Extension\DeprecationBridge

Code

public function loadDeprecationIgnorePatterns() : void {
  assert(empty($this->deprecationIgnorePatterns), 'deprecationIgnorePatterns can only be loaded once');
  // Load the deprecation ignore patterns from the specified file.
  $path = $this->absoluteAndExistingPath($this->projectIgnoreFile);
  set_error_handler(static function () use ($path, &$line) : never {
    throw new \RuntimeException(sprintf('Invalid pattern found in "%s" on line %d', $path, 1 + $line));
  });
  try {
    foreach (file($path) as $line => $pattern) {
      if ((trim($pattern)[0] ?? '#') !== '#') {
        preg_match($pattern, '');
        $this->deprecationIgnorePatterns[] = $pattern;
      }
    }
  } finally {
    restore_error_handler();
  }
}

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