]> git.mxchange.org Git - friendica.git/commitdiff
Replace deprecated use of "self" in callables
authorHypolite Petovan <hypolite@mrpetovan.com>
Thu, 19 Jan 2023 14:02:05 +0000 (09:02 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sat, 21 Jan 2023 19:25:21 +0000 (14:25 -0500)
- Address part of https://github.com/friendica/friendica/issues/12011#issuecomment-1383147421

src/Content/OEmbed.php
src/Content/Smilies.php
src/Content/Text/BBCode.php
src/Content/Text/HTML.php
src/Content/Widget/TagCloud.php
src/Database/DBA.php
src/Model/Event.php
src/Protocol/ActivityPub/Transmitter.php
src/Util/ParseUrl.php
src/Util/Proxy.php

index 7553cd9f81728e49c913d677b724621f9a83f8ff..562febdaf916bc0d49a9eebc312a5c0019159be0 100644 (file)
@@ -316,7 +316,7 @@ class OEmbed
                if ($stopoembed == true) {
                        return preg_replace("/\[embed\](.+?)\[\/embed\]/is", "<!-- oembed $1 --><i>" . DI::l10n()->t('Embedding disabled') . " : $1</i><!-- /oembed $1 -->", $text);
                }
-               return preg_replace_callback("/\[embed\](.+?)\[\/embed\]/is", ['self', 'replaceCallback'], $text);
+               return preg_replace_callback("/\[embed\](.+?)\[\/embed\]/is", [self::class, 'replaceCallback'], $text);
        }
 
        /**
index 5ebb5b64e83341c5f958438aa3fff413d8308073..c51d9b33058225c95f1b9d57133df26e0c893355 100644 (file)
@@ -218,8 +218,8 @@ class Smilies
                        return $text;
                }
 
-               $text = preg_replace_callback('/<(pre)>(.*?)<\/pre>/ism', 'self::encode', $text);
-               $text = preg_replace_callback('/<(code)>(.*?)<\/code>/ism', 'self::encode', $text);
+               $text = preg_replace_callback('/<(pre)>(.*?)<\/pre>/ism', [self::class, 'encode'], $text);
+               $text = preg_replace_callback('/<(code)>(.*?)<\/code>/ism', [self::class, 'encode'], $text);
 
                if ($no_images) {
                        $cleaned = ['texts' => [], 'icons' => []];
@@ -233,11 +233,11 @@ class Smilies
                        $smilies = $cleaned;
                }
 
-               $text = preg_replace_callback('/&lt;(3+)/', 'self::heartReplaceCallback', $text);
+               $text = preg_replace_callback('/&lt;(3+)/', [self::class, 'heartReplaceCallback'], $text);
                $text = self::strOrigReplace($smilies['texts'], $smilies['icons'], $text);
 
-               $text = preg_replace_callback('/<(code)>(.*?)<\/code>/ism', 'self::decode', $text);
-               $text = preg_replace_callback('/<(pre)>(.*?)<\/pre>/ism', 'self::decode', $text);
+               $text = preg_replace_callback('/<(code)>(.*?)<\/code>/ism', [self::class, 'decode'], $text);
+               $text = preg_replace_callback('/<(pre)>(.*?)<\/pre>/ism', [self::class, 'decode'], $text);
 
                return $text;
        }
index f65eeeee2cd7171c62d305a2265aad27e095b20e..e95ed0675983e48f238c6930f99c9f5db5faf1a3 100644 (file)
@@ -1415,8 +1415,8 @@ class BBCode
        public static function cleanPictureLinks(string $text): string
        {
                DI::profiler()->startRecording('rendering');
-               $return = preg_replace_callback("&\[url=([^\[\]]*)\]\[img=(.*)\](.*)\[\/img\]\[\/url\]&Usi", 'self::cleanPictureLinksCallback', $text);
-               $return = preg_replace_callback("&\[url=([^\[\]]*)\]\[img\](.*)\[\/img\]\[\/url\]&Usi", 'self::cleanPictureLinksCallback', $return);
+               $return = preg_replace_callback("&\[url=([^\[\]]*)\]\[img=(.*)\](.*)\[\/img\]\[\/url\]&Usi", [self::class, 'cleanPictureLinksCallback'], $text);
+               $return = preg_replace_callback("&\[url=([^\[\]]*)\]\[img\](.*)\[\/img\]\[\/url\]&Usi", [self::class, 'cleanPictureLinksCallback'], $return);
                DI::profiler()->stopRecording();
                return $return;
        }
@@ -1450,7 +1450,7 @@ class BBCode
        {
                DI::profiler()->startRecording('rendering');
                $regexp = "/([@!])\[url\=([^\[\]]*)\].*?\[\/url\]/ism";
-               $body = preg_replace_callback($regexp, ['self', 'mentionCallback'], $body);
+               $body = preg_replace_callback($regexp, [self::class, 'mentionCallback'], $body);
                DI::profiler()->stopRecording();
                return $body;
        }
@@ -2002,12 +2002,12 @@ class BBCode
 
                                if (!$for_plaintext) {
                                        if (in_array($simple_html, [self::OSTATUS, self::MASTODON_API, self::TWITTER_API, self::ACTIVITYPUB])) {
-                                               $text = preg_replace_callback("/\[url\](.*?)\[\/url\]/ism", 'self::convertUrlForActivityPubCallback', $text);
-                                               $text = preg_replace_callback("/\[url\=(.*?)\](.*?)\[\/url\]/ism", 'self::convertUrlForActivityPubCallback', $text);
+                                               $text = preg_replace_callback("/\[url\](.*?)\[\/url\]/ism", [self::class, 'convertUrlForActivityPubCallback'], $text);
+                                               $text = preg_replace_callback("/\[url\=(.*?)\](.*?)\[\/url\]/ism", [self::class, 'convertUrlForActivityPubCallback'], $text);
                                        }
                                } else {
                                        $text = preg_replace("(\[url\](.*?)\[\/url\])ism", " $1 ", $text);
-                                       $text = preg_replace_callback("&\[url=([^\[\]]*)\]\[img\](.*)\[\/img\]\[\/url\]&Usi", 'self::removePictureLinksCallback', $text);
+                                       $text = preg_replace_callback("&\[url=([^\[\]]*)\]\[img\](.*)\[\/img\]\[\/url\]&Usi", [self::class, 'removePictureLinksCallback'], $text);
                                }
 
                                // Bookmarks in red - will be converted to bookmarks in friendica
@@ -2017,7 +2017,7 @@ class BBCode
                                                        "[bookmark=$1]$2[/bookmark]", $text);
 
                                if (in_array($simple_html, [self::OSTATUS, self::TWITTER])) {
-                                       $text = preg_replace_callback("/([^#@!])\[url\=([^\]]*)\](.*?)\[\/url\]/ism", "self::expandLinksCallback", $text);
+                                       $text = preg_replace_callback("/([^#@!])\[url\=([^\]]*)\](.*?)\[\/url\]/ism", [self::class, 'expandLinksCallback'], $text);
                                        //$text = preg_replace("/[^#@!]\[url\=([^\]]*)\](.*?)\[\/url\]/ism", ' $2 [url]$1[/url]', $text);
                                        $text = preg_replace("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism", ' $2 [url]$1[/url]', $text);
                                }
@@ -2327,7 +2327,7 @@ class BBCode
                        $url_search_string = "^\[\]";
                        $text = preg_replace_callback(
                                "/([@!])\[(.*?)\]\(([$url_search_string]*?)\)/ism",
-                               ['self', 'bbCodeMention2DiasporaCallback'],
+                               [self::class, 'bbCodeMention2DiasporaCallback'],
                                $text
                        );
                }
index c65e1d9820368d488f595aefb8e0f297a42d1a52..f9f340135cf51cf22cab2bf62c941166305b2f4c 100644 (file)
@@ -1032,7 +1032,7 @@ class HTML
                // the quotes, e.g.:
                //
                //    concat("'foo'", '"', "bar")
-               return 'concat(' . implode(', \'"\', ', array_map(['self', 'xpathQuote'], explode('"', $value))) . ')';
+               return 'concat(' . implode(', \'"\', ', array_map([self::class, 'xpathQuote'], explode('"', $value))) . ')';
        }
 
        /**
index 6f146f4ac1bb00a48ee73e14b5607a6a4daf69a7..53d332f0a8897df3caccd5d8d9a2296884dbcaa4 100644 (file)
@@ -144,7 +144,7 @@ class TagCloud
                        $x ++;
                }
 
-               usort($tags, 'self::tagsSort');
+               usort($tags, [self::class, 'tagsSort']);
                $range = max(0.01, $max - $min) * 1.0001;
 
                for ($x = 0; $x < count($tags); $x ++) {
index ffeecfaa711615e607e6fdb83462f66ff1215656..e29cd30386848b465afc2f9446dc3f0c9864758e 100644 (file)
@@ -527,7 +527,7 @@ class DBA
        public static function buildTableString(array $tables): string
        {
                // Quote each entry
-               return implode(',', array_map(['self', 'quoteIdentifier'], $tables));
+               return implode(',', array_map([self::class, 'quoteIdentifier'], $tables));
        }
 
        /**
@@ -717,7 +717,7 @@ class DBA
        {
                $groupby_string = '';
                if (!empty($params['group_by'])) {
-                       $groupby_string = " GROUP BY " . implode(', ', array_map(['self', 'quoteIdentifier'], $params['group_by']));
+                       $groupby_string = " GROUP BY " . implode(', ', array_map([self::class, 'quoteIdentifier'], $params['group_by']));
                }
 
                $order_string = '';
index ca22c32ac6df506e350f7f4246f07036fd6eafc9..e39ee5fd56b43b78fc64561a7cf55320b8638372 100644 (file)
@@ -198,7 +198,7 @@ class Event
 
        public static function sortByDate(array $event_list): array
        {
-               usort($event_list, ['self', 'compareDatesCallback']);
+               usort($event_list, [self::class, 'compareDatesCallback']);
                return $event_list;
        }
 
index 6e1180bca81c6047acf6601faaff70c41c3339be..bcff0b53b13d08cf43319643fa817d35bc0f0d46 100644 (file)
@@ -1661,7 +1661,7 @@ class Transmitter
                 *
                 * } elseif (($type == 'Article') && empty($data['summary'])) {
                 *              $regexp = "/[@!]\[url\=([^\[\]]*)\].*?\[\/url\]/ism";
-                *              $summary = preg_replace_callback($regexp, ['self', 'mentionAddrCallback'], $body);
+                *              $summary = preg_replace_callback($regexp, [self::class, 'mentionAddrCallback'], $body);
                 *              $data['summary'] = BBCode::toPlaintext(Plaintext::shorten(self::removePictures($summary), 1000));
                 * }
                 */
index 9d19a4ebac9e02aade552216f4bbfc23f9727f21..f1e96dedc3b8347a0c673f5134c285b0c2f2203e 100644 (file)
@@ -646,7 +646,7 @@ class ParseUrl
                $arr_tags = str_getcsv($string);
                if (count($arr_tags)) {
                        // add the # sign to every tag
-                       array_walk($arr_tags, ['self', 'arrAddHashes']);
+                       array_walk($arr_tags, [self::class, 'arrAddHashes']);
 
                        return $arr_tags;
                }
index 67a0becb04e842103c7304accb1bb2b36600152b..7f3c94672273dacb5341e6d98d6ef4080fd73c4e 100644 (file)
@@ -141,7 +141,7 @@ class Proxy
        {
                $html = str_replace(Strings::normaliseLink(DI::baseUrl()) . '/', DI::baseUrl() . '/', $html);
 
-               return preg_replace_callback('/(<img [^>]*src *= *["\'])([^"\']+)(["\'][^>]*>)/siU', 'self::replaceUrl', $html);
+               return preg_replace_callback('/(<img [^>]*src *= *["\'])([^"\']+)(["\'][^>]*>)/siU', [self::class, 'replaceUrl'], $html);
        }
 
        /**