Automattic\WooCommerce\Vendor\Pelago\Emogrifier\Utilities

Preg::matchAllpublicWC 1.0

Wraps preg_match_all.

If an error occurs, and exceptions are not being thrown, zero (0) is returned.

In the error case, if the $matches parameter is provided, it is set to an array containing empty arrays for the full pattern match and any possible subpattern match that might be expected. The algorithm to determine the length of this array simply counts the number of opening parentheses in the $pattern, which may result in a longer array than expected, but guarantees that it is at least as long as expected.

This method does not currently support the $flags or $offset parameters.

Method of the class: Preg{}

No Hooks.

Returns

null. Nothing (null).

Usage

$Preg = new Preg();
$Preg->matchAll( $pattern, $subject, ?array $matches ): int;
$pattern(non-empty-string) (required)
.
$subject(string) (required)
.
?array $matches(passed by reference — &)
.
Default: null

Preg::matchAll() code WC 10.7.0

public function matchAll(string $pattern, string $subject, ?array &$matches = null): int
{
    $result = \preg_match_all($pattern, $subject, $matches);

    if ($result === false) {
        $this->logOrThrowPregLastError();
        $result = 0;
        $matches = \array_fill(0, \substr_count($pattern, '(') + 1, []);
    }

    return $result;
}