- added some missing type-hints
- no need for local array `$t` (changed to "anonymous" varriant)
- formatted some arrays
This commit is contained in:
Roland Häder 2022-09-11 07:04:13 +02:00
parent 05b15f2824
commit bf9f09182e
No known key found for this signature in database
GPG Key ID: C82EDE5DDFA0BA77
7 changed files with 35 additions and 30 deletions

View File

@ -391,7 +391,7 @@ class OEmbed
* @param string $title Optional title (default: what comes from OEmbed object) * @param string $title Optional title (default: what comes from OEmbed object)
* @return string Formatted HTML * @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)); $o = self::fetchURL($url, !self::isAllowedURL($url));

View File

@ -34,12 +34,14 @@ class CalendarExport
{ {
/** /**
* Get the events widget. * Get the events widget.
*
* @param int $uid * @param int $uid
* *
* @return string Formated HTML of the calendar widget. * @return string Formated HTML of the calendar widget.
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function getHTML(int $uid = 0) { public static function getHTML(int $uid = 0): string
{
if (empty($uid)) { if (empty($uid)) {
return ''; return '';
} }
@ -49,11 +51,11 @@ class CalendarExport
return ''; return '';
} }
$tpl = Renderer::getMarkupTemplate("widget/events.tpl"); $tpl = Renderer::getMarkupTemplate('widget/events.tpl');
$return = Renderer::replaceMacros($tpl, [ $return = Renderer::replaceMacros($tpl, [
'$etitle' => DI::l10n()->t("Export"), '$etitle' => DI::l10n()->t('Export'),
'$export_ical' => DI::l10n()->t("Export calendar as ical"), '$export_ical' => DI::l10n()->t('Export calendar as ical'),
'$export_csv' => DI::l10n()->t("Export calendar as csv"), '$export_csv' => DI::l10n()->t('Export calendar as csv'),
'$user' => $user['nickname'] '$user' => $user['nickname']
]); ]);

View File

@ -42,9 +42,9 @@ class ContactBlock
* *
* @template widget/contacts.tpl * @template widget/contacts.tpl
* @hook contact_block_end (contacts=>array, output=>string) * @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 = ''; $o = '';
@ -66,13 +66,13 @@ class ContactBlock
$contacts = []; $contacts = [];
$total = DBA::count('contact', [ $total = DBA::count('contact', [
'uid' => $profile['uid'], 'uid' => $profile['uid'],
'self' => false, 'self' => false,
'blocked' => false, 'blocked' => false,
'pending' => false, 'pending' => false,
'hidden' => false, 'hidden' => false,
'archive' => false, 'archive' => false,
'failed' => false, 'failed' => false,
'network' => [Protocol::DFRN, Protocol::ACTIVITYPUB, Protocol::OSTATUS, Protocol::DIASPORA, Protocol::FEED], 'network' => [Protocol::DFRN, Protocol::ACTIVITYPUB, Protocol::OSTATUS, Protocol::DIASPORA, Protocol::FEED],
]); ]);
@ -89,15 +89,17 @@ class ContactBlock
} }
$personal_contacts = DBA::selectToArray('contact', ['uri-id'], [ $personal_contacts = DBA::selectToArray('contact', ['uri-id'], [
'uid' => $profile['uid'], 'uid' => $profile['uid'],
'self' => false, 'self' => false,
'blocked' => false, 'blocked' => false,
'pending' => false, 'pending' => false,
'hidden' => false, 'hidden' => false,
'archive' => false, 'archive' => false,
'rel' => $rel, 'rel' => $rel,
'network' => Protocol::FEDERATED, 'network' => Protocol::FEDERATED,
], ['limit' => $shown]); ], [
'limit' => $shown,
]);
$contact_uriids = array_column($personal_contacts, 'uri-id'); $contact_uriids = array_column($personal_contacts, 'uri-id');

View File

@ -34,7 +34,7 @@ class SavedSearches
* @return string * @return string
* @throws \Exception * @throws \Exception
*/ */
public static function getHTML($return_url, $search = '') public static function getHTML(string $return_url, string $search = ''): string
{ {
$saved = []; $saved = [];
$saved_searches = DBA::select('search', ['id', 'term'], ['uid' => DI::userSession()->getLocalUserId()]); $saved_searches = DBA::select('search', ['id', 'term'], ['uid' => DI::userSession()->getLocalUserId()]);

View File

@ -46,7 +46,7 @@ class TagCloud
* @return string HTML formatted output. * @return string HTML formatted output.
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @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 = ''; $o = '';
$r = self::tagadelic($uid, $count, $owner_id, $flags, $type); $r = self::tagadelic($uid, $count, $owner_id, $flags, $type);
@ -56,17 +56,17 @@ class TagCloud
$tags = []; $tags = [];
foreach ($r as $rr) { foreach ($r as $rr) {
$tag['level'] = $rr[2]; $tags[] = [
$tag['url'] = $url . '?tag=' . urlencode($rr[0]); 'level' => $rr[2],
$tag['name'] = $rr[0]; 'url' => $url . '?tag=' . urlencode($rr[0]),
'name' => $rr[0],
$tags[] = $tag; ];
} }
$tpl = Renderer::getMarkupTemplate('widget/tagcloud.tpl'); $tpl = Renderer::getMarkupTemplate('widget/tagcloud.tpl');
$o = Renderer::replaceMacros($tpl, [ $o = Renderer::replaceMacros($tpl, [
'$title' => DI::l10n()->t('Tags'), '$title' => DI::l10n()->t('Tags'),
'$tags' => $tags '$tags' => $tags
]); ]);
} }
return $o; return $o;

View File

@ -35,10 +35,11 @@ class TrendingTags
/** /**
* @param string $content 'global' (all posts) or 'local' (this node's posts only) * @param string $content 'global' (all posts) or 'local' (this node's posts only)
* @param int $period Period in hours to consider posts * @param int $period Period in hours to consider posts
* @return string *
* @return string Formatted HTML code
* @throws \Exception * @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') { if ($content == 'local') {
$tags = Tag::getLocalTrendingHashtags($period, 20); $tags = Tag::getLocalTrendingHashtags($period, 20);
@ -49,8 +50,8 @@ class TrendingTags
$tpl = Renderer::getMarkupTemplate('widget/trending_tags.tpl'); $tpl = Renderer::getMarkupTemplate('widget/trending_tags.tpl');
$o = Renderer::replaceMacros($tpl, [ $o = Renderer::replaceMacros($tpl, [
'$title' => DI::l10n()->tt('Trending Tags (last %d hour)', 'Trending Tags (last %d hours)', $period), '$title' => DI::l10n()->tt('Trending Tags (last %d hour)', 'Trending Tags (last %d hours)', $period),
'$more' => DI::l10n()->t('More Trending Tags'), '$more' => DI::l10n()->t('More Trending Tags'),
'$tags' => $tags, '$tags' => $tags,
]); ]);
return $o; return $o;

View File

@ -44,7 +44,7 @@ class VCard
* @template widget/vcard.tpl * @template widget/vcard.tpl
* @return string * @return string
*/ */
public static function getHTML(array $contact) public static function getHTML(array $contact): string
{ {
if (!isset($contact['network']) || !isset($contact['id'])) { if (!isset($contact['network']) || !isset($contact['id'])) {
Logger::warning('Incomplete contact', ['contact' => $contact ?? [], 'callstack' => System::callstack(20)]); Logger::warning('Incomplete contact', ['contact' => $contact ?? [], 'callstack' => System::callstack(20)]);