From 9fde74082ab338093f977101bbc112b14fb41bde Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 18 Sep 2026 12:34:58 +0930 Subject: [PATCH] add type to function --- app/Http/Controllers/AvatarController.php | 2 +- app/Http/Controllers/RemoteOidcController.php | 2 +- app/Jobs/MovePipeline/ProcessMovePipeline.php | 2 +- app/Jobs/SharePipeline/SharePipeline.php | 2 +- app/Models/Contact.php | 2 +- app/Models/CustomFilterKeyword.php | 2 +- app/Models/DirectMessage.php | 2 +- app/Models/Group.php | 2 +- app/Models/GroupComment.php | 2 +- app/Models/GroupPost.php | 4 ++-- app/Models/Hashtag.php | 2 +- app/Models/LiveStream.php | 6 +++--- app/Models/Media.php | 4 ++-- app/Models/ModLog.php | 2 +- app/Models/Place.php | 2 +- app/Models/Portfolio.php | 2 +- app/Models/Profile.php | 2 +- app/Models/Status.php | 4 ++-- app/Models/User.php | 4 ++-- app/Services/AccountService.php | 2 +- app/Services/GroupPostService.php | 2 +- app/Services/GroupService.php | 2 +- app/Services/Groups/GroupCommentService.php | 2 +- app/Services/Groups/GroupPostService.php | 2 +- app/Services/Internal/SoftwareUpdateService.php | 4 ++-- app/Services/RelationshipService.php | 2 +- app/Services/SanitizeService.php | 2 +- app/Services/StatusService.php | 4 ++-- app/Services/TrendingHashtagService.php | 2 +- app/Transformer/Api/Mastodon/v1/NotificationTransformer.php | 2 +- app/Util/ActivityPub/Helpers.php | 2 +- app/Util/Lexer/Autolink.php | 6 +++--- app/Util/Lexer/LooseAutolink.php | 4 ++-- app/Util/Lexer/PrettyNumber.php | 2 +- app/Util/Lexer/StringUtils.php | 2 +- app/Util/Media/Blurhash.php | 2 +- app/Util/Webfinger/WebfingerUrl.php | 2 +- 37 files changed, 48 insertions(+), 48 deletions(-) diff --git a/app/Http/Controllers/AvatarController.php b/app/Http/Controllers/AvatarController.php index f4f30109b..1593ab21a 100644 --- a/app/Http/Controllers/AvatarController.php +++ b/app/Http/Controllers/AvatarController.php @@ -80,7 +80,7 @@ class AvatarController extends Controller } } - public function buildPath($id) + public function buildPath($id): string { $padded = str_pad($id, 19, 0, STR_PAD_LEFT); $parts = str_split($padded, 3); diff --git a/app/Http/Controllers/RemoteOidcController.php b/app/Http/Controllers/RemoteOidcController.php index 2f8228322..f294552dd 100644 --- a/app/Http/Controllers/RemoteOidcController.php +++ b/app/Http/Controllers/RemoteOidcController.php @@ -131,7 +131,7 @@ class RemoteOidcController extends Controller return Auth::guard(); } - private function ensure_valid_username($starting_username) + private function ensure_valid_username($starting_username): string { $starting_username = explode('@', $starting_username)[0]; $temp_username = preg_replace('/[^a-z0-9_]+/i', '', $starting_username); diff --git a/app/Jobs/MovePipeline/ProcessMovePipeline.php b/app/Jobs/MovePipeline/ProcessMovePipeline.php index 83cd050b7..f0c7e3650 100644 --- a/app/Jobs/MovePipeline/ProcessMovePipeline.php +++ b/app/Jobs/MovePipeline/ProcessMovePipeline.php @@ -150,7 +150,7 @@ class ProcessMovePipeline implements ShouldQueue return false; } - protected function lowerTrim($str) + protected function lowerTrim($str): string { return trim(strtolower($str)); } diff --git a/app/Jobs/SharePipeline/SharePipeline.php b/app/Jobs/SharePipeline/SharePipeline.php index 4298331a7..1371d8963 100644 --- a/app/Jobs/SharePipeline/SharePipeline.php +++ b/app/Jobs/SharePipeline/SharePipeline.php @@ -102,7 +102,7 @@ class SharePipeline implements ShouldQueue return $this->remoteAnnounceDeliver(); } - protected function counterGuardKey($statusId) + protected function counterGuardKey($statusId): string { return 'pf:share-pipeline:counted:'.$statusId; } diff --git a/app/Models/Contact.php b/app/Models/Contact.php index 9858f23e5..0d6e680e6 100644 --- a/app/Models/Contact.php +++ b/app/Models/Contact.php @@ -29,7 +29,7 @@ class Contact extends Model return url('/i/contact-admin-response/'.$this->id); } - public function getMessageId() + public function getMessageId(): string { return $this->id.'-'.(string) Str::uuid().'@'.strtolower(config('pixelfed.domain.app', 'example.org')); } diff --git a/app/Models/CustomFilterKeyword.php b/app/Models/CustomFilterKeyword.php index aeac7f0a0..c56fc8e8d 100644 --- a/app/Models/CustomFilterKeyword.php +++ b/app/Models/CustomFilterKeyword.php @@ -26,7 +26,7 @@ class CustomFilterKeyword extends Model $this->attributes['keyword'] = mb_strtolower(trim($value)); } - public function toRegex() + public function toRegex(): string { $pattern = preg_quote($this->keyword, '/'); diff --git a/app/Models/DirectMessage.php b/app/Models/DirectMessage.php index 92bec7c53..30f2fd4dd 100644 --- a/app/Models/DirectMessage.php +++ b/app/Models/DirectMessage.php @@ -13,7 +13,7 @@ class DirectMessage extends Model return $this->belongsTo(Status::class, 'status_id', 'id'); } - public function url() + public function url(): string { return config('app.url').'/account/direct/m/'.$this->status_id; } diff --git a/app/Models/Group.php b/app/Models/Group.php index c7711017f..239a3927d 100644 --- a/app/Models/Group.php +++ b/app/Models/Group.php @@ -72,7 +72,7 @@ class Group extends Model return GroupService::isMember($this->id, $id); } - public function getMembershipType() + public function getMembershipType(): string { return $this->is_private ? 'private' : ($this->is_local ? 'local' : 'all'); } diff --git a/app/Models/GroupComment.php b/app/Models/GroupComment.php index dd5f0b06c..0bd4a987d 100644 --- a/app/Models/GroupComment.php +++ b/app/Models/GroupComment.php @@ -16,7 +16,7 @@ class GroupComment extends Model return $this->belongsTo(Profile::class); } - public function url() + public function url(): string { return '/group/'.$this->group_id.'/c/'.$this->id; } diff --git a/app/Models/GroupPost.php b/app/Models/GroupPost.php index f0ec57e21..35771d5a6 100644 --- a/app/Models/GroupPost.php +++ b/app/Models/GroupPost.php @@ -19,7 +19,7 @@ class GroupPost extends Model protected $guarded = []; - public function mediaPath() + public function mediaPath(): string { return 'public/g/_v1/'.$this->group_id.'/'.$this->id; } @@ -39,7 +39,7 @@ class GroupPost extends Model return $this->belongsTo(Profile::class); } - public function url() + public function url(): string { return '/groups/'.$this->group_id.'/p/'.$this->id; } diff --git a/app/Models/Hashtag.php b/app/Models/Hashtag.php index 936421553..d982d827b 100644 --- a/app/Models/Hashtag.php +++ b/app/Models/Hashtag.php @@ -21,7 +21,7 @@ class Hashtag extends Model ); } - public function url($suffix = '') + public function url($suffix = ''): string { return config('routes.hashtag.base').$this->slug.$suffix; } diff --git a/app/Models/LiveStream.php b/app/Models/LiveStream.php index cba933af8..82f83c27b 100644 --- a/app/Models/LiveStream.php +++ b/app/Models/LiveStream.php @@ -17,7 +17,7 @@ class LiveStream extends Model return url($path); } - public function getStreamServer() + public function getStreamServer(): string { $proto = 'rtmp://'; $host = config('livestreaming.server.host'); @@ -27,7 +27,7 @@ class LiveStream extends Model return $proto.$host.$port.$path; } - public function getStreamKeyUrl() + public function getStreamKeyUrl(): string { $path = $this->getStreamServer().'?'; $query = http_build_query([ @@ -37,7 +37,7 @@ class LiveStream extends Model return $path.$query; } - public function getStreamRtmpUrl() + public function getStreamRtmpUrl(): string { return $this->getStreamServer().'/'.$this->stream_id; } diff --git a/app/Models/Media.php b/app/Models/Media.php index 10da251fa..bfd2847f1 100644 --- a/app/Models/Media.php +++ b/app/Models/Media.php @@ -85,7 +85,7 @@ class Media extends Model return explode('/', $this->mime)[0]; } - public function activityVerb() + public function activityVerb(): string { $verb = 'Document'; switch ($this->mimeType()) { @@ -109,7 +109,7 @@ class Media extends Model return $verb; } - public function mediaType() + public function mediaType(): string { $verb = 'Document'; switch ($this->mimeType()) { diff --git a/app/Models/ModLog.php b/app/Models/ModLog.php index 6553e7092..b095a42f8 100644 --- a/app/Models/ModLog.php +++ b/app/Models/ModLog.php @@ -15,7 +15,7 @@ class ModLog extends Model return $this->belongsTo(User::class, 'user_id'); } - public function actionToText() + public function actionToText(): string { $msg = 'Unknown action'; diff --git a/app/Models/Place.php b/app/Models/Place.php index 07a119cb7..c9dea6b9b 100644 --- a/app/Models/Place.php +++ b/app/Models/Place.php @@ -41,7 +41,7 @@ class Place extends Model return $this->url(); } - public function getName() + public function getName(): string { return $this->name.', '.$this->country; } diff --git a/app/Models/Portfolio.php b/app/Models/Portfolio.php index cf49b04fa..226cb125c 100644 --- a/app/Models/Portfolio.php +++ b/app/Models/Portfolio.php @@ -41,7 +41,7 @@ class Portfolio extends Model return 'https://'.config('portfolio.domain').config('portfolio.path').'/'.$account['username'].$suffix; } - public function permalink($suffix = '') + public function permalink($suffix = ''): string { $account = AccountService::get($this->profile_id); diff --git a/app/Models/Profile.php b/app/Models/Profile.php index cc974cc46..fe9a8b7fd 100644 --- a/app/Models/Profile.php +++ b/app/Models/Profile.php @@ -315,7 +315,7 @@ class Profile extends Model return $this->sharedInbox ?? $this->inboxUrl(); } - public function getDefaultScope() + public function getDefaultScope(): string { return $this->is_private == true ? 'private' : 'public'; } diff --git a/app/Models/Status.php b/app/Models/Status.php index aab0b2174..b41f1c4f4 100644 --- a/app/Models/Status.php +++ b/app/Models/Status.php @@ -178,7 +178,7 @@ class Status extends Model return url($path); } - public function editUrl() + public function editUrl(): string { return $this->url().'/edit'; } @@ -308,7 +308,7 @@ class Status extends Model ); } - public function reportUrl() + public function reportUrl(): string { return route('report.form')."?type=post&id={$this->id}"; } diff --git a/app/Models/User.php b/app/Models/User.php index 6b65ad7e1..11317d09e 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -83,7 +83,7 @@ class User extends Authenticatable implements OAuthenticatable return $this->hasMany(UserFilter::class, 'user_id', 'profile_id'); } - public function receivesBroadcastNotificationsOn() + public function receivesBroadcastNotificationsOn(): string { return 'App.User.'.$this->id; } @@ -93,7 +93,7 @@ class User extends Authenticatable implements OAuthenticatable return $this->hasMany(UserDevice::class); } - public function storageUsedKey() + public function storageUsedKey(): string { return 'profile:storage:used:'.$this->id; } diff --git a/app/Services/AccountService.php b/app/Services/AccountService.php index 8223e2114..0f680b253 100644 --- a/app/Services/AccountService.php +++ b/app/Services/AccountService.php @@ -332,7 +332,7 @@ class AccountService return Profile::whereKey($profileId)->value('user_id'); } - public static function getMetaDescription($id) + public static function getMetaDescription($id): string { $account = self::get($id, true); diff --git a/app/Services/GroupPostService.php b/app/Services/GroupPostService.php index 99b8b498f..ac8e63e5e 100644 --- a/app/Services/GroupPostService.php +++ b/app/Services/GroupPostService.php @@ -13,7 +13,7 @@ class GroupPostService const COMMENT_COUNT_KEY = 'pf:services:groups:post:comment_count:'; - public static function key($gid, $pid) + public static function key($gid, $pid): string { return self::CACHE_KEY.$gid.':'.$pid; } diff --git a/app/Services/GroupService.php b/app/Services/GroupService.php index fa1b1bb1b..3dd418b26 100644 --- a/app/Services/GroupService.php +++ b/app/Services/GroupService.php @@ -18,7 +18,7 @@ class GroupService { const CACHE_KEY = 'pf:services:groups:'; - protected static function key($name) + protected static function key($name): string { return self::CACHE_KEY.$name; } diff --git a/app/Services/Groups/GroupCommentService.php b/app/Services/Groups/GroupCommentService.php index 1feb5974b..4ebc3f13b 100644 --- a/app/Services/Groups/GroupCommentService.php +++ b/app/Services/Groups/GroupCommentService.php @@ -11,7 +11,7 @@ class GroupCommentService { const CACHE_KEY = 'pf:services:groups:comment:'; - public static function key($gid, $pid) + public static function key($gid, $pid): string { return self::CACHE_KEY.$gid.':'.$pid; } diff --git a/app/Services/Groups/GroupPostService.php b/app/Services/Groups/GroupPostService.php index 0880de10b..276c4b430 100644 --- a/app/Services/Groups/GroupPostService.php +++ b/app/Services/Groups/GroupPostService.php @@ -13,7 +13,7 @@ class GroupPostService { const CACHE_KEY = 'pf:services:groups:post:'; - public static function key($gid, $pid) + public static function key($gid, $pid): string { return self::CACHE_KEY.$gid.':'.$pid; } diff --git a/app/Services/Internal/SoftwareUpdateService.php b/app/Services/Internal/SoftwareUpdateService.php index 48dc1e585..2744ca166 100644 --- a/app/Services/Internal/SoftwareUpdateService.php +++ b/app/Services/Internal/SoftwareUpdateService.php @@ -11,7 +11,7 @@ class SoftwareUpdateService { const CACHE_KEY = 'pf:services:software-update:'; - public static function cacheKey() + public static function cacheKey(): string { return self::CACHE_KEY.'latest:v1.0.0'; } @@ -66,7 +66,7 @@ class SoftwareUpdateService ); } - public static function normalizeVersion($version) + public static function normalizeVersion($version): string { return ltrim(trim((string) $version), 'vV'); } diff --git a/app/Services/RelationshipService.php b/app/Services/RelationshipService.php index 25f22f6fe..59d55f2b3 100644 --- a/app/Services/RelationshipService.php +++ b/app/Services/RelationshipService.php @@ -92,7 +92,7 @@ class RelationshipService ]; } - protected static function key($suffix) + protected static function key($suffix): string { return self::CACHE_KEY.$suffix; } diff --git a/app/Services/SanitizeService.php b/app/Services/SanitizeService.php index ac692736e..b3a517daf 100644 --- a/app/Services/SanitizeService.php +++ b/app/Services/SanitizeService.php @@ -18,7 +18,7 @@ class SanitizeService return $this->cleanHtmlWithSpacing($html); } - public function cleanHtmlWithSpacing($html) + public function cleanHtmlWithSpacing($html): string { $blockTags = ['a', 'b', 'blockquote', 'br', 'code', 'del', 'div', 'em', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'i', 'img', 'li', 'ol', 'p', 'pre', 's', 'strike', 'strong', 'u', 'ul']; diff --git a/app/Services/StatusService.php b/app/Services/StatusService.php index 4e6330d57..68833dd6b 100644 --- a/app/Services/StatusService.php +++ b/app/Services/StatusService.php @@ -15,7 +15,7 @@ class StatusService const MAX_PINNED = 3; - public static function key($id, $publicOnly = true) + public static function key($id, $publicOnly = true): string { $p = $publicOnly ? 'pub:' : 'all:'; @@ -199,7 +199,7 @@ class StatusService public static function clampReplyVisibility( $replyVisibility, $parentVisibility - ) { + ): string { if ($parentVisibility === 'group') { return 'group'; } diff --git a/app/Services/TrendingHashtagService.php b/app/Services/TrendingHashtagService.php index 824d19b62..072e0252a 100644 --- a/app/Services/TrendingHashtagService.php +++ b/app/Services/TrendingHashtagService.php @@ -11,7 +11,7 @@ class TrendingHashtagService { const CACHE_KEY = 'api:discover:v1.1:trending:hashtags'; - public static function key($k = null) + public static function key($k = null): string { return self::CACHE_KEY.$k; } diff --git a/app/Transformer/Api/Mastodon/v1/NotificationTransformer.php b/app/Transformer/Api/Mastodon/v1/NotificationTransformer.php index 20f0ab0df..21ec29aff 100644 --- a/app/Transformer/Api/Mastodon/v1/NotificationTransformer.php +++ b/app/Transformer/Api/Mastodon/v1/NotificationTransformer.php @@ -41,7 +41,7 @@ class NotificationTransformer extends Fractal\TransformerAbstract } - public function replaceTypeVerb($verb) + public function replaceTypeVerb($verb): string { $verbs = [ 'dm' => 'direct', diff --git a/app/Util/ActivityPub/Helpers.php b/app/Util/ActivityPub/Helpers.php index ffead3a0f..f04f0f263 100644 --- a/app/Util/ActivityPub/Helpers.php +++ b/app/Util/ActivityPub/Helpers.php @@ -1068,7 +1068,7 @@ class Helpers return self::statusFirstOrFetch($inReplyTo, false, $depth + 1)?->id; } - public static function getScope($activity, $url) + public static function getScope($activity, $url): string { $id = isset($activity['id']) ? self::pluckval($activity['id']) : self::pluckval($url); $url = isset($activity['url']) ? self::pluckval($activity['url']) : self::pluckval($id); diff --git a/app/Util/Lexer/Autolink.php b/app/Util/Lexer/Autolink.php index 3398171ff..a8252928c 100755 --- a/app/Util/Lexer/Autolink.php +++ b/app/Util/Lexer/Autolink.php @@ -429,7 +429,7 @@ class Autolink extends Regex * * @since 1.1.0 */ - public function autoLinkEntities($tweet = null, $entities = null) + public function autoLinkEntities($tweet = null, $entities = null): string { if (is_null($tweet)) { $tweet = $this->tweet; @@ -792,7 +792,7 @@ class Autolink extends Regex * * @since 1.1.0 */ - public function linkToText(array $entity, $text, $attributes = []) + public function linkToText(array $entity, $text, $attributes = []): string { $rel = []; if ($this->external) { @@ -825,7 +825,7 @@ class Autolink extends Regex * @param string $text * @return string */ - protected function escapeHTML($text) + protected function escapeHTML($text): string { return htmlspecialchars($text, ENT_QUOTES, 'UTF-8', false); } diff --git a/app/Util/Lexer/LooseAutolink.php b/app/Util/Lexer/LooseAutolink.php index 966e52d20..0cfd36239 100755 --- a/app/Util/Lexer/LooseAutolink.php +++ b/app/Util/Lexer/LooseAutolink.php @@ -194,7 +194,7 @@ class LooseAutolink extends Autolink * * @deprecated since version 1.1.0 */ - protected function wrap($url, $class, $element) + protected function wrap($url, $class, $element): string { $link = 'mime, ['image/png', 'image/jpeg', 'image/jpg', 'video/mp4'])) { return self::DEFAULT_HASH; diff --git a/app/Util/Webfinger/WebfingerUrl.php b/app/Util/Webfinger/WebfingerUrl.php index a5472d51f..3be620105 100644 --- a/app/Util/Webfinger/WebfingerUrl.php +++ b/app/Util/Webfinger/WebfingerUrl.php @@ -20,7 +20,7 @@ class WebfingerUrl return 'https://'.$n['domain'].'/.well-known/webfinger?resource=acct:'.$n['username'].'@'.$n['domain']; } - public static function generateWebfingerUrl($url) + public static function generateWebfingerUrl($url): string { $url = Nickname::normalizeProfileUrl($url); $domain = $url['domain'];