Automattic\WooCommerce\Vendor\Pelago\Emogrifier\Utilities
Preg::replaceCallback
Wraps preg_replace_callback, though does not support $subject being an array. If an error occurs, and exceptions are not being thrown, the original $subject is returned.
Note that (unlike when calling preg_replace_callback), $callback cannot be a non-public method represented by an array comprising an object or class name and the method name. To circumvent that, use \Closure::fromCallable([$objectOrClassName, 'method']).
Method of the class: Preg{}
No Hooks.
Returns
null. Nothing (null).
Usage
$Preg = new Preg(); $Preg->replaceCallback( $pattern, $callback, $subject, $limit, ?int $count ): string;
- $pattern(non-empty-string|non-empty-array
) (required) - .
- $callback(callable) (required)
- .
- $subject(string) (required)
- .
- $limit(int)
- .
Default:-1 - ?int $count(passed by reference — &)
- .
Default:null
Preg::replaceCallback() Preg::replaceCallback code WC 10.5.0
public function replaceCallback(
$pattern,
callable $callback,
string $subject,
int $limit = -1,
?int &$count = null
): string {
$result = \preg_replace_callback($pattern, $callback, $subject, $limit, $count);
if ($result === null) {
$this->logOrThrowPregLastError();
$result = $subject;
}
return $result;
}