]> git.mxchange.org Git - friendica.git/commitdiff
Changes:
authorRoland Häder <roland@mxchange.org>
Sun, 11 Sep 2022 05:04:13 +0000 (07:04 +0200)
committerRoland Häder <roland@mxchange.org>
Mon, 24 Oct 2022 18:32:24 +0000 (20:32 +0200)
- added some missing type-hints
- no need for local array `$t` (changed to "anonymous" varriant)
- formatted some arrays

src/Content/OEmbed.php
src/Content/Widget/CalendarExport.php
src/Content/Widget/ContactBlock.php
src/Content/Widget/SavedSearches.php
src/Content/Widget/TagCloud.php
src/Content/Widget/TrendingTags.php
src/Content/Widget/VCard.php

index 498a65e33bb79649aa9d46c372277dec5e5507dd..008269785262904c3314d7997f4f4fbc49badde7 100644 (file)
@@ -391,7 +391,7 @@ class OEmbed
         * @param string $title Optional title (default: what comes from OEmbed object)
         * @return string Formatted HTML
         */
-       public static function getHTML(string $url, string $title = '')
+       public static function getHTML(string $url, string $title = ''): string
        {
                $o = self::fetchURL($url, !self::isAllowedURL($url));
 
index 3d028ef478ca8f52272586440a44f48fe2940380..c6ab3b062a5ebd0d0e53e55a4ffce6f002b979f4 100644 (file)
@@ -34,12 +34,14 @@ class CalendarExport
 {
        /**
         * Get the events widget.
+        *
         * @param int $uid
         *
         * @return string Formated HTML of the calendar widget.
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
-       public static function getHTML(int $uid = 0) {
+       public static function getHTML(int $uid = 0): string
+       {
                if (empty($uid)) {
                        return '';
                }
@@ -49,11 +51,11 @@ class CalendarExport
                        return '';
                }
 
-               $tpl = Renderer::getMarkupTemplate("widget/events.tpl");
+               $tpl = Renderer::getMarkupTemplate('widget/events.tpl');
                $return = Renderer::replaceMacros($tpl, [
-                       '$etitle'      => DI::l10n()->t("Export"),
-                       '$export_ical' => DI::l10n()->t("Export calendar as ical"),
-                       '$export_csv'  => DI::l10n()->t("Export calendar as csv"),
+                       '$etitle'      => DI::l10n()->t('Export'),
+                       '$export_ical' => DI::l10n()->t('Export calendar as ical'),
+                       '$export_csv'  => DI::l10n()->t('Export calendar as csv'),
                        '$user'        => $user['nickname']
                ]);
 
index 041f1a89ead577e2abd72418263c0672f953961b..458167caea4ac947ec333b074633f11bebba6a37 100644 (file)
@@ -42,9 +42,9 @@ class ContactBlock
         *
         * @template widget/contacts.tpl
         * @hook contact_block_end (contacts=>array, output=>string)
-        * @return string
+        * @return string Formatted HTML code or empty string
         */
-       public static function getHTML(array $profile, int $visitor_uid = null)
+       public static function getHTML(array $profile, int $visitor_uid = null): string
        {
                $o = '';
 
@@ -66,13 +66,13 @@ class ContactBlock
                $contacts = [];
 
                $total = DBA::count('contact', [
-                       'uid' => $profile['uid'],
-                       'self' => false,
+                       'uid'     => $profile['uid'],
+                       'self'    => false,
                        'blocked' => false,
                        'pending' => false,
-                       'hidden' => false,
+                       'hidden'  => false,
                        'archive' => false,
-                       'failed' => false,
+                       'failed'  => false,
                        'network' => [Protocol::DFRN, Protocol::ACTIVITYPUB, Protocol::OSTATUS, Protocol::DIASPORA, Protocol::FEED],
                ]);
 
@@ -89,15 +89,17 @@ class ContactBlock
                        }
 
                        $personal_contacts = DBA::selectToArray('contact', ['uri-id'], [
-                               'uid' => $profile['uid'],
-                               'self' => false,
+                               'uid'     => $profile['uid'],
+                               'self'    => false,
                                'blocked' => false,
                                'pending' => false,
-                               'hidden' => false,
+                               'hidden'  => false,
                                'archive' => false,
-                               'rel' => $rel,
+                               'rel'     => $rel,
                                'network' => Protocol::FEDERATED,
-                       ], ['limit' => $shown]);
+                       ], [
+                               'limit' => $shown,
+                       ]);
 
                        $contact_uriids = array_column($personal_contacts, 'uri-id');
 
