diff options
author | blizzz <blizzz@owncloud.com> | 2015-07-16 11:35:25 +0200 |
---|---|---|
committer | blizzz <blizzz@owncloud.com> | 2015-07-16 11:35:25 +0200 |
commit | bfb90d10edfc863213522c704f7d0b8bad8c8646 (patch) | |
tree | c5db88dab3beb85fb320d7249b8f436dd5f20e14 /lib/private/helper.php | |
parent | dce462c28db1d5e5b144efcfb26a466bd290621c (diff) | |
parent | 472d48f6e32168bb7309a4869e469eb305d95f14 (diff) | |
download | nextcloud-server-bfb90d10edfc863213522c704f7d0b8bad8c8646.tar.gz nextcloud-server-bfb90d10edfc863213522c704f7d0b8bad8c8646.zip |
Merge pull request #17046 from nicolas-grekas/fix-16654
Do not use OC*::mb_*_replace(), they are useless
Diffstat (limited to 'lib/private/helper.php')
-rw-r--r-- | lib/private/helper.php | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/lib/private/helper.php b/lib/private/helper.php index e825009f687..ed954f87630 100644 --- a/lib/private/helper.php +++ b/lib/private/helper.php @@ -726,17 +726,11 @@ class OC_Helper { * @param int $start If start is positive, the replacing will begin at the start'th offset into string. If start is negative, the replacing will begin at the start'th character from the end of string. * @param int $length Length of the part to be replaced * @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8 - * @internal param string $input The input string. .Opposite to the PHP build-in function does not accept an array. * @return string + * @deprecated 8.2.0 Use substr_replace() instead. */ - public static function mb_substr_replace($string, $replacement, $start, $length = null, $encoding = 'UTF-8') { - $start = intval($start); - $length = intval($length); - $string = mb_substr($string, 0, $start, $encoding) . - $replacement . - mb_substr($string, $start + $length, mb_strlen($string, 'UTF-8') - $start, $encoding); - - return $string; + public static function mb_substr_replace($string, $replacement, $start, $length = 0, $encoding = 'UTF-8') { + return substr_replace($string, $replacement, $start, $length); } /** @@ -748,17 +742,11 @@ class OC_Helper { * @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8 * @param int $count If passed, this will be set to the number of replacements performed. * @return string + * @deprecated 8.2.0 Use str_replace() instead. * */ public static function mb_str_replace($search, $replace, $subject, $encoding = 'UTF-8', &$count = null) { - $offset = -1; - $length = mb_strlen($search, $encoding); - while (($i = mb_strrpos($subject, $search, $offset, $encoding)) !== false) { - $subject = OC_Helper::mb_substr_replace($subject, $replace, $i, $length); - $offset = $i - mb_strlen($subject, $encoding); - $count++; - } - return $subject; + return str_replace($search, $replace, $subject, $count); } /** |