summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorNicolas Grekas <nicolas.grekas@gmail.com>2015-06-19 14:55:04 +0200
committerNicolas Grekas <nicolas.grekas@gmail.com>2015-07-16 11:00:04 +0200
commit472d48f6e32168bb7309a4869e469eb305d95f14 (patch)
tree21317d12e130ced3f7fcd9b8a26e3f6c423aa903 /lib
parent5c2646a4bfe235487ba4177bd5733a278ab2101e (diff)
downloadnextcloud-server-472d48f6e32168bb7309a4869e469eb305d95f14.tar.gz
nextcloud-server-472d48f6e32168bb7309a4869e469eb305d95f14.zip
Do not use OC*::mb_*_replace(), they are useless
Diffstat (limited to 'lib')
-rw-r--r--lib/private/helper.php22
-rw-r--r--lib/public/util.php2
2 files changed, 7 insertions, 17 deletions
diff --git a/lib/private/helper.php b/lib/private/helper.php
index f4de5b0d9f8..d2414525859 100644
--- a/lib/private/helper.php
+++ b/lib/private/helper.php
@@ -770,17 +770,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);
}
/**
@@ -792,17 +786,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);
}
/**
diff --git a/lib/public/util.php b/lib/public/util.php
index 087bb639618..d7c67eaa2f5 100644
--- a/lib/public/util.php
+++ b/lib/public/util.php
@@ -542,6 +542,7 @@ class Util {
* @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8
* @return string
* @since 4.5.0
+ * @deprecated 8.2.0 Use substr_replace() instead.
*/
public static function mb_substr_replace($string, $replacement, $start, $length = null, $encoding = 'UTF-8') {
return(\OC_Helper::mb_substr_replace($string, $replacement, $start, $length, $encoding));
@@ -557,6 +558,7 @@ class Util {
* @param int $count If passed, this will be set to the number of replacements performed.
* @return string
* @since 4.5.0
+ * @deprecated 8.2.0 Use str_replace() instead.
*/
public static function mb_str_replace($search, $replace, $subject, $encoding = 'UTF-8', &$count = null) {
return(\OC_Helper::mb_str_replace($search, $replace, $subject, $encoding, $count));