X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=includes%2Flibs%2FStringUtils.php;h=51d108168af43b063fe12389408f5dc377c8734a;hb=9bbb26ffbd16edbaccce27461730fa9e172aa048;hp=7915ccf19146421dc8dda9cd89d5c0b4742bc842;hpb=8c99c1484536efee223d881ae29ef6cd0412615e;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/libs/StringUtils.php b/includes/libs/StringUtils.php index 7915ccf191..51d108168a 100644 --- a/includes/libs/StringUtils.php +++ b/includes/libs/StringUtils.php @@ -206,7 +206,7 @@ class StringUtils { } elseif ( $tokenType == 'end' ) { if ( $foundStart ) { # Found match - $output .= call_user_func( $callback, [ + $output .= $callback( [ substr( $subject, $outputPos, $tokenOffset + $tokenLength - $outputPos ), substr( $subject, $contentPos, $tokenOffset - $contentPos ) ] ); @@ -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 );