X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Flibs%2FStringUtils.php;h=51d108168af43b063fe12389408f5dc377c8734a;hb=a89f844919271da2e7c4d2a540de6d0f516d845a;hp=d91ac85adb1a56c99748f9a55a2400aba7a36b78;hpb=284bc0b5eb1c0e47d7100d5604ab4d5180dcd8d5;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/libs/StringUtils.php b/includes/libs/StringUtils.php index d91ac85adb..51d108168a 100644 --- a/includes/libs/StringUtils.php +++ b/includes/libs/StringUtils.php @@ -243,10 +243,13 @@ class StringUtils { * @return string The string with the matches replaced */ static function delimiterReplace( $startDelim, $endDelim, $replace, $subject, $flags = '' ) { - $replacer = new RegexlikeReplacer( $replace ); - - return self::delimiterReplaceCallback( $startDelim, $endDelim, - $replacer->cb(), $subject, $flags ); + return self::delimiterReplaceCallback( + $startDelim, $endDelim, + function ( array $matches ) use ( $replace ) { + return strtr( $replace, [ '$0' => $matches[0], '$1' => $matches[1] ] ); + }, + $subject, $flags + ); } /** @@ -263,8 +266,13 @@ class StringUtils { $text = str_replace( $placeholder, '', $text ); // Replace instances of the separator inside HTML-like tags with the placeholder - $replacer = new DoubleReplacer( $separator, $placeholder ); - $cleaned = self::delimiterReplaceCallback( '<', '>', $replacer->cb(), $text ); + $cleaned = self::delimiterReplaceCallback( + '<', '>', + function ( array $matches ) use ( $separator, $placeholder ) { + return str_replace( $separator, $placeholder, $matches[0] ); + }, + $text + ); // Explode, then put the replaced separators back in $items = explode( $separator, $cleaned ); @@ -290,8 +298,13 @@ class StringUtils { $text = str_replace( $placeholder, '', $text ); // Replace instances of the separator inside HTML-like tags with the placeholder - $replacer = new DoubleReplacer( $search, $placeholder ); - $cleaned = self::delimiterReplaceCallback( '<', '>', $replacer->cb(), $text ); + $cleaned = self::delimiterReplaceCallback( + '<', '>', + function ( array $matches ) use ( $search, $placeholder ) { + return str_replace( $search, $placeholder, $matches[0] ); + }, + $text + ); // Explode, then put the replaced separators back in $cleaned = str_replace( $search, $replace, $cleaned );