function ExpectDeprecationTrait::regularExpressionForFormatDescription

1 call to ExpectDeprecationTrait::regularExpressionForFormatDescription()
ExpectDeprecationTrait::expectDeprecation in core/tests/Drupal/TestTools/Extension/DeprecationBridge/ExpectDeprecationTrait.php
Adds an expected deprecation.

File

core/tests/Drupal/TestTools/Extension/DeprecationBridge/ExpectDeprecationTrait.php, line 44

Class

ExpectDeprecationTrait
A trait to include in Drupal tests to manage expected deprecations.

Namespace

Drupal\TestTools\Extension\DeprecationBridge

Code

private function regularExpressionForFormatDescription(string $string) : string {
  $string = strtr(preg_quote($string, '/'), [
    '%%' => '%',
    '%e' => preg_quote(\DIRECTORY_SEPARATOR, '/'),
    '%s' => '[^\\r\\n]+',
    '%S' => '[^\\r\\n]*',
    '%a' => '.+?',
    '%A' => '.*?',
    '%w' => '\\s*',
    '%i' => '[+-]?\\d+',
    '%d' => '\\d+',
    '%x' => '[0-9a-fA-F]+',
    '%f' => '[+-]?(?:\\d+|(?=\\.\\d))(?:\\.\\d+)?(?:[Ee][+-]?\\d+)?',
    '%c' => '.',
    '%0' => '\\x00',
  ]);
  return '/^' . $string . '$/s';
}

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