index 484afc258aed824f3784c65ec183f599a8e8c54d..6b6202ba32ea2879551755d3d127306200146653 100644 (file)
@@ -34,7 +34,7 @@ class SavedSearches
         * @return string
         * @throws \Exception
         */
-       public static function getHTML($return_url, $search = '')
+       public static function getHTML(string $return_url, string $search = ''): string
        {
                $saved = [];
                $saved_searches = DBA::select('search', ['id', 'term'], ['uid' => DI::userSession()->getLocalUserId()]);
index 6eac362b4b35793f24ea60bb88325e1758441602..d2c9d94534a9611df4b7a2e62d74940250e27b18 100644 (file)
@@ -46,7 +46,7 @@ class TagCloud
         * @return string       HTML formatted output.
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
-       public static function getHTML($uid, $count = 0, $owner_id = 0, $flags = '', $type = Tag::HASHTAG)
+       public static function getHTML(int $uid, int $count = 0, int $owner_id = 0, string $flags = '', int $type = Tag::HASHTAG): string
        {
                $o = '';
                $r = self::tagadelic($uid, $count, $owner_id, $flags, $type);
@@ -56,17 +56,17 @@ class TagCloud
 
                        $tags = [];
                        foreach ($r as $rr) {
-                               $tag['level'] = $rr[2];
-                               $tag['url'] = $url . '?tag=' . urlencode($rr[0]);
-                               $tag['name'] = $rr[0];
-
-                               $tags[] = $tag;
+                               $tags[] = [
+                                       'level' => $rr[2],
+                                       'url'   => $url . '?tag=' . urlencode($rr[0]),
+                                       'name'  => $rr[0],
+                               ];
                        }
 
                        $tpl = Renderer::getMarkupTemplate('widget/tagcloud.tpl');
                        $o = Renderer::replaceMacros($tpl, [
                                '$title' => DI::l10n()->t('Tags'),
-                               '$tags' => $tags
+                               '$tags'  => $tags
                        ]);
                }
                return $o;
index e9c44b49df248e761de6e45f1322e5024bb8a72f..173cdad1b5741106e2a4b972233b9c8cb816f7aa 100644 (file)
@@ -35,10 +35,11 @@ class TrendingTags
        /**
         * @param string $content 'global' (all posts) or 'local' (this node's posts only)
         * @param int    $period  Period in hours to consider posts
-        * @return string
+        *
+        * @return string Formatted HTML code
         * @throws \Exception
         */
-       public static function getHTML($content = 'global', int $period = 24)
+       public static function getHTML(string $content = 'global', int $period = 24): string
        {
                if ($content == 'local') {
                        $tags = Tag::getLocalTrendingHashtags($period, 20);
@@ -49,8 +50,8 @@ class TrendingTags
                $tpl = Renderer::getMarkupTemplate('widget/trending_tags.tpl');
                $o = Renderer::replaceMacros($tpl, [
                        '$title' => DI::l10n()->tt('Trending Tags (last %d hour)', 'Trending Tags (last %d hours)', $period),
-                       '$more' => DI::l10n()->t('More Trending Tags'),
-                       '$tags' => $tags,
+                       '$more'  => DI::l10n()->t('More Trending Tags'),
+                       '$tags'  => $tags,
                ]);
 
                return $o;
index 3a29522cfe90cc49cdfd02403a285e326d2527b1..13bd6f29a97be19642f1f178786f328091a0ecd6 100644 (file)
@@ -44,7 +44,7 @@ class VCard
         * @template widget/vcard.tpl
         * @return string
         */
-       public static function getHTML(array $contact)
+       public static function getHTML(array $contact): string
        {
                if (!isset($contact['network']) || !isset($contact['id'])) {
                        Logger::warning('Incomplete contact', ['contact' => $contact ?? [], 'callstack' => System::callstack(20)]);