Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Preg.php

function Preg::enforceNonNullMatches

Parameters

array<int|string, string|null|array{string|null, int}> $matches:

Return value

array<int|string, string>

Throws

UnexpectedNullMatchException

2 calls to Preg::enforceNonNullMatches()
Preg::matchStrictGroups in vendor/composer/pcre/src/Preg.php
Variant of `match()` which outputs non-null matches (or throws)
Preg::replaceCallbackStrictGroups in vendor/composer/pcre/src/Preg.php
Variant of `replaceCallback()` which outputs non-null matches (or throws)

File

vendor/composer/pcre/src/Preg.php, line 398

Class

Preg

Namespace

Composer\Pcre

Code

private static function enforceNonNullMatches(string $pattern, array $matches, string $variantMethod) {
    foreach ($matches as $group => $match) {
        if (is_string($match) || is_array($match) && is_string($match[0])) {
            continue;
        }
        throw new UnexpectedNullMatchException('Pattern "' . $pattern . '" had an unexpected unmatched group "' . $group . '", make sure the pattern always matches or use ' . $variantMethod . '() instead.');
    }
    
    /** @var array<string> */
    return $matches;
}
RSS feed
Powered by Drupal