From 5ebc1af91e96ca065ea55f20e94de5d874a442c8 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 18 Sep 2026 01:56:40 +0930 Subject: [PATCH] BATCH 1 --- app/Auth/AppRegisterGrant.php | 2 +- app/Auth/AppRegisterTokenFactory.php | 2 +- app/Console/Commands/Admin/BackupToCloud.php | 2 +- .../Admin/CuratedOnboardingCommand.php | 2 +- app/Console/Commands/Admin/FixPostCounts.php | 4 ++-- .../Commands/Admin/FixProfileCounts.php | 4 ++-- app/Console/Commands/Admin/ImportCities.php | 2 +- .../Commands/Admin/InstanceManager.php | 8 +++---- .../Commands/Admin/MediaUpdateS3CDNUrl.php | 4 ++-- app/Console/Commands/Dev/ExportLanguages.php | 2 +- .../Commands/FixBugs/AvatarStorage.php | 2 +- .../FixBugs/AvatarStorageDeepClean.php | 20 ++++++---------- .../Commands/FixBugs/FixMediaDriver.php | 2 +- .../Install/GenerateInstanceActor.php | 2 +- app/Console/Commands/Install/Installer.php | 11 +++++---- .../Internal/GarbageCollectorStory.php | 2 +- .../Commands/Internal/WeeklyInstanceScan.php | 2 +- app/Console/Commands/Status/StatusAvatar.php | 2 +- app/Console/Commands/Status/StatusEmoji.php | 2 +- .../Commands/Status/StatusInstance.php | 2 +- app/Console/Commands/Status/StatusProfile.php | 4 ++-- .../Commands/Status/StatusStatuses.php | 2 +- app/Console/Commands/Status/StatusUser.php | 6 ++--- .../Commands/User/AddUserDomainBlock.php | 8 +++---- .../Commands/User/DeleteUserDomainBlock.php | 8 +++---- .../Commands/User/UserAccountDelete.php | 8 +++---- app/Console/Commands/User/UserDelete.php | 2 +- .../User/UserRegistrationMagicLink.php | 10 ++++---- app/Console/Commands/User/UserShow.php | 2 +- app/Console/Commands/User/UserUnsuspend.php | 2 +- .../AccountInterstitialController.php | 2 +- .../Admin/AdminDiscoverController.php | 4 ++-- .../Admin/AdminGroupsController.php | 2 +- .../Admin/AdminHashtagsController.php | 3 ++- .../Admin/AdminMediaController.php | 8 +++---- .../Controllers/Admin/AdminUserController.php | 18 +++++++------- .../Controllers/AdminInviteController.php | 7 +++--- .../Controllers/Api/ApiV1Dot1Controller.php | 4 ++-- app/Http/Controllers/Api/ApiV2Controller.php | 4 ++-- app/Http/Controllers/Auth/LoginController.php | 12 +++++----- app/Http/Controllers/AvatarController.php | 14 +++++------ app/Http/Controllers/BookmarkController.php | 3 +-- app/Http/Controllers/CircleController.php | 4 ++-- app/Http/Controllers/CollectionController.php | 4 ++-- app/Http/Controllers/CommentController.php | 8 +++---- app/Http/Controllers/ComposeController.php | 6 ++--- .../Controllers/CuratedRegisterController.php | 10 ++++---- .../Controllers/DirectMessageController.php | 8 +++---- .../Groups/GroupsCommentController.php | 3 +-- .../Groups/GroupsFeedController.php | 2 +- .../Groups/GroupsTopicController.php | 2 +- app/Http/Controllers/Import/Instagram.php | 24 +++++++++---------- .../Controllers/InternalApiController.php | 10 ++++---- app/Http/Controllers/LandingController.php | 6 ++--- app/Http/Controllers/LikeController.php | 8 +++---- app/Http/Controllers/LiveStreamController.php | 10 ++++---- app/Http/Controllers/NewsroomController.php | 4 ++-- app/Http/Controllers/PageController.php | 4 ++-- .../Controllers/ProfileAliasController.php | 2 +- .../ProfileMigrationController.php | 4 ++-- app/Http/Controllers/SearchController.php | 4 ++-- .../Controllers/Settings/HomeSettings.php | 5 ++-- .../Controllers/Settings/LabsSettings.php | 4 ++-- .../Controllers/Settings/PrivacySettings.php | 16 ++++++------- .../Settings/RelationshipSettings.php | 2 +- .../Controllers/Settings/SecuritySettings.php | 14 +++++------ app/Http/Controllers/StatusController.php | 6 ++--- .../Controllers/StoryComposeController.php | 2 +- app/Http/Controllers/StoryController.php | 4 ++-- app/Http/Controllers/TimelineController.php | 4 ++-- app/Http/Middleware/TwoFactorAuth.php | 5 ++-- app/Jobs/AvatarPipeline/RemoteAvatarFetch.php | 4 ++-- .../RemoteAvatarFetchFromUrl.php | 4 ++-- app/Jobs/CommentPipeline/CommentPipeline.php | 11 +++++---- .../DeleteRemoteProfilePipeline.php | 4 ++-- .../DeleteRemoteStatusPipeline.php | 4 ++-- .../DeletePipeline/FanoutDeletePipeline.php | 4 ++-- .../ImageOptimizePipeline/ImageOptimize.php | 8 +++---- .../ImageOptimizePipeline/ImageUpdate.php | 7 +++--- app/Jobs/ImportPipeline/ImportInstagram.php | 2 +- app/Jobs/InboxPipeline/InboxValidator.php | 17 +++++-------- app/Jobs/InboxPipeline/InboxWorker.php | 7 +++--- .../MediaPipeline/MediaDeletePipeline.php | 2 +- ...MediaFixLocalFilesystemCleanupPipeline.php | 2 +- .../MediaSyncLicensePipeline.php | 1 + .../CleanupLegacyAccountMovePipeline.php | 2 +- .../MoveMigrateFollowersPipeline.php | 2 +- app/Jobs/MovePipeline/ProcessMovePipeline.php | 6 ++--- .../UnfollowLegacyAccountMovePipeline.php | 2 +- app/Jobs/SharePipeline/SharePipeline.php | 11 +++++---- app/Jobs/SharePipeline/UndoSharePipeline.php | 7 +++--- app/Jobs/StatusPipeline/StatusDelete.php | 7 +++--- app/Jobs/StoryPipeline/StoryFetch.php | 7 +++--- app/Jobs/VideoPipeline/VideoHlsPipeline.php | 3 +-- app/Jobs/VideoPipeline/VideoOptimize.php | 3 ++- app/Mail/ContactAdmin.php | 2 +- app/Models/CustomEmoji.php | 18 +++++++------- app/Models/CustomFilter.php | 5 ++-- app/Models/Media.php | 2 +- app/Models/ParentalControls.php | 4 +--- app/Models/Profile.php | 5 ++-- app/Models/Status.php | 21 +++++++--------- app/Observers/UserObserver.php | 2 +- .../CachedPersonalAccessClientRepository.php | 2 +- app/Services/AccountService.php | 15 ++++++------ app/Services/ActivityPubFetchService.php | 2 +- app/Services/ConfigCacheService.php | 3 +-- app/Services/CustomEmojiService.php | 18 +++++--------- app/Services/DeliveryHostService.php | 6 ++--- app/Services/FeaturedCollectionService.php | 4 ++-- app/Services/FetchCacheService.php | 2 +- app/Services/FollowerService.php | 16 +++++-------- app/Services/GroupFeedService.php | 1 + app/Services/GroupService.php | 9 +++---- app/Services/Groups/GroupFeedService.php | 1 + app/Services/Groups/GroupMediaService.php | 2 +- app/Services/HashidService.php | 2 +- app/Services/Internal/BeagleService.php | 8 +++---- app/Services/MediaStorageService.php | 4 ++-- app/Services/ModLogService.php | 3 +-- app/Services/ReblogService.php | 16 +++++-------- app/Services/ResilientMediaStorageService.php | 2 +- app/Services/Status/UpdateStatusService.php | 2 +- app/Services/UserFilterService.php | 4 ++-- app/Services/UserStorageService.php | 2 +- app/Services/WebfingerService.php | 2 +- .../Mastodon/v1/NotificationTransformer.php | 4 +--- app/Util/ActivityPub/Inbox/HandlesCreates.php | 16 ++++++------- app/Util/ActivityPub/Inbox/HandlesUndos.php | 6 ++--- app/Util/Blurhash/Blurhash.php | 2 +- app/Util/Lexer/Autolink.php | 2 +- app/Util/Lexer/Classifier.php | 2 +- app/Util/Lexer/Extractor.php | 8 +++---- app/Util/Lexer/Hashtag.php | 2 +- app/Util/Lexer/HitHighlighter.php | 6 +++-- app/Util/Lexer/LooseAutolink.php | 4 ++-- app/Util/Lexer/Nickname.php | 4 ++-- app/Util/Lexer/PrettyNumber.php | 2 +- app/Util/Lexer/Validator.php | 3 +-- app/Util/Localization/Localization.php | 2 +- app/Util/Sentiment/Bouncer.php | 2 +- 141 files changed, 364 insertions(+), 410 deletions(-) diff --git a/app/Auth/AppRegisterGrant.php b/app/Auth/AppRegisterGrant.php index bd4473e94..e862a8ceb 100644 --- a/app/Auth/AppRegisterGrant.php +++ b/app/Auth/AppRegisterGrant.php @@ -66,7 +66,7 @@ class AppRegisterGrant extends AbstractGrant $refreshToken = $this->issueRefreshToken($accessToken); - if ($refreshToken !== null) { + if ($refreshToken instanceof \League\OAuth2\Server\Entities\RefreshTokenEntityInterface) { $this->getEmitter()->emit( new RequestRefreshTokenEvent(RequestEvent::REFRESH_TOKEN_ISSUED, $request, $refreshToken) ); diff --git a/app/Auth/AppRegisterTokenFactory.php b/app/Auth/AppRegisterTokenFactory.php index 6dd8e3be9..613312612 100644 --- a/app/Auth/AppRegisterTokenFactory.php +++ b/app/Auth/AppRegisterTokenFactory.php @@ -91,7 +91,7 @@ class AppRegisterTokenFactory protected function server(): AuthorizationServer { - if ($this->server) { + if ($this->server instanceof \League\OAuth2\Server\AuthorizationServer) { return $this->server; } diff --git a/app/Console/Commands/Admin/BackupToCloud.php b/app/Console/Commands/Admin/BackupToCloud.php index c19910720..367910e7b 100644 --- a/app/Console/Commands/Admin/BackupToCloud.php +++ b/app/Console/Commands/Admin/BackupToCloud.php @@ -59,7 +59,7 @@ final class BackupToCloud extends Command $newest = $backupDestination->newestBackup(); - if ($newest === null) { + if (!$newest instanceof \Spatie\Backup\BackupDestination\Backup) { $this->error('No backup found to upload.'); return Command::FAILURE; diff --git a/app/Console/Commands/Admin/CuratedOnboardingCommand.php b/app/Console/Commands/Admin/CuratedOnboardingCommand.php index ce2d8ff66..e2e487419 100644 --- a/app/Console/Commands/Admin/CuratedOnboardingCommand.php +++ b/app/Console/Commands/Admin/CuratedOnboardingCommand.php @@ -78,7 +78,7 @@ class CuratedOnboardingCommand extends Command { $id = search( label: 'Search for a username or email', - options: fn (string $value) => strlen($value) > 0 + options: fn (string $value) => $value !== '' ? CuratedRegister::where(function ($query) use ($value) { $query->whereLike('username', "%{$value}%") ->orWhereLike('email', "%{$value}%"); diff --git a/app/Console/Commands/Admin/FixPostCounts.php b/app/Console/Commands/Admin/FixPostCounts.php index 69179ccf2..1e686d94f 100644 --- a/app/Console/Commands/Admin/FixPostCounts.php +++ b/app/Console/Commands/Admin/FixPostCounts.php @@ -171,7 +171,7 @@ class FixPostCounts extends Command { $values = (array) $this->option('active'); - if (empty($values)) { + if ($values === []) { return null; } @@ -223,7 +223,7 @@ class FixPostCounts extends Command $drifted = array_filter($drift, fn ($m) => $m['cached'] !== $m['live']); - if (empty($drifted)) { + if ($drifted === []) { // No drift on the selected metrics: stay silent. return false; } diff --git a/app/Console/Commands/Admin/FixProfileCounts.php b/app/Console/Commands/Admin/FixProfileCounts.php index 15f3b18a7..4a0c8603a 100644 --- a/app/Console/Commands/Admin/FixProfileCounts.php +++ b/app/Console/Commands/Admin/FixProfileCounts.php @@ -178,7 +178,7 @@ class FixProfileCounts extends Command { $values = (array) $this->option('active'); - if (empty($values)) { + if ($values === []) { return null; } @@ -230,7 +230,7 @@ class FixProfileCounts extends Command $drifted = array_filter($drift, fn ($m) => $m['cached'] !== $m['live']); - if (empty($drifted)) { + if ($drifted === []) { // No drift on the selected metrics: stay silent. return false; } diff --git a/app/Console/Commands/Admin/ImportCities.php b/app/Console/Commands/Admin/ImportCities.php index a207c496b..01ac495a7 100644 --- a/app/Console/Commands/Admin/ImportCities.php +++ b/app/Console/Commands/Admin/ImportCities.php @@ -123,7 +123,7 @@ class ImportCities extends Command $count++; - if ($count % $this->argument('chunk') == 0) { + if ($count % $this->argument('chunk') === 0) { $this->insertBuffer($buffer); $bar->advance(count($buffer)); $buffer = []; diff --git a/app/Console/Commands/Admin/InstanceManager.php b/app/Console/Commands/Admin/InstanceManager.php index c4d1a18e7..6bfc29fd8 100644 --- a/app/Console/Commands/Admin/InstanceManager.php +++ b/app/Console/Commands/Admin/InstanceManager.php @@ -96,7 +96,7 @@ class InstanceManager extends Command { $id = search( 'Search by domain', - fn (string $value) => strlen($value) > 0 + fn (string $value) => $value !== '' ? Instance::whereUnlisted(false)->where('domain', 'like', "%{$value}%")->pluck('domain', 'id')->all() : [] ); @@ -136,7 +136,7 @@ class InstanceManager extends Command { $id = search( 'Search by domain', - fn (string $value) => strlen($value) > 0 + fn (string $value) => $value !== '' ? Instance::whereUnlisted(true)->where('domain', 'like', "%{$value}%")->pluck('domain', 'id')->all() : [] ); @@ -176,7 +176,7 @@ class InstanceManager extends Command { $id = search( 'Search by domain', - fn (string $value) => strlen($value) > 0 + fn (string $value) => $value !== '' ? Instance::whereBanned(false)->where('domain', 'like', "%{$value}%")->pluck('domain', 'id')->all() : [] ); @@ -216,7 +216,7 @@ class InstanceManager extends Command { $id = search( 'Search by domain', - fn (string $value) => strlen($value) > 0 + fn (string $value) => $value !== '' ? Instance::whereBanned(true)->where('domain', 'like', "%{$value}%")->pluck('domain', 'id')->all() : [] ); diff --git a/app/Console/Commands/Admin/MediaUpdateS3CDNUrl.php b/app/Console/Commands/Admin/MediaUpdateS3CDNUrl.php index 8eb560c7f..6e6409d7e 100644 --- a/app/Console/Commands/Admin/MediaUpdateS3CDNUrl.php +++ b/app/Console/Commands/Admin/MediaUpdateS3CDNUrl.php @@ -272,7 +272,7 @@ class MediaUpdateS3CDNUrl extends Command $changes[$field] = ['from' => $current, 'to' => $rebuilt]; } - if (empty($changes)) { + if ($changes === []) { return false; } @@ -337,7 +337,7 @@ class MediaUpdateS3CDNUrl extends Command $diskHost = parse_url($url, PHP_URL_HOST); if ($diskHost && strcasecmp($diskHost, $this->newHost) !== 0) { // Override host was requested; swap it into the disk-built URL. - $url = preg_replace('#^(https?://)'.preg_quote($diskHost, '#').'#i', '$1'.$this->newHost, $url); + return preg_replace('#^(https?://)'.preg_quote($diskHost, '#').'#i', '$1'.$this->newHost, $url); } return $url; diff --git a/app/Console/Commands/Dev/ExportLanguages.php b/app/Console/Commands/Dev/ExportLanguages.php index 453b15ccc..7229fe6c4 100644 --- a/app/Console/Commands/Dev/ExportLanguages.php +++ b/app/Console/Commands/Dev/ExportLanguages.php @@ -174,7 +174,7 @@ class ExportLanguages extends Command foreach ($strings as $key => $value) { if (is_array($value)) { $filtered = $this->stripEmptyStrings($value); - if (! empty($filtered)) { + if ($filtered !== []) { $result[$key] = $filtered; } } elseif (is_string($value)) { diff --git a/app/Console/Commands/FixBugs/AvatarStorage.php b/app/Console/Commands/FixBugs/AvatarStorage.php index 3b66e1dc4..54dec3e46 100644 --- a/app/Console/Commands/FixBugs/AvatarStorage.php +++ b/app/Console/Commands/FixBugs/AvatarStorage.php @@ -212,7 +212,7 @@ class AvatarStorage extends Command return; } - if ((bool) config_cache('pixelfed.cloud_storage') == false && config_cache('federation.avatars.store_local') == false) { + if ((bool) config_cache('pixelfed.cloud_storage') === false && config_cache('federation.avatars.store_local') == false) { $this->error('You have cloud storage disabled and local avatar storage disabled, we cannot refetch avatars.'); return; diff --git a/app/Console/Commands/FixBugs/AvatarStorageDeepClean.php b/app/Console/Commands/FixBugs/AvatarStorageDeepClean.php index 4336dfd91..16a25a766 100644 --- a/app/Console/Commands/FixBugs/AvatarStorageDeepClean.php +++ b/app/Console/Commands/FixBugs/AvatarStorageDeepClean.php @@ -66,14 +66,12 @@ class AvatarStorageDeepClean extends Command if (! $this->confirm('Do you want to continue where you left off?')) { $this->error('Aborting...'); exit; - } else { - $start = Cache::has('cmd:asdp') ? (int) Cache::get('cmd:asdp') : (int) Storage::get('avatar-deep-clean.json'); - - if ($start && $start < 1 || $start > PHP_INT_MAX) { - $this->error('Error fetching cached value'); - $this->error('Aborting...'); - exit; - } + } + $start = Cache::has('cmd:asdp') ? (int) Cache::get('cmd:asdp') : (int) Storage::get('avatar-deep-clean.json'); + if ($start && $start < 1 || $start > PHP_INT_MAX) { + $this->error('Error fetching cached value'); + $this->error('Aborting...'); + exit; } } @@ -99,11 +97,7 @@ class AvatarStorageDeepClean extends Command protected function activeCheck() { - if (Storage::exists('avatar-deep-clean.json') || Cache::has('cmd:asdp')) { - return false; - } - - return true; + return !Storage::exists('avatar-deep-clean.json') && !Cache::has('cmd:asdp'); } protected function handleAvatar($avatar) diff --git a/app/Console/Commands/FixBugs/FixMediaDriver.php b/app/Console/Commands/FixBugs/FixMediaDriver.php index 3b2511117..2e99c93d1 100644 --- a/app/Console/Commands/FixBugs/FixMediaDriver.php +++ b/app/Console/Commands/FixBugs/FixMediaDriver.php @@ -38,7 +38,7 @@ class FixMediaDriver extends Command return Command::SUCCESS; } - if ((bool) config_cache('pixelfed.cloud_storage') == false) { + if ((bool) config_cache('pixelfed.cloud_storage') === false) { $this->error('Cloud storage not enabled, exiting...'); return Command::SUCCESS; diff --git a/app/Console/Commands/Install/GenerateInstanceActor.php b/app/Console/Commands/Install/GenerateInstanceActor.php index 807f0f03f..5278205b6 100644 --- a/app/Console/Commands/Install/GenerateInstanceActor.php +++ b/app/Console/Commands/Install/GenerateInstanceActor.php @@ -41,7 +41,7 @@ class GenerateInstanceActor extends Command }); $this->info('Instance actor succesfully generated. You do not need to run this command again.'); - return; + return null; } $pkiConfig = [ diff --git a/app/Console/Commands/Install/Installer.php b/app/Console/Commands/Install/Installer.php index 859745909..00805d99d 100644 --- a/app/Console/Commands/Install/Installer.php +++ b/app/Console/Commands/Install/Installer.php @@ -142,7 +142,7 @@ class Installer extends Command $missing = []; foreach ($extensions as $ext) { - if (extension_loaded($ext) == false) { + if (extension_loaded($ext) === false) { $this->error("- \"{$ext}\" not found"); $missing[] = $ext; } else { @@ -150,7 +150,7 @@ class Installer extends Command } } - if (! empty($missing)) { + if ($missing !== []) { $continue = $this->choice('Some extensions are missing. Do you wish to continue?', ['yes', 'no'], 1); if ($continue === 'no') { $this->info('Exiting Installer.'); @@ -158,6 +158,7 @@ class Installer extends Command return 1; } } + return null; } @@ -179,6 +180,7 @@ class Installer extends Command } else { $this->info('- Found FFmpeg!'); } + return null; } protected function checkOptimiseDependencies() @@ -215,14 +217,13 @@ class Installer extends Command ]; foreach ($paths as $path) { - if (is_writable($path) == false) { + if (is_writable($path) === false) { $this->error('- Invalid permission found! Aborting installation.'); $this->error(' Please make the following path writeable by the web server:'); $this->error(" $path"); exit; - } else { - $this->info("- Found valid permissions for {$path}"); } + $this->info("- Found valid permissions for {$path}"); } } diff --git a/app/Console/Commands/Internal/GarbageCollectorStory.php b/app/Console/Commands/Internal/GarbageCollectorStory.php index 9e481ebb8..e4216d75c 100644 --- a/app/Console/Commands/Internal/GarbageCollectorStory.php +++ b/app/Console/Commands/Internal/GarbageCollectorStory.php @@ -60,7 +60,7 @@ class GarbageCollectorStory extends Command { $queue = StoryService::rotateQueue(); - if (! $queue || count($queue) == 0) { + if (! $queue || count($queue) === 0) { return; } diff --git a/app/Console/Commands/Internal/WeeklyInstanceScan.php b/app/Console/Commands/Internal/WeeklyInstanceScan.php index ff5cafbb5..eaab8e9d5 100644 --- a/app/Console/Commands/Internal/WeeklyInstanceScan.php +++ b/app/Console/Commands/Internal/WeeklyInstanceScan.php @@ -29,7 +29,7 @@ class WeeklyInstanceScan extends Command */ public function handle() { - if ((bool) config_cache('federation.activitypub.enabled') == false) { + if ((bool) config_cache('federation.activitypub.enabled') === false) { return; } diff --git a/app/Console/Commands/Status/StatusAvatar.php b/app/Console/Commands/Status/StatusAvatar.php index 705c1b825..e98169915 100644 --- a/app/Console/Commands/Status/StatusAvatar.php +++ b/app/Console/Commands/Status/StatusAvatar.php @@ -30,7 +30,7 @@ class StatusAvatar extends Command { $avatar = $this->resolve($this->argument('id')); - if (! $avatar) { + if (!$avatar instanceof \App\Models\Avatar) { $this->error('No avatar found for "'.$this->argument('id').'" (tried avatar id then profile_id).'); return self::FAILURE; diff --git a/app/Console/Commands/Status/StatusEmoji.php b/app/Console/Commands/Status/StatusEmoji.php index a0a35900a..792dd5ac7 100644 --- a/app/Console/Commands/Status/StatusEmoji.php +++ b/app/Console/Commands/Status/StatusEmoji.php @@ -29,7 +29,7 @@ class StatusEmoji extends Command { $emoji = $this->resolve($this->argument('id')); - if (! $emoji) { + if (!$emoji instanceof \App\Models\CustomEmoji) { $this->error('No custom emoji found for "'.$this->argument('id').'" (tried id, shortcode, then media filename).'); return self::FAILURE; diff --git a/app/Console/Commands/Status/StatusInstance.php b/app/Console/Commands/Status/StatusInstance.php index e38c43488..10cabe2da 100644 --- a/app/Console/Commands/Status/StatusInstance.php +++ b/app/Console/Commands/Status/StatusInstance.php @@ -27,7 +27,7 @@ class StatusInstance extends Command { $instance = $this->resolve($this->argument('id')); - if (! $instance) { + if (!$instance instanceof \App\Models\Instance) { $this->error('No instance found for "'.$this->argument('id').'".'); return self::FAILURE; diff --git a/app/Console/Commands/Status/StatusProfile.php b/app/Console/Commands/Status/StatusProfile.php index 9049996cb..704aa20b1 100644 --- a/app/Console/Commands/Status/StatusProfile.php +++ b/app/Console/Commands/Status/StatusProfile.php @@ -39,7 +39,7 @@ class StatusProfile extends Command $profile = $this->resolveProfile($id); - if (! $profile) { + if (!$profile instanceof \App\Models\Profile) { $this->error('No profile found for "'.$id.'".'); $this->suggestSimilar($id); @@ -272,7 +272,7 @@ class StatusProfile extends Command $problems[] = 'followers_count ('.$cached.') out of sync with live count ('.$live.').'; } - if ($problems) { + if ($problems !== []) { $this->error('ISSUES:'); foreach ($problems as $p) { $this->line(' ✗ '.$p); diff --git a/app/Console/Commands/Status/StatusStatuses.php b/app/Console/Commands/Status/StatusStatuses.php index af41774ed..6ebfa9a34 100644 --- a/app/Console/Commands/Status/StatusStatuses.php +++ b/app/Console/Commands/Status/StatusStatuses.php @@ -216,7 +216,7 @@ class StatusStatuses extends Command } } - if ($stale) { + if ($stale !== []) { $this->error('STALE MEDIA URLS DETECTED:'); foreach ($stale as $s) { $this->line(' ✗ '.$s); diff --git a/app/Console/Commands/Status/StatusUser.php b/app/Console/Commands/Status/StatusUser.php index 7236a863d..841d23ef5 100644 --- a/app/Console/Commands/Status/StatusUser.php +++ b/app/Console/Commands/Status/StatusUser.php @@ -178,7 +178,7 @@ class StatusUser extends Command $problems[] = 'profile_id is EMPTY (user has no linked profile — avatarUrl/profile routes will misbehave)'; } - if ($problems) { + if ($problems !== []) { $this->error('POTENTIAL LOGIN / RESET BLOCKERS:'); foreach ($problems as $p) { $this->line(' ✗ '.$p); @@ -187,7 +187,7 @@ class StatusUser extends Command $this->info('No obvious auth blockers detected on the user row.'); } - if ($ok) { + if ($ok !== []) { $this->newLine(); $this->comment('OK checks:'); foreach ($ok as $o) { @@ -288,7 +288,7 @@ class StatusUser extends Command $problems[] = 'followers_count ('.$cachedFollowers.') is out of sync with live count ('.$liveFollowers.').'; } - if ($problems) { + if ($problems !== []) { $this->newLine(); $this->error('PROFILE ISSUES:'); foreach ($problems as $p) { diff --git a/app/Console/Commands/User/AddUserDomainBlock.php b/app/Console/Commands/User/AddUserDomainBlock.php index ed1bcd2f2..8f0a25747 100644 --- a/app/Console/Commands/User/AddUserDomainBlock.php +++ b/app/Console/Commands/User/AddUserDomainBlock.php @@ -47,7 +47,7 @@ class AddUserDomainBlock extends Command protected function validateDomain($domain) { if (! strpos($domain, '.')) { - return; + return null; } if (str_starts_with($domain, 'https://')) { @@ -62,18 +62,18 @@ class AddUserDomainBlock extends Command $valid = filter_var($domain, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME | FILTER_NULL_ON_FAILURE); if (! $valid) { - return; + return null; } if ($domain === config('pixelfed.domain.app')) { $this->error('Invalid domain'); - return; + return null; } $confirmed = confirm('Are you sure you want to block '.$domain.'?'); if (! $confirmed) { - return; + return null; } return $domain; diff --git a/app/Console/Commands/User/DeleteUserDomainBlock.php b/app/Console/Commands/User/DeleteUserDomainBlock.php index 566d80edb..f6eb56742 100644 --- a/app/Console/Commands/User/DeleteUserDomainBlock.php +++ b/app/Console/Commands/User/DeleteUserDomainBlock.php @@ -46,7 +46,7 @@ class DeleteUserDomainBlock extends Command protected function validateDomain($domain) { if (! strpos($domain, '.')) { - return; + return null; } if (str_starts_with($domain, 'https://')) { @@ -61,16 +61,16 @@ class DeleteUserDomainBlock extends Command $valid = filter_var($domain, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME | FILTER_NULL_ON_FAILURE); if (! $valid) { - return; + return null; } if ($domain === config('pixelfed.domain.app')) { - return; + return null; } $confirmed = confirm('Are you sure you want to unblock '.$domain.'?'); if (! $confirmed) { - return; + return null; } return $domain; diff --git a/app/Console/Commands/User/UserAccountDelete.php b/app/Console/Commands/User/UserAccountDelete.php index 8eca886d9..e13d34473 100644 --- a/app/Console/Commands/User/UserAccountDelete.php +++ b/app/Console/Commands/User/UserAccountDelete.php @@ -34,7 +34,7 @@ class UserAccountDelete extends Command public function handle(): int { $user = $this->promptForDeletedUser(); - if (! $user) { + if (!$user instanceof \App\Models\User) { $this->error('No deleted user selected.'); return self::FAILURE; @@ -115,7 +115,7 @@ class UserAccountDelete extends Command config('app.url').'/inbox', $digest, ); - if (empty($testHeaders) || ! isset($testHeaders['Signature'])) { + if ($testHeaders === [] || ! isset($testHeaders['Signature'])) { $this->error('Instance actor signing failed — run php artisan instance:actor'); return self::FAILURE; @@ -242,14 +242,14 @@ class UserAccountDelete extends Command { $id = search( label: 'Search for the account to delete by username', - placeholder: 'john.appleseed', - options: fn (string $value) => strlen($value) > 0 + options: fn (string $value) => $value !== '' ? User::withTrashed() ->whereIn('status', ['deleted', 'delete']) ->where('username', 'like', "%{$value}%") ->pluck('username', 'id') ->all() : [], + placeholder: 'john.appleseed', ); return User::withTrashed()->find($id); diff --git a/app/Console/Commands/User/UserDelete.php b/app/Console/Commands/User/UserDelete.php index 2e5512f20..a30a78d14 100644 --- a/app/Console/Commands/User/UserDelete.php +++ b/app/Console/Commands/User/UserDelete.php @@ -85,7 +85,7 @@ class UserDelete extends Command implements PromptsForMissingInput return; - if (ctype_digit($id) == true) { + if (ctype_digit($id) === true) { $user = User::find($id); } else { $user = User::whereUsername($id)->first(); diff --git a/app/Console/Commands/User/UserRegistrationMagicLink.php b/app/Console/Commands/User/UserRegistrationMagicLink.php index 7215c0805..7f74caaf5 100644 --- a/app/Console/Commands/User/UserRegistrationMagicLink.php +++ b/app/Console/Commands/User/UserRegistrationMagicLink.php @@ -38,7 +38,7 @@ class UserRegistrationMagicLink extends Command $this->info('php artisan user:app-magic-link --username=dansup'); $this->info('php artisan user:app-magic-link --email=dansup@pixelfed.com'); - return; + return null; } $user = User::when($username, function ($q, $username) { return $q->whereUsername($username); @@ -51,19 +51,19 @@ class UserRegistrationMagicLink extends Command if (! $user) { $this->error('We cannot find any matching accounts'); - return; + return null; } if ($user->email_verified_at) { $this->error('User already verified email address'); - return; + return null; } if (! $user->register_source || $user->register_source !== 'app' || ! $user->app_register_token) { $this->error('User did not register via app'); - return; + return null; } $verify = EmailVerification::whereUserId($user->id)->first(); @@ -71,7 +71,7 @@ class UserRegistrationMagicLink extends Command if (! $verify) { $this->error('Cannot find user verification codes'); - return; + return null; } $appUrl = 'pixelfed://confirm-account/'.$user->app_register_token.'?rt='.$verify->random_token; diff --git a/app/Console/Commands/User/UserShow.php b/app/Console/Commands/User/UserShow.php index 1a9624ca2..91e6088a7 100644 --- a/app/Console/Commands/User/UserShow.php +++ b/app/Console/Commands/User/UserShow.php @@ -39,7 +39,7 @@ class UserShow extends Command public function handle() { $id = $this->argument('id'); - if (ctype_digit($id) == true) { + if (ctype_digit($id) === true) { $user = User::find($id); } else { $user = User::whereUsername($id)->first(); diff --git a/app/Console/Commands/User/UserUnsuspend.php b/app/Console/Commands/User/UserUnsuspend.php index 5b8ba16d2..d37c42723 100644 --- a/app/Console/Commands/User/UserUnsuspend.php +++ b/app/Console/Commands/User/UserUnsuspend.php @@ -39,7 +39,7 @@ class UserUnsuspend extends Command public function handle() { $id = $this->argument('id'); - if (ctype_digit($id) == true) { + if (ctype_digit($id) === true) { $user = User::find($id); } else { $user = User::whereUsername($id)->first(); diff --git a/app/Http/Controllers/AccountInterstitialController.php b/app/Http/Controllers/AccountInterstitialController.php index 32020fc7b..2d6c90615 100644 --- a/app/Http/Controllers/AccountInterstitialController.php +++ b/app/Http/Controllers/AccountInterstitialController.php @@ -33,7 +33,7 @@ class AccountInterstitialController extends Controller $meta = json_decode($interstitial->meta); $view = $interstitial->view; - return view($view, compact('interstitial', 'meta')); + return view($view, ['interstitial' => $interstitial, 'meta' => $meta]); } public function read(Request $request): RedirectResponse diff --git a/app/Http/Controllers/Admin/AdminDiscoverController.php b/app/Http/Controllers/Admin/AdminDiscoverController.php index 41e5999b5..271a121af 100644 --- a/app/Http/Controllers/Admin/AdminDiscoverController.php +++ b/app/Http/Controllers/Admin/AdminDiscoverController.php @@ -15,7 +15,7 @@ trait AdminDiscoverController { $categories = DiscoverCategory::orderByDesc('id')->paginate(10); - return view('admin.discover.home', compact('categories')); + return view('admin.discover.home', ['categories' => $categories]); } public function discoverCreateCategory() @@ -51,7 +51,7 @@ trait AdminDiscoverController { $category = DiscoverCategory::findOrFail($id); - return view('admin.discover.show', compact('category')); + return view('admin.discover.show', ['category' => $category]); } public function discoverCategoryUpdate(Request $request, $id) diff --git a/app/Http/Controllers/Admin/AdminGroupsController.php b/app/Http/Controllers/Admin/AdminGroupsController.php index 76d994713..a3215d61f 100644 --- a/app/Http/Controllers/Admin/AdminGroupsController.php +++ b/app/Http/Controllers/Admin/AdminGroupsController.php @@ -17,7 +17,7 @@ trait AdminGroupsController { $stats = $this->groupAdminStats(); - return view('admin.groups.home', compact('stats')); + return view('admin.groups.home', ['stats' => $stats]); } protected function groupAdminStats() diff --git a/app/Http/Controllers/Admin/AdminHashtagsController.php b/app/Http/Controllers/Admin/AdminHashtagsController.php index fe7cddea1..4bd8907db 100644 --- a/app/Http/Controllers/Admin/AdminHashtagsController.php +++ b/app/Http/Controllers/Admin/AdminHashtagsController.php @@ -38,7 +38,8 @@ trait AdminHashtagsController ->when($action, function ($q, $action) { if ($action === 'banned') { return $q->whereIsBanned(true); - } elseif ($action === 'nsfw') { + } + if ($action === 'nsfw') { return $q->whereIsNsfw(true); } }) diff --git a/app/Http/Controllers/Admin/AdminMediaController.php b/app/Http/Controllers/Admin/AdminMediaController.php index b94645c02..8a3292b14 100644 --- a/app/Http/Controllers/Admin/AdminMediaController.php +++ b/app/Http/Controllers/Admin/AdminMediaController.php @@ -32,24 +32,24 @@ trait AdminMediaController ->orWhere('mime', $request->input('search')) ->paginate(12); - return view('admin.media.home', compact('media')); + return view('admin.media.home', ['media' => $media]); } if ($request->input('layout') == 'banned') { $media = MediaBlocklist::latest()->paginate(12); - return view('admin.media.home', compact('media')); + return view('admin.media.home', ['media' => $media]); } $media = Media::whereNull('remote_url')->orderby('id', 'desc')->simplePaginate(12); - return view('admin.media.home', compact('media')); + return view('admin.media.home', ['media' => $media]); } public function mediaShow(Request $request, $id) { $media = Media::findOrFail($id); - return view('admin.media.show', compact('media')); + return view('admin.media.show', ['media' => $media]); } } diff --git a/app/Http/Controllers/Admin/AdminUserController.php b/app/Http/Controllers/Admin/AdminUserController.php index a4394f17c..2a7c427e0 100644 --- a/app/Http/Controllers/Admin/AdminUserController.php +++ b/app/Http/Controllers/Admin/AdminUserController.php @@ -71,7 +71,7 @@ trait AdminUserController return $u; }); - return view('admin.users.home', compact('users', 'pagination', 'search', 'col', 'dir', 'limit', 'trashed')); + return view('admin.users.home', ['users' => $users, 'pagination' => $pagination, 'search' => $search, 'col' => $col, 'dir' => $dir, 'limit' => $limit, 'trashed' => $trashed]); } public function userShow(Request $request, $id) @@ -79,7 +79,7 @@ trait AdminUserController $user = User::findOrFail($id); $profile = $user->profile; - return view('admin.users.show', compact('user', 'profile')); + return view('admin.users.show', ['user' => $user, 'profile' => $profile]); } public function userEdit(Request $request, $id) @@ -87,7 +87,7 @@ trait AdminUserController $user = User::findOrFail($id); $profile = $user->profile; - return view('admin.users.edit', compact('user', 'profile')); + return view('admin.users.edit', ['user' => $user, 'profile' => $profile]); } public function userEditSubmit(Request $request, $id) @@ -130,7 +130,7 @@ trait AdminUserController $changed = true; } - if ($changed == true) { + if ($changed === true) { ModLogService::boot() ->objectUid($user->id) ->objectId($user->id) @@ -155,7 +155,7 @@ trait AdminUserController $profile = $user->profile; $logs = $user->accountLog()->orderByDesc('created_at')->paginate(10); - return view('admin.users.activity', compact('user', 'profile', 'logs')); + return view('admin.users.activity', ['user' => $user, 'profile' => $profile, 'logs' => $logs]); } public function userMessage(Request $request, $id) @@ -163,7 +163,7 @@ trait AdminUserController $user = User::findOrFail($id); $profile = $user->profile; - return view('admin.users.message', compact('user', 'profile')); + return view('admin.users.message', ['user' => $user, 'profile' => $profile]); } public function userMessageSend(Request $request, $id) @@ -195,7 +195,7 @@ trait AdminUserController $user = User::findOrFail($id); $profile = $user->profile; - return view('admin.users.modtools', compact('user', 'profile')); + return view('admin.users.modtools', ['user' => $user, 'profile' => $profile]); } public function userModLogs(Request $request, $id) @@ -206,7 +206,7 @@ trait AdminUserController ->orderByDesc('created_at') ->simplePaginate(10); - return view('admin.users.modlogs', compact('user', 'profile', 'logs')); + return view('admin.users.modlogs', ['user' => $user, 'profile' => $profile, 'logs' => $logs]); } public function userModLogsMessage(Request $request, $id) @@ -234,7 +234,7 @@ trait AdminUserController $user = User::findOrFail($id); $profile = $user->profile; - return view('admin.users.delete', compact('user', 'profile')); + return view('admin.users.delete', ['user' => $user, 'profile' => $profile]); } public function userDeleteProcess(Request $request, $id) diff --git a/app/Http/Controllers/AdminInviteController.php b/app/Http/Controllers/AdminInviteController.php index 01c739509..b5ca76ee8 100644 --- a/app/Http/Controllers/AdminInviteController.php +++ b/app/Http/Controllers/AdminInviteController.php @@ -30,7 +30,7 @@ class AdminInviteController extends Controller return redirect('/'); } - return view('invite.admin_invite', compact('code')); + return view('invite.admin_invite', ['code' => $code]); } public function apiVerifyCheck(Request $request): JsonResponse @@ -151,7 +151,7 @@ class AdminInviteController extends Controller abort_if($invite->expires_at && $invite->expires_at->lt(now()), 400, 'Invite expired'); abort_if($invite->max_uses && $invite->uses >= $invite->max_uses, 400, 'Maximum invites reached.'); - $invite->uses = $invite->uses + 1; + $invite->uses += 1; event(new Registered($user = User::create([ 'name' => Purify::clean($request->input('name')) ?? $request->input('username'), @@ -182,8 +182,7 @@ class AdminInviteController extends Controller $request->session()->regenerate(); return redirect()->intended('/'); - } else { - return response()->json([], 400); } + return response()->json([], 400); } } diff --git a/app/Http/Controllers/Api/ApiV1Dot1Controller.php b/app/Http/Controllers/Api/ApiV1Dot1Controller.php index ed1cca676..56b768af5 100644 --- a/app/Http/Controllers/Api/ApiV1Dot1Controller.php +++ b/app/Http/Controllers/Api/ApiV1Dot1Controller.php @@ -1339,7 +1339,7 @@ class ApiV1Dot1Controller extends Controller abort_if($accountSize === -1, 403, 'Invalid request.'); $updatedAccountSize = (int) $accountSize + (int) $sizeInKbs; - if ((bool) config_cache('pixelfed.enforce_account_limit') == true) { + if ((bool) config_cache('pixelfed.enforce_account_limit') === true) { $limit = (int) config_cache('pixelfed.max_account_size'); if ($updatedAccountSize >= $limit) { abort(403, 'Account size limit reached.'); @@ -1347,7 +1347,7 @@ class ApiV1Dot1Controller extends Controller } $mimes = explode(',', config_cache('pixelfed.media_types')); - if (in_array($photo->getMimeType(), $mimes) == false) { + if (in_array($photo->getMimeType(), $mimes) === false) { abort(403, 'Invalid or unsupported mime type.'); } diff --git a/app/Http/Controllers/Api/ApiV2Controller.php b/app/Http/Controllers/Api/ApiV2Controller.php index 57fb34865..f97b1f351 100644 --- a/app/Http/Controllers/Api/ApiV2Controller.php +++ b/app/Http/Controllers/Api/ApiV2Controller.php @@ -253,7 +253,7 @@ class ApiV2Controller extends Controller $sizeInKbs = (int) ceil($fileSize / 1000); $updatedAccountSize = (int) $accountSize + (int) $sizeInKbs; - if ((bool) config_cache('pixelfed.enforce_account_limit') == true) { + if ((bool) config_cache('pixelfed.enforce_account_limit') === true) { $limit = (int) config_cache('pixelfed.max_account_size'); if ($updatedAccountSize >= $limit) { abort(403, 'Account size limit reached.'); @@ -264,7 +264,7 @@ class ApiV2Controller extends Controller $filterName = in_array($request->input('filter_name'), Filter::names()) ? $request->input('filter_name') : null; $mimes = explode(',', config_cache('pixelfed.media_types')); - if (in_array($photo->getMimeType(), $mimes) == false) { + if (in_array($photo->getMimeType(), $mimes) === false) { abort(403, 'Invalid or unsupported mime type.'); } diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 35a55d18e..350629b70 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -76,7 +76,7 @@ class LoginController extends Controller $user = PendingLoginService::user($request); - if (! $user) { + if (!$user instanceof \App\Models\User) { return redirect()->route('login'); } @@ -151,7 +151,7 @@ class LoginController extends Controller $user = $this->pendingUser($request, PendingLoginService::STEP_2FA); - if (! $user) { + if (!$user instanceof \App\Models\User) { return $this->redirectToPendingStep($request); } @@ -206,7 +206,7 @@ class LoginController extends Controller { $user = $this->pendingUser($request, PendingLoginService::STEP_VERIFY); - if (! $user) { + if (!$user instanceof \App\Models\User) { return $this->redirectToPendingStep($request); } @@ -231,7 +231,7 @@ class LoginController extends Controller { $user = $this->pendingUser($request, PendingLoginService::STEP_VERIFY); - if (! $user) { + if (!$user instanceof \App\Models\User) { return $this->redirectToPendingStep($request); } @@ -267,7 +267,7 @@ class LoginController extends Controller { $user = $this->pendingUser($request, PendingLoginService::STEP_VERIFY); - if (! $user) { + if (!$user instanceof \App\Models\User) { return $this->redirectToPendingStep($request); } @@ -327,7 +327,7 @@ class LoginController extends Controller $randomToken ); - if (! $user) { + if (!$user instanceof \App\Models\User) { if ($request->user() !== null) { return redirect($this->redirectPath()); } diff --git a/app/Http/Controllers/AvatarController.php b/app/Http/Controllers/AvatarController.php index c3dbc502e..42e5d2f9c 100644 --- a/app/Http/Controllers/AvatarController.php +++ b/app/Http/Controllers/AvatarController.php @@ -85,34 +85,34 @@ class AvatarController extends Controller $padded = str_pad($id, 19, 0, STR_PAD_LEFT); $parts = str_split($padded, 3); foreach ($parts as $k => $part) { - if ($k == 0) { + if ($k === 0) { $prefix = storage_path('app/public/avatars/'.$parts[0]); $this->checkDir($prefix); } - if ($k == 1) { + if ($k === 1) { $prefix = storage_path('app/public/avatars/'.$parts[0].'/'.$parts[1]); $this->checkDir($prefix); } - if ($k == 2) { + if ($k === 2) { $prefix = storage_path('app/public/avatars/'.$parts[0].'/'.$parts[1].'/'.$parts[2]); $this->checkDir($prefix); } - if ($k == 3) { + if ($k === 3) { $avatarpath = 'public/avatars/'.$parts[0].'/'.$parts[1].'/'.$parts[2].'/'.$parts[3]; $prefix = storage_path('app/'.$avatarpath); $this->checkDir($prefix); } - if ($k == 4) { + if ($k === 4) { $avatarpath = 'public/avatars/'.$parts[0].'/'.$parts[1].'/'.$parts[2].'/'.$parts[3].'/'.$parts[4]; $prefix = storage_path('app/'.$avatarpath); $this->checkDir($prefix); } - if ($k == 5) { + if ($k === 5) { $avatarpath = 'public/avatars/'.$parts[0].'/'.$parts[1].'/'.$parts[2].'/'.$parts[3].'/'.$parts[4].'/'.$parts[5]; $prefix = storage_path('app/'.$avatarpath); $this->checkDir($prefix); } - if ($k == 6) { + if ($k === 6) { $avatarpath = 'public/avatars/'.$parts[0].'/'.$parts[1].'/'.$parts[2].'/'.$parts[3].'/'.$parts[4].'/'.$parts[5].'/'.$parts[6]; $prefix = storage_path('app/'.$avatarpath); $this->checkDir($prefix); diff --git a/app/Http/Controllers/BookmarkController.php b/app/Http/Controllers/BookmarkController.php index 18f70770c..1a9de6a07 100644 --- a/app/Http/Controllers/BookmarkController.php +++ b/app/Http/Controllers/BookmarkController.php @@ -40,9 +40,8 @@ class BookmarkController extends Controller if ($request->ajax()) { return ['code' => 200, 'msg' => 'Bookmark removed!']; - } else { - return redirect()->back(); } + return redirect()->back(); } abort(404, 'Error: You cannot bookmark private posts from accounts you do not follow.'); } diff --git a/app/Http/Controllers/CircleController.php b/app/Http/Controllers/CircleController.php index a3985aeef..86efc2601 100644 --- a/app/Http/Controllers/CircleController.php +++ b/app/Http/Controllers/CircleController.php @@ -21,7 +21,7 @@ class CircleController extends Controller ->orderByDesc('created_at') ->paginate(10); - return view('account.circles.home', compact('circles')); + return view('account.circles.home', ['circles' => $circles]); } public function create(Request $request): View @@ -62,6 +62,6 @@ class CircleController extends Controller { $circle = Circle::findOrFail($id); - return view('account.circles.show', compact('circle')); + return view('account.circles.show', ['circle' => $circle]); } } diff --git a/app/Http/Controllers/CollectionController.php b/app/Http/Controllers/CollectionController.php index 1b66c8aa4..8a86cd015 100644 --- a/app/Http/Controllers/CollectionController.php +++ b/app/Http/Controllers/CollectionController.php @@ -26,7 +26,7 @@ class CollectionController extends Controller $collection->visibility = 'draft'; $collection->save(); - return view('collection.create', compact('collection')); + return view('collection.create', ['collection' => $collection]); } public function show(Request $request, $id): View @@ -44,7 +44,7 @@ class CollectionController extends Controller } } - return view('collection.show', compact('collection')); + return view('collection.show', ['collection' => $collection]); } public function store(Request $request, $id) diff --git a/app/Http/Controllers/CommentController.php b/app/Http/Controllers/CommentController.php index 1c622c285..85d4d3c9c 100644 --- a/app/Http/Controllers/CommentController.php +++ b/app/Http/Controllers/CommentController.php @@ -55,7 +55,7 @@ class CommentController extends Controller ->exists(); if ($filtered == true) { - return; + return null; } $reply = DB::transaction(function () use ($comment, $status, $profile, $nsfw) { @@ -98,7 +98,7 @@ class CommentController extends Controller $fractal->setSerializer(new ArraySerializer); $entity = new Fractal\Resource\Item($reply, new StatusTransformer); $entity = $fractal->createData($entity)->toArray(); - $response = [ + return [ 'code' => 200, 'msg' => 'Comment saved', 'username' => $profile->username, @@ -107,10 +107,8 @@ class CommentController extends Controller 'comment' => $reply->caption, 'entity' => $entity, ]; - } else { - $response = redirect($status->url()); } - return $response; + return redirect($status->url()); } } diff --git a/app/Http/Controllers/ComposeController.php b/app/Http/Controllers/ComposeController.php index a477ae34c..fea8ea68d 100644 --- a/app/Http/Controllers/ComposeController.php +++ b/app/Http/Controllers/ComposeController.php @@ -96,7 +96,7 @@ class ComposeController extends Controller $sizeInKbs = (int) ceil($fileSize / 1000); $updatedAccountSize = (int) $accountSize + (int) $sizeInKbs; - if ((bool) config_cache('pixelfed.enforce_account_limit') == true) { + if ((bool) config_cache('pixelfed.enforce_account_limit') === true) { $limit = (int) config_cache('pixelfed.max_account_size'); if ($updatedAccountSize >= $limit) { abort(403, 'Account size limit reached.'); @@ -105,7 +105,7 @@ class ComposeController extends Controller $mimes = explode(',', config_cache('pixelfed.media_types')); - abort_if(in_array($photo->getMimeType(), $mimes) == false, 400, 'Invalid media format'); + abort_if(in_array($photo->getMimeType(), $mimes) === false, 400, 'Invalid media format'); // Check the blocklist against the temp upload BEFORE storing, so a // blocked upload never leaves an orphaned file on disk (media:gc only @@ -607,7 +607,7 @@ class ComposeController extends Controller $mediaType = StatusController::mimeTypeCheck($mimes); - if (in_array($mediaType, ['photo', 'video', 'photo:album']) == false) { + if (in_array($mediaType, ['photo', 'video', 'photo:album']) === false) { abort(400, __('exception.compose.invalid.album')); } diff --git a/app/Http/Controllers/CuratedRegisterController.php b/app/Http/Controllers/CuratedRegisterController.php index 6a2d3232b..0b08835fe 100644 --- a/app/Http/Controllers/CuratedRegisterController.php +++ b/app/Http/Controllers/CuratedRegisterController.php @@ -58,7 +58,7 @@ class CuratedRegisterController extends Controller $request->has('next') && $request->session()->has('cur-reg-con.cr-id'); - return view('auth.curated-register.concierge', compact('emailConfirmed')); + return view('auth.curated-register.concierge', ['emailConfirmed' => $emailConfirmed]); } public function conciergeResponseSent(Request $request): View @@ -88,7 +88,7 @@ class CuratedRegisterController extends Controller } $activity = CuratedRegisterActivity::whereRegisterId($crid)->whereFromAdmin(true)->findOrFail($arid); - return view('auth.curated-register.concierge_form', compact('activity', 'showCaptcha')); + return view('auth.curated-register.concierge_form', ['activity' => $activity, 'showCaptcha' => $showCaptcha]); } public function conciergeFormStore(Request $request): RedirectResponse|View @@ -335,14 +335,14 @@ class CuratedRegisterController extends Controller $step = 2; $request->session()->put('cur-step', 1); - return view('auth.curated-register.index', compact('step')); + return view('auth.curated-register.index', ['step' => $step]); case 2: $this->stepTwo($request); $step = 3; $request->session()->put('cur-step', 2); - return view('auth.curated-register.index', compact('step')); + return view('auth.curated-register.index', ['step' => $step]); case 3: $this->stepThree($request); @@ -351,7 +351,7 @@ class CuratedRegisterController extends Controller $verifiedEmail = true; $request->session()->pull('cur-reg'); - return view('auth.curated-register.index', compact('step', 'verifiedEmail')); + return view('auth.curated-register.index', ['step' => $step, 'verifiedEmail' => $verifiedEmail]); default: return redirect(route('help.email-confirmation-issues')); diff --git a/app/Http/Controllers/DirectMessageController.php b/app/Http/Controllers/DirectMessageController.php index f1120310a..222d3c77b 100644 --- a/app/Http/Controllers/DirectMessageController.php +++ b/app/Http/Controllers/DirectMessageController.php @@ -214,7 +214,7 @@ class DirectMessageController extends Controller ->whereFilterType('dm.mute') ->exists(); - if ($recipient->domain == null && $hidden == false && ! $nf) { + if ($recipient->domain == null && $hidden === false && ! $nf) { NotificationService::createNotification($recipient->id, $profile->id, 'dm', $dm->id, DirectMessage::class); } @@ -463,7 +463,7 @@ class DirectMessageController extends Controller $sizeInKbs = (int) ceil($fileSize / 1000); $updatedAccountSize = (int) $accountSize + (int) $sizeInKbs; - if ((bool) config_cache('pixelfed.enforce_account_limit') == true) { + if ((bool) config_cache('pixelfed.enforce_account_limit') === true) { $limit = (int) config_cache('pixelfed.max_account_size'); if ($updatedAccountSize >= $limit) { abort(403, 'Account size limit reached.'); @@ -471,7 +471,7 @@ class DirectMessageController extends Controller } $mimes = explode(',', config_cache('pixelfed.media_types')); - if (in_array($photo->getMimeType(), $mimes) == false) { + if (in_array($photo->getMimeType(), $mimes) === false) { abort(403, 'Invalid or unsupported mime type.'); } @@ -567,7 +567,7 @@ class DirectMessageController extends Controller if (strlen($q) < 3) { return []; } - if (substr_count($q, '@') == 2) { + if (substr_count($q, '@') === 2) { WebfingerService::lookup($q); } $q = mb_substr($q, 1); diff --git a/app/Http/Controllers/Groups/GroupsCommentController.php b/app/Http/Controllers/Groups/GroupsCommentController.php index 722cac11a..4dd6a4947 100644 --- a/app/Http/Controllers/Groups/GroupsCommentController.php +++ b/app/Http/Controllers/Groups/GroupsCommentController.php @@ -271,9 +271,8 @@ class GroupsCommentController extends Controller if ($request->wantsJson()) { return response()->json(['Status successfully deleted.']); - } else { - return redirect('/groups/feed'); } + return redirect('/groups/feed'); } public function likePost(Request $request) diff --git a/app/Http/Controllers/Groups/GroupsFeedController.php b/app/Http/Controllers/Groups/GroupsFeedController.php index 05ac59f54..f94e6d1d1 100644 --- a/app/Http/Controllers/Groups/GroupsFeedController.php +++ b/app/Http/Controllers/Groups/GroupsFeedController.php @@ -176,7 +176,7 @@ class GroupsFeedController extends Controller return $status; }) ->filter(function ($s) use ($filtered) { - return $s && in_array($s['account']['id'], $filtered) == false; + return $s && in_array($s['account']['id'], $filtered) === false; }) ->values() ->toArray(); diff --git a/app/Http/Controllers/Groups/GroupsTopicController.php b/app/Http/Controllers/Groups/GroupsTopicController.php index 4bbc2b92b..37a02f5f7 100644 --- a/app/Http/Controllers/Groups/GroupsTopicController.php +++ b/app/Http/Controllers/Groups/GroupsTopicController.php @@ -124,6 +124,6 @@ class GroupsTopicController extends Controller $gid = $group->id; abort_if(! $group->isMember($pid), 403, 'Not a member of group.'); - return view('groups.topic-feed', compact('gid', 'tag')); + return view('groups.topic-feed', ['gid' => $gid, 'tag' => $tag]); } } diff --git a/app/Http/Controllers/Import/Instagram.php b/app/Http/Controllers/Import/Instagram.php index 9cc9a7d6e..aa8c730ed 100644 --- a/app/Http/Controllers/Import/Instagram.php +++ b/app/Http/Controllers/Import/Instagram.php @@ -14,7 +14,7 @@ trait Instagram { public function instagram() { - if ((bool) config_cache('pixelfed.import.instagram.enabled') != true) { + if ((bool) config_cache('pixelfed.import.instagram.enabled') !== true) { abort(404, 'Feature not enabled'); } @@ -23,7 +23,7 @@ trait Instagram public function instagramStart(Request $request) { - if ((bool) config_cache('pixelfed.import.instagram.enabled') != true) { + if ((bool) config_cache('pixelfed.import.instagram.enabled') !== true) { abort(404, 'Feature not enabled'); } $completed = ImportJob::whereProfileId($request->user()->profile->id) @@ -40,7 +40,7 @@ trait Instagram protected function instagramRedirectOrNew() { - if ((bool) config_cache('pixelfed.import.instagram.enabled') != true) { + if ((bool) config_cache('pixelfed.import.instagram.enabled') !== true) { abort(404, 'Feature not enabled'); } $profile = request()->user()->profile; @@ -67,7 +67,7 @@ trait Instagram public function instagramStepOne(Request $request, $uuid) { - if ((bool) config_cache('pixelfed.import.instagram.enabled') != true) { + if ((bool) config_cache('pixelfed.import.instagram.enabled') !== true) { abort(404, 'Feature not enabled'); } $profile = $request->user()->profile; @@ -77,12 +77,12 @@ trait Instagram ->whereStage(1) ->firstOrFail(); - return view('settings.import.instagram.step-one', compact('profile', 'job')); + return view('settings.import.instagram.step-one', ['profile' => $profile, 'job' => $job]); } public function instagramStepOneStore(Request $request, $uuid) { - if ((bool) config_cache('pixelfed.import.instagram.enabled') != true) { + if ((bool) config_cache('pixelfed.import.instagram.enabled') !== true) { abort(404, 'Feature not enabled'); } $max = 'max:'.config('pixelfed.import.instagram.limits.size'); @@ -128,7 +128,7 @@ trait Instagram public function instagramStepTwo(Request $request, $uuid) { - if ((bool) config_cache('pixelfed.import.instagram.enabled') != true) { + if ((bool) config_cache('pixelfed.import.instagram.enabled') !== true) { abort(404, 'Feature not enabled'); } $profile = $request->user()->profile; @@ -138,12 +138,12 @@ trait Instagram ->whereStage(2) ->firstOrFail(); - return view('settings.import.instagram.step-two', compact('profile', 'job')); + return view('settings.import.instagram.step-two', ['profile' => $profile, 'job' => $job]); } public function instagramStepTwoStore(Request $request, $uuid) { - if ((bool) config_cache('pixelfed.import.instagram.enabled') != true) { + if ((bool) config_cache('pixelfed.import.instagram.enabled') !== true) { abort(404, 'Feature not enabled'); } $this->validate($request, [ @@ -172,7 +172,7 @@ trait Instagram public function instagramStepThree(Request $request, $uuid) { - if ((bool) config_cache('pixelfed.import.instagram.enabled') != true) { + if ((bool) config_cache('pixelfed.import.instagram.enabled') !== true) { abort(404, 'Feature not enabled'); } $profile = $request->user()->profile; @@ -183,12 +183,12 @@ trait Instagram ->whereStage(3) ->firstOrFail(); - return view('settings.import.instagram.step-three', compact('profile', 'job')); + return view('settings.import.instagram.step-three', ['profile' => $profile, 'job' => $job]); } public function instagramStepThreeStore(Request $request, $uuid) { - if ((bool) config_cache('pixelfed.import.instagram.enabled') != true) { + if ((bool) config_cache('pixelfed.import.instagram.enabled') !== true) { abort(404, 'Feature not enabled'); } $profile = $request->user()->profile; diff --git a/app/Http/Controllers/InternalApiController.php b/app/Http/Controllers/InternalApiController.php index 59a345b57..96be90edb 100644 --- a/app/Http/Controllers/InternalApiController.php +++ b/app/Http/Controllers/InternalApiController.php @@ -64,7 +64,7 @@ class InternalApiController extends Controller ->take(12) ->values(); - return response()->json(compact('posts')); + return response()->json(['posts' => $posts]); } public function directMessage(Request $request, $profileId, $threadId): JsonResponse @@ -84,7 +84,7 @@ class InternalApiController extends Controller ->orderBy('created_at', 'asc') ->paginate(30); - return response()->json(compact('msg', 'profile', 'thread'), 200, [], JSON_PRETTY_PRINT); + return response()->json(['msg' => $msg, 'profile' => $profile, 'thread' => $thread], 200, [], JSON_PRETTY_PRINT); } public function statusReplies(Request $request, int $id): JsonResponse @@ -311,12 +311,12 @@ class InternalApiController extends Controller } $pid = $request->user()->profile->id; $following = FollowerService::getFollowingIds($pid); - $visibility = in_array($profile->id, $following) == true ? ['public', 'unlisted', 'private'] : []; + $visibility = in_array($profile->id, $following) === true ? ['public', 'unlisted', 'private'] : []; } else { if ($request->user() !== null) { $pid = $request->user()->profile->id; $following = FollowerService::getFollowingIds($pid); - $visibility = in_array($profile->id, $following) == true ? ['public', 'unlisted', 'private'] : ['public', 'unlisted']; + $visibility = in_array($profile->id, $following) === true ? ['public', 'unlisted', 'private'] : ['public', 'unlisted']; } else { $visibility = ['public', 'unlisted']; } @@ -368,7 +368,7 @@ class InternalApiController extends Controller $pid = $request->user()->profile_id; $exists = Redis::sismember('email:manual', $pid); - return view('account.email.request_verification', compact('exists')); + return view('account.email.request_verification', ['exists' => $exists]); } public function requestEmailVerificationStore(Request $request): RedirectResponse diff --git a/app/Http/Controllers/LandingController.php b/app/Http/Controllers/LandingController.php index 1c8d713f6..dde224afa 100644 --- a/app/Http/Controllers/LandingController.php +++ b/app/Http/Controllers/LandingController.php @@ -16,7 +16,7 @@ class LandingController extends Controller return redirect('/'); } - abort_if((bool) config_cache('instance.landing.show_directory') == false, 404); + abort_if((bool) config_cache('instance.landing.show_directory') === false, 404); return view('site.index'); } @@ -27,14 +27,14 @@ class LandingController extends Controller return redirect('/'); } - abort_if((bool) config_cache('instance.landing.show_explore') == false, 404); + abort_if((bool) config_cache('instance.landing.show_explore') === false, 404); return view('site.index'); } public function getDirectoryApi(Request $request) { - abort_if((bool) config_cache('instance.landing.show_directory') == false, 404); + abort_if((bool) config_cache('instance.landing.show_directory') === false, 404); return DirectoryProfile::collection( Profile::whereNull('domain') diff --git a/app/Http/Controllers/LikeController.php b/app/Http/Controllers/LikeController.php index 13929ae39..17c97519d 100644 --- a/app/Http/Controllers/LikeController.php +++ b/app/Http/Controllers/LikeController.php @@ -55,7 +55,7 @@ class LikeController extends Controller 'video', 'video:album', 'photo:video:album', - ]) == false; + ]) === false; $like->save(); $status->save(); LikePipeline::dispatch($like)->onQueue('feed'); @@ -66,11 +66,9 @@ class LikeController extends Controller StatusService::refresh($status->id); if ($request->ajax()) { - $response = ['code' => 200, 'msg' => 'Like saved', 'count' => 0]; - } else { - $response = redirect($status->url()); + return ['code' => 200, 'msg' => 'Like saved', 'count' => 0]; } - return $response; + return redirect($status->url()); } } diff --git a/app/Http/Controllers/LiveStreamController.php b/app/Http/Controllers/LiveStreamController.php index 7e0ae8525..311363fe9 100644 --- a/app/Http/Controllers/LiveStreamController.php +++ b/app/Http/Controllers/LiveStreamController.php @@ -135,7 +135,7 @@ class LiveStreamController extends Controller abort_if(! $request->user() && $stream && $stream->visibility !== 'public', 404); - return view('live.player', compact('id')); + return view('live.player', ['id' => $id]); } public function deleteStream(Request $request): array @@ -369,20 +369,18 @@ class LiveStreamController extends Controller $stream = LiveStream::whereStreamKey($key)->firstOrFail(); return redirect($stream->getStreamRtmpUrl(), 301); - } else { - $stream = LiveStream::whereStreamId($key)->firstOrFail(); } + $stream = LiveStream::whereStreamId($key)->firstOrFail(); StreamStart::dispatch($stream->profile_id); - if ($request->filled('name') && $token == false) { + if ($request->filled('name') && $token === false) { $stream->live_at = now(); $stream->save(); return []; - } else { - abort(400); } + abort(400); abort(400); } diff --git a/app/Http/Controllers/NewsroomController.php b/app/Http/Controllers/NewsroomController.php index a6faeef20..634069e4d 100644 --- a/app/Http/Controllers/NewsroomController.php +++ b/app/Http/Controllers/NewsroomController.php @@ -22,7 +22,7 @@ class NewsroomController extends Controller ->paginate(3); } - return view('site.news.home', compact('posts')); + return view('site.news.home', ['posts' => $posts]); } public function show(Request $request, $year, $month, $slug): View @@ -34,7 +34,7 @@ class NewsroomController extends Controller ->firstOrFail(); abort_if($post->auth_only && ! $request->user(), 404); - return view('site.news.post.show', compact('post')); + return view('site.news.post.show', ['post' => $post]); } public function search(Request $request): void diff --git a/app/Http/Controllers/PageController.php b/app/Http/Controllers/PageController.php index eaf37bd84..33dd87e62 100644 --- a/app/Http/Controllers/PageController.php +++ b/app/Http/Controllers/PageController.php @@ -46,12 +46,12 @@ class PageController extends Controller 'page' => 'required|string', ]); $slug = urldecode($request->page); - if (in_array($slug, array_keys($this->cacheKeys())) == false) { + if (in_array($slug, array_keys($this->cacheKeys())) === false) { return redirect(route('admin.settings.pages')); } $page = Page::firstOrCreate(['slug' => $slug]); - return view('admin.pages.edit', compact('page')); + return view('admin.pages.edit', ['page' => $page]); } public function store(Request $request): JsonResponse diff --git a/app/Http/Controllers/ProfileAliasController.php b/app/Http/Controllers/ProfileAliasController.php index 3707cb99f..d84da7d29 100644 --- a/app/Http/Controllers/ProfileAliasController.php +++ b/app/Http/Controllers/ProfileAliasController.php @@ -23,7 +23,7 @@ class ProfileAliasController extends Controller { $aliases = $request->user()->profile->aliases; - return view('settings.aliases.index', compact('aliases')); + return view('settings.aliases.index', ['aliases' => $aliases]); } public function store(Request $request): RedirectResponse diff --git a/app/Http/Controllers/ProfileMigrationController.php b/app/Http/Controllers/ProfileMigrationController.php index d16e67e83..5c0a5f106 100644 --- a/app/Http/Controllers/ProfileMigrationController.php +++ b/app/Http/Controllers/ProfileMigrationController.php @@ -33,7 +33,7 @@ class ProfileMigrationController extends Controller ->where('created_at', '>', now()->subDays(30)) ->exists(); - return view('settings.migration.index', compact('hasExistingMigration')); + return view('settings.migration.index', ['hasExistingMigration' => $hasExistingMigration]); } public function store(ProfileMigrationStoreRequest $request): RedirectResponse @@ -44,7 +44,7 @@ class ProfileMigrationController extends Controller return redirect()->back()->withErrors(['acct' => 'The new account you provided is not responding to our requests.']); } $newAccount = Helpers::profileFetch($acct); - if (! $newAccount) { + if (!$newAccount instanceof \App\Models\Profile) { return redirect()->back()->withErrors(['acct' => 'An error occured, please try again later. Code: res-failed-account-fetch']); } $user = $request->user(); diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php index d284703b0..e8b12ec3d 100644 --- a/app/Http/Controllers/SearchController.php +++ b/app/Http/Controllers/SearchController.php @@ -94,7 +94,7 @@ class SearchController extends Controller $hash = hash('sha256', $tag); if (Helpers::validateUrl($tag) != false && Helpers::validateLocalUrl($tag) != true && - (bool) config_cache('federation.activitypub.enabled') == true && + (bool) config_cache('federation.activitypub.enabled') === true && config('federation.activitypub.remoteFollow') == true ) { $remote = Helpers::fetchFromUrl($tag); @@ -215,7 +215,7 @@ class SearchController extends Controller $ttl = now()->addHours(2); if (Helpers::validateUrl($tag) != false && Helpers::validateLocalUrl($tag) != true && - (bool) config_cache('federation.activitypub.enabled') == true && + (bool) config_cache('federation.activitypub.enabled') === true && config('federation.activitypub.remoteFollow') == true ) { $remote = Helpers::fetchFromUrl($tag); diff --git a/app/Http/Controllers/Settings/HomeSettings.php b/app/Http/Controllers/Settings/HomeSettings.php index 84ac608e6..4d9b3898e 100644 --- a/app/Http/Controllers/Settings/HomeSettings.php +++ b/app/Http/Controllers/Settings/HomeSettings.php @@ -33,7 +33,7 @@ trait HomeSettings $storage['usedPretty'] = PrettyNumber::size($storage['used']); $pronouns = PronounService::get($id); - return view('settings.home', compact('storage', 'pronouns')); + return view('settings.home', ['storage' => $storage, 'pronouns' => $pronouns]); } public function homeUpdate(Request $request) @@ -217,9 +217,8 @@ trait HomeSettings } return redirect('/settings/email')->with('status', 'Email successfully updated!'); - } else { - return redirect('/settings/email'); } + return redirect('/settings/email'); } diff --git a/app/Http/Controllers/Settings/LabsSettings.php b/app/Http/Controllers/Settings/LabsSettings.php index c1e3faf45..0e84f48f0 100644 --- a/app/Http/Controllers/Settings/LabsSettings.php +++ b/app/Http/Controllers/Settings/LabsSettings.php @@ -17,7 +17,7 @@ trait LabsSettings { $profile = $request->user()->profile; - return view('settings.labs', compact('profile')); + return view('settings.labs', ['profile' => $profile]); } public function labsStore(Request $request) @@ -67,7 +67,7 @@ trait LabsSettings $changes = true; } - if ($changes == true) { + if ($changes === true) { $profile->save(); } diff --git a/app/Http/Controllers/Settings/PrivacySettings.php b/app/Http/Controllers/Settings/PrivacySettings.php index c292504b1..a26ea595d 100644 --- a/app/Http/Controllers/Settings/PrivacySettings.php +++ b/app/Http/Controllers/Settings/PrivacySettings.php @@ -30,7 +30,7 @@ trait PrivacySettings $settings['disable_embeds'] = false; } - return view('settings.privacy', compact('settings', 'profile')); + return view('settings.privacy', ['settings' => $settings, 'profile' => $profile]); } public function privacyStore(Request $request) @@ -64,7 +64,7 @@ trait PrivacySettings foreach ($fields as $field) { $form = $request->input($field); - if ($field == 'is_private') { + if ($field === 'is_private') { if ($form == 'on') { $profile->{$field} = true; $settings->show_guests = false; @@ -75,19 +75,19 @@ trait PrivacySettings $profile->save(); } Cache::forget('profiles:private'); - } elseif ($field == 'crawlable') { + } elseif ($field === 'crawlable') { if ($form == 'on') { $settings->{$field} = false; } else { $settings->{$field} = true; } - } elseif ($field == 'public_dm') { + } elseif ($field === 'public_dm') { if ($form == 'on') { $settings->{$field} = true; } else { $settings->{$field} = false; } - } elseif ($field == 'indexable') { + } elseif ($field === 'indexable') { } else { if ($form == 'on') { $settings->{$field} = true; @@ -130,7 +130,7 @@ trait PrivacySettings $ids = (new UserFilter)->mutedUserIds($pid); $users = Profile::whereIn('id', $ids)->simplePaginate(15); - return view('settings.privacy.muted', compact('users')); + return view('settings.privacy.muted', ['users' => $users]); } public function mutedUsersUpdate(Request $request) @@ -162,7 +162,7 @@ trait PrivacySettings ->orderByDesc('created_at') ->simplePaginate(15); - return view('settings.privacy.featured-collections', compact('collections')); + return view('settings.privacy.featured-collections', ['collections' => $collections]); } public function featuredCollectionsRemove(Request $request) @@ -186,7 +186,7 @@ trait PrivacySettings $ids = (new UserFilter)->blockedUserIds($pid); $users = Profile::whereIn('id', $ids)->simplePaginate(15); - return view('settings.privacy.blocked', compact('users')); + return view('settings.privacy.blocked', ['users' => $users]); } public function blockedUsersUpdate(Request $request) diff --git a/app/Http/Controllers/Settings/RelationshipSettings.php b/app/Http/Controllers/Settings/RelationshipSettings.php index e3a8fec5d..74dcbee9f 100644 --- a/app/Http/Controllers/Settings/RelationshipSettings.php +++ b/app/Http/Controllers/Settings/RelationshipSettings.php @@ -29,6 +29,6 @@ trait RelationshipSettings break; } - return view('settings.relationships.home', compact('profile', 'mode', 'data')); + return view('settings.relationships.home', ['profile' => $profile, 'mode' => $mode, 'data' => $data]); } } diff --git a/app/Http/Controllers/Settings/SecuritySettings.php b/app/Http/Controllers/Settings/SecuritySettings.php index 0860cd436..1c7d98872 100644 --- a/app/Http/Controllers/Settings/SecuritySettings.php +++ b/app/Http/Controllers/Settings/SecuritySettings.php @@ -28,7 +28,7 @@ trait SecuritySettings ->limit(5) ->get(); - return view('settings.security', compact('activity', 'user', 'devices')); + return view('settings.security', ['activity' => $activity, 'user' => $user, 'devices' => $devices]); } public function securityTwoFactorSetup(Request $request) @@ -44,8 +44,7 @@ trait SecuritySettings $qrcode = $google2fa->getQRCodeUrl( config('pixelfed.domain.app'), $user->email, - $key, - 500 + $key ); $writer = new Writer( @@ -59,7 +58,7 @@ trait SecuritySettings $user->{'2fa_backup_codes'} = json_encode($backups); $user->save(); - return view('settings.security.2fa.setup', compact('user', 'qrcode', 'backups')); + return view('settings.security.2fa.setup', ['user' => $user, 'qrcode' => $qrcode, 'backups' => $backups]); } protected function generateBackupCodes() @@ -91,9 +90,8 @@ trait SecuritySettings $user->save(); return response()->json(['msg' => 'success']); - } else { - return response()->json(['msg' => 'fail'], 403); } + return response()->json(['msg' => 'fail'], 403); } public function securityTwoFactorEdit(Request $request) @@ -104,7 +102,7 @@ trait SecuritySettings abort(403); } - return view('settings.security.2fa.edit', compact('user')); + return view('settings.security.2fa.edit', ['user' => $user]); } public function securityTwoFactorRecoveryCodes(Request $request) @@ -116,7 +114,7 @@ trait SecuritySettings } $codes = json_decode($user->{'2fa_backup_codes'}, true); - return view('settings.security.2fa.recovery-codes', compact('user', 'codes')); + return view('settings.security.2fa.recovery-codes', ['user' => $user, 'codes' => $codes]); } public function securityTwoFactorRecoveryCodesRegenerate(Request $request) diff --git a/app/Http/Controllers/StatusController.php b/app/Http/Controllers/StatusController.php index 999dc2a42..e05c251e5 100644 --- a/app/Http/Controllers/StatusController.php +++ b/app/Http/Controllers/StatusController.php @@ -62,7 +62,7 @@ class StatusController extends Controller $template = $status->in_reply_to_id ? 'status.reply' : 'status.show'; - return view($template, compact('user', 'status')); + return view($template, ['user' => $user, 'status' => $status]); } public function shortcodeRedirect(Request $request, string $id): RedirectResponse @@ -119,7 +119,7 @@ class StatusController extends Controller $showCaption = $request->boolean('caption'); $layout = $request->input('layout') === 'compact' ? 'compact' : 'full'; - return response(view('status.embed', compact('status', 'showLikes', 'showCaption', 'layout'))) + return response(view('status.embed', ['status' => $status, 'showLikes' => $showLikes, 'showCaption' => $showCaption, 'layout' => $layout])) ->header('X-Frame-Options', 'ALLOWALL'); } @@ -270,7 +270,7 @@ class StatusController extends Controller ->findOrFail($id); $licenses = License::get(); - return view('status.edit', compact('user', 'status', 'licenses')); + return view('status.edit', ['user' => $user, 'status' => $status, 'licenses' => $licenses]); } public function editStore(Request $request, string $username, string $id): RedirectResponse diff --git a/app/Http/Controllers/StoryComposeController.php b/app/Http/Controllers/StoryComposeController.php index ee99f741e..2e4c81cd8 100644 --- a/app/Http/Controllers/StoryComposeController.php +++ b/app/Http/Controllers/StoryComposeController.php @@ -132,7 +132,7 @@ class StoryComposeController extends Controller 'image/jpeg', 'image/png', 'video/mp4', - ]) == false) { + ]) === false) { abort(400, 'Invalid media type'); return; diff --git a/app/Http/Controllers/StoryController.php b/app/Http/Controllers/StoryController.php index 1b86f8dd6..5fa5569f3 100644 --- a/app/Http/Controllers/StoryController.php +++ b/app/Http/Controllers/StoryController.php @@ -162,7 +162,7 @@ class StoryController extends StoryComposeController return $res; })->toArray(); - if (count($stories) == 0) { + if (count($stories) === 0) { return []; } $cursor = count($stories) - 1; @@ -290,7 +290,7 @@ class StoryController extends StoryComposeController } $pid = $profile->id; - return view('stories.show_remote', compact('pid')); + return view('stories.show_remote', ['pid' => $pid]); } public function pollResults(Request $request) diff --git a/app/Http/Controllers/TimelineController.php b/app/Http/Controllers/TimelineController.php index 704eee52f..bc0a4a625 100644 --- a/app/Http/Controllers/TimelineController.php +++ b/app/Http/Controllers/TimelineController.php @@ -31,7 +31,7 @@ class TimelineController extends Controller ]); $layout = $request->input('layout', 'feed'); - return view('timeline.local', compact('layout')); + return view('timeline.local', ['layout' => $layout]); } public function network(Request $request): View @@ -42,7 +42,7 @@ class TimelineController extends Controller ]); $layout = $request->input('layout', 'feed'); - return view('timeline.network', compact('layout')); + return view('timeline.network', ['layout' => $layout]); } // public function publicApi(Request $request) diff --git a/app/Http/Middleware/TwoFactorAuth.php b/app/Http/Middleware/TwoFactorAuth.php index 224ad57c8..bd3dae893 100644 --- a/app/Http/Middleware/TwoFactorAuth.php +++ b/app/Http/Middleware/TwoFactorAuth.php @@ -19,11 +19,12 @@ class TwoFactorAuth if ($request->user()) { $user = $request->user(); $enabled = (bool) $user->{'2fa_enabled'}; - if ($enabled != false) { + if ($enabled !== false) { $checkpoint = 'i/auth/checkpoint'; if ($request->session()->has('2fa.session.active') !== true && ! $request->is($checkpoint) && ! $request->is('logout')) { return redirect('/i/auth/checkpoint'); - } elseif ($request->session()->has('2fa.attempts') && (int) $request->session()->get('2fa.attempts') > 3) { + } + if ($request->session()->has('2fa.attempts') && (int) $request->session()->get('2fa.attempts') > 3) { $request->session()->pull('2fa.attempts'); Auth::logout(); } diff --git a/app/Jobs/AvatarPipeline/RemoteAvatarFetch.php b/app/Jobs/AvatarPipeline/RemoteAvatarFetch.php index 3c59d5808..a81572544 100644 --- a/app/Jobs/AvatarPipeline/RemoteAvatarFetch.php +++ b/app/Jobs/AvatarPipeline/RemoteAvatarFetch.php @@ -55,7 +55,7 @@ class RemoteAvatarFetch implements ShouldQueue { $profile = $this->profile; - if ((bool) config_cache('pixelfed.cloud_storage') == false && (bool) config_cache('federation.avatars.store_local') == false) { + if ((bool) config_cache('pixelfed.cloud_storage') === false && (bool) config_cache('federation.avatars.store_local') === false) { return 1; } @@ -103,7 +103,7 @@ class RemoteAvatarFetch implements ShouldQueue $avatar->remote_url = $icon['url']; $avatar->save(); - MediaStorageService::avatar($avatar, (bool) config_cache('pixelfed.cloud_storage') == false, true); + MediaStorageService::avatar($avatar, (bool) config_cache('pixelfed.cloud_storage') === false, true); return 1; } diff --git a/app/Jobs/AvatarPipeline/RemoteAvatarFetchFromUrl.php b/app/Jobs/AvatarPipeline/RemoteAvatarFetchFromUrl.php index 13e848ef9..e195a3eaa 100644 --- a/app/Jobs/AvatarPipeline/RemoteAvatarFetchFromUrl.php +++ b/app/Jobs/AvatarPipeline/RemoteAvatarFetchFromUrl.php @@ -62,7 +62,7 @@ class RemoteAvatarFetchFromUrl implements ShouldQueue Cache::forget('avatar:'.$profile->id); AccountService::del($profile->id); - if ((bool) config_cache('pixelfed.cloud_storage') == false && (bool) config_cache('federation.avatars.store_local') == false) { + if ((bool) config_cache('pixelfed.cloud_storage') === false && (bool) config_cache('federation.avatars.store_local') === false) { return 1; } @@ -84,7 +84,7 @@ class RemoteAvatarFetchFromUrl implements ShouldQueue $avatar->save(); } - MediaStorageService::avatar($avatar, (bool) config_cache('pixelfed.cloud_storage') == false, true); + MediaStorageService::avatar($avatar, (bool) config_cache('pixelfed.cloud_storage') === false, true); return 1; } diff --git a/app/Jobs/CommentPipeline/CommentPipeline.php b/app/Jobs/CommentPipeline/CommentPipeline.php index 0bf0bc728..8cb167abc 100644 --- a/app/Jobs/CommentPipeline/CommentPipeline.php +++ b/app/Jobs/CommentPipeline/CommentPipeline.php @@ -60,12 +60,12 @@ class CommentPipeline implements ShouldQueue if (! $status) { Log::info('CommentPipeline: Status no longer exists, skipping job'); - return; + return null; } if (! $comment) { Log::info('CommentPipeline: Comment no longer exists, skipping job'); - return; + return null; } $target = $status->profile; @@ -75,12 +75,12 @@ class CommentPipeline implements ShouldQueue if (! $target) { Log::info("CommentPipeline: Target profile no longer exists for status {$status->id}, skipping job"); - return; + return null; } if (! $actor) { Log::info("CommentPipeline: Actor profile no longer exists for comment {$comment->id}, skipping job"); - return; + return null; } if (db_is_mysql_maria()) { @@ -112,7 +112,7 @@ class CommentPipeline implements ShouldQueue ->exists(); if ($filtered == true) { - return; + return null; } if ($target->user_id && $target->domain === null) { @@ -130,5 +130,6 @@ class CommentPipeline implements ShouldQueue } else { Cache::forget('status:replies:all:'.$status->id); } + return null; } } diff --git a/app/Jobs/DeletePipeline/DeleteRemoteProfilePipeline.php b/app/Jobs/DeletePipeline/DeleteRemoteProfilePipeline.php index 0dc00a1d0..c07ecd331 100644 --- a/app/Jobs/DeletePipeline/DeleteRemoteProfilePipeline.php +++ b/app/Jobs/DeletePipeline/DeleteRemoteProfilePipeline.php @@ -56,13 +56,13 @@ class DeleteRemoteProfilePipeline implements ShouldQueue if (! $profile) { Log::info('DeleteRemoteProfilePipeline: Profile no longer exists, skipping job'); - return; + return null; } $pid = $profile->id; if ($profile->domain == null || $profile->private_key) { - return; + return null; } $profile->status = 'delete'; diff --git a/app/Jobs/DeletePipeline/DeleteRemoteStatusPipeline.php b/app/Jobs/DeletePipeline/DeleteRemoteStatusPipeline.php index c31d5cd58..1f0045055 100644 --- a/app/Jobs/DeletePipeline/DeleteRemoteStatusPipeline.php +++ b/app/Jobs/DeletePipeline/DeleteRemoteStatusPipeline.php @@ -61,14 +61,14 @@ class DeleteRemoteStatusPipeline implements ShouldQueue if (! $status) { Log::info('DeleteRemoteStatusPipeline: Status no longer exists, skipping job'); - return; + return null; } // Verify status has a profile if (! $status->profile_id) { Log::info("DeleteRemoteStatusPipeline: Status {$status->id} has no profile_id, skipping job"); - return; + return null; } try { diff --git a/app/Jobs/DeletePipeline/FanoutDeletePipeline.php b/app/Jobs/DeletePipeline/FanoutDeletePipeline.php index 2a9079118..9eae990b8 100644 --- a/app/Jobs/DeletePipeline/FanoutDeletePipeline.php +++ b/app/Jobs/DeletePipeline/FanoutDeletePipeline.php @@ -40,14 +40,14 @@ class FanoutDeletePipeline implements ShouldQueue if (! $profile) { Log::info('FanoutDeletePipeline: Profile no longer exists, skipping job'); - return; + return null; } // Verify profile has required fields for ActivityPub if (! $profile->permalink() || ! $profile->private_key) { Log::info("FanoutDeletePipeline: Profile {$profile->id} missing required fields for ActivityPub, skipping job"); - return; + return null; } try { diff --git a/app/Jobs/ImageOptimizePipeline/ImageOptimize.php b/app/Jobs/ImageOptimizePipeline/ImageOptimize.php index 9d2685c53..5fd7316c2 100644 --- a/app/Jobs/ImageOptimizePipeline/ImageOptimize.php +++ b/app/Jobs/ImageOptimizePipeline/ImageOptimize.php @@ -71,14 +71,12 @@ class ImageOptimize implements ShouldQueue } } - if ((bool) config_cache('pixelfed.optimize_image') == false) { + if ((bool) config_cache('pixelfed.optimize_image') === false) { ImageThumbnail::dispatch($media)->onQueue('mmo'); - return; - } else { - ImageResize::dispatch($media)->onQueue('mmo'); - return; } + ImageResize::dispatch($media)->onQueue('mmo'); + return; } } diff --git a/app/Jobs/ImageOptimizePipeline/ImageUpdate.php b/app/Jobs/ImageOptimizePipeline/ImageUpdate.php index 012b7e2c9..02e8d2f0b 100644 --- a/app/Jobs/ImageOptimizePipeline/ImageUpdate.php +++ b/app/Jobs/ImageOptimizePipeline/ImageUpdate.php @@ -75,7 +75,7 @@ class ImageUpdate implements ShouldQueue } if ((bool) config_cache('pixelfed.optimize_image') && $localFs) { - if (in_array($media->mime, $this->protectedMimes) == true) { + if (in_array($media->mime, $this->protectedMimes) === true) { try { $thumbPath = storage_path('app/'.$media->thumbnail_path); if (file_exists($thumbPath)) { @@ -93,7 +93,7 @@ class ImageUpdate implements ShouldQueue } } } elseif ((bool) config_cache('pixelfed.optimize_image') && ! $localFs) { - if (in_array($media->mime, $this->protectedMimes) == true) { + if (in_array($media->mime, $this->protectedMimes) === true) { $this->optimizeRemoteImages($media, $disk); } } @@ -124,9 +124,8 @@ class ImageUpdate implements ShouldQueue if ($localFs) { return filesize(storage_path('app/'.$path)) ?? 0; - } else { - return $disk->size($path) ?? 0; } + return $disk->size($path) ?? 0; } /** diff --git a/app/Jobs/ImportPipeline/ImportInstagram.php b/app/Jobs/ImportPipeline/ImportInstagram.php index 0e525b6d4..119288829 100644 --- a/app/Jobs/ImportPipeline/ImportInstagram.php +++ b/app/Jobs/ImportPipeline/ImportInstagram.php @@ -95,7 +95,7 @@ class ImportInstagram implements ShouldQueue ->whereOriginalName($filename) ->first(); - if (empty($importData) || is_file(storage_path("app/$importData->path")) == false) { + if (empty($importData) || is_file(storage_path("app/$importData->path")) === false) { continue; } diff --git a/app/Jobs/InboxPipeline/InboxValidator.php b/app/Jobs/InboxPipeline/InboxValidator.php index ca58e18a6..e32b483c8 100644 --- a/app/Jobs/InboxPipeline/InboxValidator.php +++ b/app/Jobs/InboxPipeline/InboxValidator.php @@ -52,7 +52,7 @@ class InboxValidator implements ShouldQueue $headers = $this->headers; if (empty($headers) || empty($this->payload) || ! isset($headers['signature']) || ! isset($headers['date'])) { - return; + return null; } $payload = json_decode($this->payload, true, 8); @@ -60,11 +60,11 @@ class InboxValidator implements ShouldQueue $profile = Profile::whereNull('domain')->whereUsername($username)->first(); if (empty($profile) || empty($headers) || empty($payload)) { - return; + return null; } if ($profile->status != null) { - return; + return null; } if ($this->verifySignature($headers, $profile, $payload) == true) { @@ -83,10 +83,9 @@ class InboxValidator implements ShouldQueue ActivityHandler::dispatch($headers, $profile, $payload)->onQueue($onQueue); } - return; - } else { - return; + return null; } + return null; } protected function verifySignature($headers, $profile, $payload) @@ -171,11 +170,7 @@ class InboxValidator implements ShouldQueue } $inboxPath = "/users/{$profile->username}/inbox"; [$verified, $headers] = HttpSignature::verify($pkey, $signatureData, $headers, $inboxPath, $body); - if ($verified == 1) { - return true; - } else { - return false; - } + return $verified == 1; } public static function actorOptionalFor(array $payload): bool diff --git a/app/Jobs/InboxPipeline/InboxWorker.php b/app/Jobs/InboxPipeline/InboxWorker.php index a0830761b..42a79d128 100644 --- a/app/Jobs/InboxPipeline/InboxWorker.php +++ b/app/Jobs/InboxPipeline/InboxWorker.php @@ -48,7 +48,7 @@ class InboxWorker implements ShouldQueue $headers = $this->headers; if (empty($headers) || empty($this->payload) || ! isset($headers['signature']) || ! isset($headers['date'])) { - return; + return null; } $payload = json_decode($this->payload, true, 8); @@ -64,10 +64,9 @@ class InboxWorker implements ShouldQueue ActivityHandler::dispatch($headers, $profile, $payload)->onQueue('shared'); - return; - } else { - return; + return null; } + return null; } protected function verifySignature($headers, $payload) diff --git a/app/Jobs/MediaPipeline/MediaDeletePipeline.php b/app/Jobs/MediaPipeline/MediaDeletePipeline.php index 7ffa8438f..e9f9b7c87 100644 --- a/app/Jobs/MediaPipeline/MediaDeletePipeline.php +++ b/app/Jobs/MediaPipeline/MediaDeletePipeline.php @@ -117,7 +117,7 @@ class MediaDeletePipeline implements ShouldBeUniqueUntilProcessing, ShouldQueue $i = implode('/', $e); try { - if ((bool) config_cache('pixelfed.cloud_storage') == true) { + if ((bool) config_cache('pixelfed.cloud_storage') === true) { $disk = Storage::disk(config('filesystems.cloud')); if ($path && $disk->exists($path)) { diff --git a/app/Jobs/MediaPipeline/MediaFixLocalFilesystemCleanupPipeline.php b/app/Jobs/MediaPipeline/MediaFixLocalFilesystemCleanupPipeline.php index da90ad907..0beb0d410 100644 --- a/app/Jobs/MediaPipeline/MediaFixLocalFilesystemCleanupPipeline.php +++ b/app/Jobs/MediaPipeline/MediaFixLocalFilesystemCleanupPipeline.php @@ -22,7 +22,7 @@ class MediaFixLocalFilesystemCleanupPipeline implements ShouldQueue public function handle() { - if ((bool) config_cache('pixelfed.cloud_storage') == false) { + if ((bool) config_cache('pixelfed.cloud_storage') === false) { // Only run if cloud storage is enabled return; } diff --git a/app/Jobs/MediaPipeline/MediaSyncLicensePipeline.php b/app/Jobs/MediaPipeline/MediaSyncLicensePipeline.php index aafe46a71..36d68b320 100644 --- a/app/Jobs/MediaPipeline/MediaSyncLicensePipeline.php +++ b/app/Jobs/MediaPipeline/MediaSyncLicensePipeline.php @@ -52,5 +52,6 @@ class MediaSyncLicensePipeline implements ShouldQueue StatusService::del($media->status_id); } }); + return null; } } diff --git a/app/Jobs/MovePipeline/CleanupLegacyAccountMovePipeline.php b/app/Jobs/MovePipeline/CleanupLegacyAccountMovePipeline.php index a5afae643..5413495a5 100644 --- a/app/Jobs/MovePipeline/CleanupLegacyAccountMovePipeline.php +++ b/app/Jobs/MovePipeline/CleanupLegacyAccountMovePipeline.php @@ -71,7 +71,7 @@ class CleanupLegacyAccountMovePipeline implements ShouldQueue */ public function handle(): void { - if (config('app.env') !== 'production' || (bool) config_cache('federation.activitypub.enabled') == false) { + if (config('app.env') !== 'production' || (bool) config_cache('federation.activitypub.enabled') === false) { throw new Exception('Activitypub not enabled'); } diff --git a/app/Jobs/MovePipeline/MoveMigrateFollowersPipeline.php b/app/Jobs/MovePipeline/MoveMigrateFollowersPipeline.php index 145de6ece..741a9412d 100644 --- a/app/Jobs/MovePipeline/MoveMigrateFollowersPipeline.php +++ b/app/Jobs/MovePipeline/MoveMigrateFollowersPipeline.php @@ -80,7 +80,7 @@ class MoveMigrateFollowersPipeline implements ShouldQueue */ public function handle(): void { - if (config('app.env') !== 'production' || (bool) config_cache('federation.activitypub.enabled') == false) { + if (config('app.env') !== 'production' || (bool) config_cache('federation.activitypub.enabled') === false) { throw new Exception('Activitypub not enabled'); } diff --git a/app/Jobs/MovePipeline/ProcessMovePipeline.php b/app/Jobs/MovePipeline/ProcessMovePipeline.php index 1ff95f96c..97591562c 100644 --- a/app/Jobs/MovePipeline/ProcessMovePipeline.php +++ b/app/Jobs/MovePipeline/ProcessMovePipeline.php @@ -76,7 +76,7 @@ class ProcessMovePipeline implements ShouldQueue */ public function handle(): void { - if (config('app.env') !== 'production' || (bool) config_cache('federation.activitypub.enabled') == false) { + if (config('app.env') !== 'production' || (bool) config_cache('federation.activitypub.enabled') === false) { throw new Exception('Activitypub not enabled'); } @@ -102,7 +102,7 @@ class ProcessMovePipeline implements ShouldQueue } $targetRes = Helpers::profileFetch($this->target); - if (! $targetRes) { + if (!$targetRes instanceof \App\Models\Profile) { return false; } @@ -133,7 +133,7 @@ class ProcessMovePipeline implements ShouldQueue } $actorRes = Helpers::profileFetch($this->activity); - if (! $actorRes) { + if (!$actorRes instanceof \App\Models\Profile) { return false; } diff --git a/app/Jobs/MovePipeline/UnfollowLegacyAccountMovePipeline.php b/app/Jobs/MovePipeline/UnfollowLegacyAccountMovePipeline.php index f33664129..13f9be21e 100644 --- a/app/Jobs/MovePipeline/UnfollowLegacyAccountMovePipeline.php +++ b/app/Jobs/MovePipeline/UnfollowLegacyAccountMovePipeline.php @@ -68,7 +68,7 @@ class UnfollowLegacyAccountMovePipeline implements ShouldQueue */ public function handle(): void { - if (config('app.env') !== 'production' || (bool) config_cache('federation.activitypub.enabled') == false) { + if (config('app.env') !== 'production' || (bool) config_cache('federation.activitypub.enabled') === false) { throw new Exception('Activitypub not enabled'); } diff --git a/app/Jobs/SharePipeline/SharePipeline.php b/app/Jobs/SharePipeline/SharePipeline.php index 933710477..31024f191 100644 --- a/app/Jobs/SharePipeline/SharePipeline.php +++ b/app/Jobs/SharePipeline/SharePipeline.php @@ -109,34 +109,35 @@ class SharePipeline implements ShouldQueue public function remoteAnnounceDeliver() { - if (config('app.env') !== 'production' || (bool) config_cache('federation.activitypub.enabled') == false) { + if (config('app.env') !== 'production' || (bool) config_cache('federation.activitypub.enabled') === false) { return true; } $status = $this->status; if ($status->uri !== null) { - return; + return null; } $profile = $status->profile; if (! $profile || $profile->domain !== null) { - return; + return null; } if ($status->scope !== 'public') { - return; + return null; } $audience = $profile->getAudienceInbox(); if (empty($audience)) { - return; + return null; } $activity = FractalService::item($status, new Announce); ActivityPubDeliveryService::pool($profile, $audience, $activity); + return null; } } diff --git a/app/Jobs/SharePipeline/UndoSharePipeline.php b/app/Jobs/SharePipeline/UndoSharePipeline.php index a0e7241df..b768b402a 100644 --- a/app/Jobs/SharePipeline/UndoSharePipeline.php +++ b/app/Jobs/SharePipeline/UndoSharePipeline.php @@ -63,16 +63,15 @@ class UndoSharePipeline implements ShouldQueue return; } - if (config('app.env') !== 'production' || (bool) config_cache('federation.activitypub.enabled') == false) { + if (config('app.env') !== 'production' || (bool) config_cache('federation.activitypub.enabled') === false) { return $status->delete(); - } else { - return $this->remoteAnnounceDeliver(); } + return $this->remoteAnnounceDeliver(); } public function remoteAnnounceDeliver() { - if (config('app.env') !== 'production' || (bool) config_cache('federation.activitypub.enabled') == false) { + if (config('app.env') !== 'production' || (bool) config_cache('federation.activitypub.enabled') === false) { $this->status->delete(); return 1; diff --git a/app/Jobs/StatusPipeline/StatusDelete.php b/app/Jobs/StatusPipeline/StatusDelete.php index 5ae7defdd..cdaaa417b 100644 --- a/app/Jobs/StatusPipeline/StatusDelete.php +++ b/app/Jobs/StatusPipeline/StatusDelete.php @@ -94,11 +94,10 @@ class StatusDelete implements ShouldQueue Cache::forget('pf:atom:user-feed:by-id:'.$status->profile_id); - if ((bool) config_cache('federation.activitypub.enabled') == true) { + if ((bool) config_cache('federation.activitypub.enabled') === true) { return $this->fanoutDelete($status); - } else { - return $this->unlinkRemoveMedia($status); } + return $this->unlinkRemoveMedia($status); } public function unlinkRemoveMedia($status) @@ -202,7 +201,7 @@ class StatusDelete implements ShouldQueue $profile = $status->profile()->withTrashed()->first(); if (! $profile) { - return; + return null; } $status->setRelation('profile', $profile); diff --git a/app/Jobs/StoryPipeline/StoryFetch.php b/app/Jobs/StoryPipeline/StoryFetch.php index fcce3eef0..7eb2a1c4e 100644 --- a/app/Jobs/StoryPipeline/StoryFetch.php +++ b/app/Jobs/StoryPipeline/StoryFetch.php @@ -528,11 +528,12 @@ class StoryFetch implements ShouldQueue return false; } - // Additional file type specific validations if (str_starts_with($actualMimeType, 'image/')) { return $this->validateImageFile($filePath); - } elseif (str_starts_with($actualMimeType, 'video/')) { + } + + if (str_starts_with($actualMimeType, 'video/')) { return $this->validateVideoFile($filePath); } @@ -555,7 +556,7 @@ class StoryFetch implements ShouldQueue // Check reasonable dimensions (not too large, not too small) [$width, $height] = $imageInfo; - if ($width < 1 || $height < 1 || $width != 1080 || $height != 1920) { + if ($width < 1 || $height < 1 || $width !== 1080 || $height !== 1920) { if (config('app.dev_log')) { Log::warning('Image dimensions out of range', [ 'width' => $width, diff --git a/app/Jobs/VideoPipeline/VideoHlsPipeline.php b/app/Jobs/VideoPipeline/VideoHlsPipeline.php index c2c3580fa..b6640b2eb 100644 --- a/app/Jobs/VideoPipeline/VideoHlsPipeline.php +++ b/app/Jobs/VideoPipeline/VideoHlsPipeline.php @@ -76,9 +76,8 @@ class VideoHlsPipeline implements ShouldBeUniqueUntilProcessing, ShouldQueue $version = $matches[1]; return (version_compare($version, config('laravel-ffmpeg.min_hls_version')) >= 0) ? 'ok' : false; - } else { - return false; } + return false; }); if (! $depCheck || $depCheck !== 'ok') { diff --git a/app/Jobs/VideoPipeline/VideoOptimize.php b/app/Jobs/VideoPipeline/VideoOptimize.php index 81cab7ac2..6d16d177a 100644 --- a/app/Jobs/VideoPipeline/VideoOptimize.php +++ b/app/Jobs/VideoPipeline/VideoOptimize.php @@ -50,7 +50,8 @@ class VideoOptimize implements ShouldQueue protected function transcode($media) { - return; + // TODO INVESTIGATE + return null; $base = $media->media_path; $path = explode('/', $base); $name = last($path); diff --git a/app/Mail/ContactAdmin.php b/app/Mail/ContactAdmin.php index d9534cc2e..b6b2e9370 100644 --- a/app/Mail/ContactAdmin.php +++ b/app/Mail/ContactAdmin.php @@ -32,6 +32,6 @@ class ContactAdmin extends Mailable { $contact = $this->contact; - return $this->subject('New Support Message')->markdown('emails.contact.admin')->with(compact('contact')); + return $this->subject('New Support Message')->markdown('emails.contact.admin')->with(['contact' => $contact]); } } diff --git a/app/Models/CustomEmoji.php b/app/Models/CustomEmoji.php index b69016622..f9b449bbb 100644 --- a/app/Models/CustomEmoji.php +++ b/app/Models/CustomEmoji.php @@ -30,7 +30,7 @@ class CustomEmoji extends Model public static function scan($text, $activitypub = false) { - if ((bool) config_cache('federation.custom_emoji.enabled') == false) { + if ((bool) config_cache('federation.custom_emoji.enabled') === false) { return []; } @@ -69,22 +69,20 @@ class CustomEmoji extends Model 'url' => $url, ], ]; - } else { - return [ - 'shortcode' => $match, - 'url' => $url, - 'static_url' => $url, - 'visible_in_picker' => $tag['disabled'] == false, - ]; } + return [ + 'shortcode' => $match, + 'url' => $url, + 'static_url' => $url, + 'visible_in_picker' => $tag['disabled'] == false, + ]; } }) ->filter(function ($tag) use ($activitypub) { if ($activitypub == true) { return $tag && isset($tag['icon']); - } else { - return $tag && isset($tag['static_url']); } + return $tag && isset($tag['static_url']); }) ->values() ->toArray(); diff --git a/app/Models/CustomFilter.php b/app/Models/CustomFilter.php index 9cc79d028..982b5ddc1 100644 --- a/app/Models/CustomFilter.php +++ b/app/Models/CustomFilter.php @@ -100,6 +100,7 @@ class CustomFilter extends Model case 2: return 'blur'; } + return null; } public function getTitleAttribute() @@ -293,7 +294,7 @@ class CustomFilter extends Model $pattern = preg_quote($keyword->keyword, '/'); if ($keyword->whole_word) { - $pattern = '\b'.$pattern.'\b'; + return '\b'.$pattern.'\b'; } return $pattern; @@ -395,7 +396,7 @@ class CustomFilter extends Model // } // } - if (! empty($keywordMatches) || ! empty($statusMatches)) { + if ($keywordMatches !== [] || ! empty($statusMatches)) { $results[] = [ 'filter' => $filter->toFilterArray(), 'keyword_matches' => $keywordMatches ?: null, diff --git a/app/Models/Media.php b/app/Models/Media.php index f02f341fd..10da251fa 100644 --- a/app/Models/Media.php +++ b/app/Models/Media.php @@ -79,7 +79,7 @@ class Media extends Model public function mimeType() { if (! $this->mime) { - return; + return null; } return explode('/', $this->mime)[0]; diff --git a/app/Models/ParentalControls.php b/app/Models/ParentalControls.php index bd85b875f..c3d479090 100644 --- a/app/Models/ParentalControls.php +++ b/app/Models/ParentalControls.php @@ -52,12 +52,10 @@ class ParentalControls extends Model if ($u = $this->child) { if ($u->profile_id) { return AccountService::get($u->profile_id, true); - } else { - return []; } - } else { return []; } + return []; } public function manageUrl() diff --git a/app/Models/Profile.php b/app/Models/Profile.php index 48f4cb54f..3a8618ae2 100644 --- a/app/Models/Profile.php +++ b/app/Models/Profile.php @@ -203,9 +203,8 @@ class Profile extends Model if ($avatar->cdn_url) { if (substr($avatar->cdn_url, 0, 8) === 'https://') { return $avatar->cdn_url; - } else { - return url('/storage/avatars/default.jpg'); } + return url('/storage/avatars/default.jpg'); } $path = $avatar->media_path; @@ -216,7 +215,7 @@ class Profile extends Model if ($avatar->is_remote && $avatar->remote_url && - boolval(config_cache('federation.avatars.store_local')) == true + boolval(config_cache('federation.avatars.store_local')) === true ) { return $avatar->remote_url; } diff --git a/app/Models/Status.php b/app/Models/Status.php index eb57f9da7..e0938e460 100644 --- a/app/Models/Status.php +++ b/app/Models/Status.php @@ -158,16 +158,14 @@ class Status extends Model { if ($this->uri) { return $forceLocal ? "/i/web/post/_/{$this->profile_id}/{$this->id}" : $this->uri; - } else { - $id = $this->id; - $account = AccountService::get($this->profile_id, true); - if (! $account || ! isset($account['username'])) { - return '/404'; - } - $path = url(config('app.url')."/p/{$account['username']}/{$id}"); - - return $path; } + $id = $this->id; + $account = AccountService::get($this->profile_id, true); + if (! $account || ! isset($account['username'])) { + return '/404'; + } + $path = url(config('app.url')."/p/{$account['username']}/{$id}"); + return $path; } public function permalink($suffix = '/activity') @@ -275,9 +273,8 @@ class Status extends Model $parent = $this->in_reply_to_id ?? $this->reblog_of_id; if (! empty($parent)) { return $this->findOrFail($parent); - } else { - return false; } + return false; } public function conversation() @@ -343,7 +340,7 @@ class Status extends Model public function scopeToAudience($audience) { if (! in_array($audience, ['to', 'cc']) || $this->local == false) { - return; + return null; } $res = []; $res['to'] = []; diff --git a/app/Observers/UserObserver.php b/app/Observers/UserObserver.php index 670027987..83415fabd 100644 --- a/app/Observers/UserObserver.php +++ b/app/Observers/UserObserver.php @@ -102,7 +102,7 @@ class UserObserver CreateAvatar::dispatch($profile); }); - if ((bool) config_cache('account.autofollow') == true) { + if ((bool) config_cache('account.autofollow') === true) { $names = config_cache('account.autofollow_usernames'); $names = explode(',', $names); diff --git a/app/Passport/CachedPersonalAccessClientRepository.php b/app/Passport/CachedPersonalAccessClientRepository.php index 09c068664..c7e0393d6 100644 --- a/app/Passport/CachedPersonalAccessClientRepository.php +++ b/app/Passport/CachedPersonalAccessClientRepository.php @@ -20,7 +20,7 @@ class CachedPersonalAccessClientRepository extends ClientRepository if ($cachedClientId) { $client = $this->findValidClientById($cachedClientId, $provider); - if ($client) { + if ($client instanceof \Laravel\Passport\Client) { return $client; } diff --git a/app/Services/AccountService.php b/app/Services/AccountService.php index f6cedeea6..edad55abc 100644 --- a/app/Services/AccountService.php +++ b/app/Services/AccountService.php @@ -93,7 +93,7 @@ class AccountService return collect($settings) ->filter(function ($item, $key) { - return in_array($key, array_keys(self::defaultSettings())) == true; + return in_array($key, array_keys(self::defaultSettings())) === true; }) ->map(function ($item, $key) { if ($key == 'compose_settings') { @@ -202,7 +202,7 @@ class AccountService $key = self::CACHE_KEY.'pcs:'.$id; if (Cache::has($key)) { - return; + return null; } $count = Status::whereProfileId($id) @@ -313,16 +313,17 @@ class AccountService $num = intval($num); $formatter = new NumberFormatter('en_US', NumberFormatter::DECIMAL); $formatter->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, 1); - if ($num >= 1000000000) { return $formatter->format($num / 1000000000).'B'; - } elseif ($num >= 1000000) { + } + if ($num >= 1000000) { return $formatter->format($num / 1000000).'M'; - } elseif ($num >= 1000) { + } + + if ($num >= 1000) { return $formatter->format($num / 1000).'K'; - } else { - return $formatter->format($num); } + return $formatter->format($num); } public static function getUserIdFromProfileId($profileId): ?int diff --git a/app/Services/ActivityPubFetchService.php b/app/Services/ActivityPubFetchService.php index db7eaf850..3e3070f29 100644 --- a/app/Services/ActivityPubFetchService.php +++ b/app/Services/ActivityPubFetchService.php @@ -67,7 +67,7 @@ class ActivityPubFetchService $ips = Helpers::resolvePublicIps($host); - if (empty($ips)) { + if ($ips === []) { return; } diff --git a/app/Services/ConfigCacheService.php b/app/Services/ConfigCacheService.php index 42ac2f41f..4c9ecc4d1 100644 --- a/app/Services/ConfigCacheService.php +++ b/app/Services/ConfigCacheService.php @@ -170,9 +170,8 @@ class ConfigCacheService if ($c) { if ($protect) { return decrypt($c->v) ?? config($key); - } else { - return $c->v ?? config($key); } + return $c->v ?? config($key); } if ($v === null) { diff --git a/app/Services/CustomEmojiService.php b/app/Services/CustomEmojiService.php index 987ad2ae5..c3543e153 100644 --- a/app/Services/CustomEmojiService.php +++ b/app/Services/CustomEmojiService.php @@ -24,7 +24,7 @@ class CustomEmojiService public static function get($shortcode) { - if ((bool) config_cache('federation.custom_emoji.enabled') == false) { + if ((bool) config_cache('federation.custom_emoji.enabled') === false) { return; } @@ -33,7 +33,7 @@ class CustomEmojiService public static function import($url, $id = false) { - if ((bool) config_cache('federation.custom_emoji.enabled') == false) { + if ((bool) config_cache('federation.custom_emoji.enabled') === false) { return; } @@ -53,7 +53,7 @@ class CustomEmojiService $host = parse_url($url, PHP_URL_HOST); $port = parse_url($url, PHP_URL_PORT) ?: 443; $ips = $host ? Helpers::resolvePublicIps($host) : []; - if (empty($ips)) { + if ($ips === []) { return; } @@ -152,10 +152,9 @@ class CustomEmojiService StatusService::del($id); } - return; - } else { return; } + return; } public static function headCheck($url) @@ -172,12 +171,7 @@ class CustomEmojiService if (! in_array($head['mime'], self::ALLOWED_MIME_TYPES, true)) { return false; } - - if ($maxSize > 0 && $head['length'] > $maxSize) { - return false; - } - - return true; + return $maxSize <= 0 || $head['length'] <= $maxSize; } /** @@ -191,7 +185,7 @@ class CustomEmojiService */ public static function resync(CustomEmoji $emoji): string { - if ((bool) config_cache('federation.custom_emoji.enabled') == false) { + if ((bool) config_cache('federation.custom_emoji.enabled') === false) { return 'skipped'; } diff --git a/app/Services/DeliveryHostService.php b/app/Services/DeliveryHostService.php index 254490f9f..821af4efd 100644 --- a/app/Services/DeliveryHostService.php +++ b/app/Services/DeliveryHostService.php @@ -128,7 +128,7 @@ class DeliveryHostService { $domains = self::normalize($domains); - if (empty($domains)) { + if ($domains === []) { return; } @@ -159,7 +159,7 @@ class DeliveryHostService fn (string $domain) => array_key_exists($domain, $flagged) ); - if (empty($domains)) { + if ($domains === []) { return; } @@ -173,7 +173,7 @@ class DeliveryHostService { $domains = self::normalize([$domain]); - if (empty($domains)) { + if ($domains === []) { return; } diff --git a/app/Services/FeaturedCollectionService.php b/app/Services/FeaturedCollectionService.php index ccdcd19c9..52eb36956 100644 --- a/app/Services/FeaturedCollectionService.php +++ b/app/Services/FeaturedCollectionService.php @@ -213,7 +213,7 @@ class FeaturedCollectionService ): FeatureAuthorization { $auth = self::find($target, $collectionUrl); - if ($auth) { + if ($auth instanceof \App\Models\FeatureAuthorization) { if ($collectionName !== null && $auth->collection_name !== $collectionName) { $auth->collection_name = $collectionName; $auth->save(); @@ -427,7 +427,7 @@ class FeaturedCollectionService $path = rtrim($parts['path'] ?? '/', '/'); - return strtolower($parts['scheme'] ?? 'https').'://'.strtolower($parts['host']).($path === '' ? '' : $path); + return strtolower($parts['scheme'] ?? 'https').'://'.strtolower($parts['host']).($path); }; $na = $norm($a); diff --git a/app/Services/FetchCacheService.php b/app/Services/FetchCacheService.php index ded9fb988..85236a20e 100644 --- a/app/Services/FetchCacheService.php +++ b/app/Services/FetchCacheService.php @@ -41,7 +41,7 @@ class FetchCacheService $host = parse_url($url, PHP_URL_HOST); $port = parse_url($url, PHP_URL_PORT) ?: 443; $ips = $host ? Helpers::resolvePublicIps($host) : []; - if (empty($ips)) { + if ($ips === []) { Cache::put($key, 1, $ttl); return false; diff --git a/app/Services/FollowerService.php b/app/Services/FollowerService.php index f3987aedc..7fee63625 100644 --- a/app/Services/FollowerService.php +++ b/app/Services/FollowerService.php @@ -132,7 +132,7 @@ class FollowerService public static function follows(string $actor, string $target, $quickCheck = false) { - if ($actor == $target) { + if ($actor === $target) { return false; } @@ -144,12 +144,10 @@ class FollowerService self::cacheSyncCheck($target, 'followers'); return (bool) Redis::zScore(self::FOLLOWERS_KEY.$target, $actor); - } else { - self::cacheSyncCheck($target, 'followers'); - self::cacheSyncCheck($actor, 'following'); - - return Follower::whereProfileId($actor)->whereFollowingId($target)->exists(); } + self::cacheSyncCheck($target, 'followers'); + self::cacheSyncCheck($actor, 'following'); + return Follower::whereProfileId($actor)->whereFollowingId($target)->exists(); } public static function cacheSyncCheck($id, $scope = 'followers') @@ -280,11 +278,9 @@ class FollowerService Redis::expire($key, 3600); return $ids; - } else { - Redis::expire($key, 3600); - - return []; } + Redis::expire($key, 3600); + return []; } /** diff --git a/app/Services/GroupFeedService.php b/app/Services/GroupFeedService.php index bf28b470e..f21432e22 100644 --- a/app/Services/GroupFeedService.php +++ b/app/Services/GroupFeedService.php @@ -84,5 +84,6 @@ class GroupFeedService return 1; } + return null; } } diff --git a/app/Services/GroupService.php b/app/Services/GroupService.php index 93468325b..876cac570 100644 --- a/app/Services/GroupService.php +++ b/app/Services/GroupService.php @@ -264,9 +264,8 @@ class GroupService $limits = self::getInteractionLimits($gid, $pid); if ($limits) { return (bool) $limits['limits']['can_post']; - } else { - return true; } + return true; } public static function canComment($gid, $pid) @@ -274,9 +273,8 @@ class GroupService $limits = self::getInteractionLimits($gid, $pid); if ($limits) { return (bool) $limits['limits']['can_comment']; - } else { - return true; } + return true; } public static function canLike($gid, $pid) @@ -284,9 +282,8 @@ class GroupService $limits = self::getInteractionLimits($gid, $pid); if ($limits) { return (bool) $limits['limits']['can_like']; - } else { - return true; } + return true; } public static function categories($onlyActive = true) diff --git a/app/Services/Groups/GroupFeedService.php b/app/Services/Groups/GroupFeedService.php index a176809ca..58e6bb5f5 100644 --- a/app/Services/Groups/GroupFeedService.php +++ b/app/Services/Groups/GroupFeedService.php @@ -84,5 +84,6 @@ class GroupFeedService return 1; } + return null; } } diff --git a/app/Services/Groups/GroupMediaService.php b/app/Services/Groups/GroupMediaService.php index f4d7519e5..d5e9c85cd 100644 --- a/app/Services/Groups/GroupMediaService.php +++ b/app/Services/Groups/GroupMediaService.php @@ -13,7 +13,7 @@ class GroupMediaService public static function path($gid, $pid, $sid = false) { if (! $gid || ! $pid) { - return; + return null; } $groupHashid = HashidService::encode($gid); $monthHash = HashidService::encode(date('Y').date('n')); diff --git a/app/Services/HashidService.php b/app/Services/HashidService.php index e12c10599..4f09b36c7 100644 --- a/app/Services/HashidService.php +++ b/app/Services/HashidService.php @@ -26,7 +26,7 @@ class HashidService public static function decode($short = false) { if (! $short) { - return; + return null; } $id = 0; foreach (str_split($short) as $needle) { diff --git a/app/Services/Internal/BeagleService.php b/app/Services/Internal/BeagleService.php index 848781769..a3e4215da 100644 --- a/app/Services/Internal/BeagleService.php +++ b/app/Services/Internal/BeagleService.php @@ -52,11 +52,11 @@ class BeagleService public static function getDiscover() { - if ((bool) config_cache('federation.activitypub.enabled') == false) { + if ((bool) config_cache('federation.activitypub.enabled') === false) { return []; } - if ((bool) config('instance.discover.beagle_api') == false) { + if ((bool) config('instance.discover.beagle_api') === false) { return []; } @@ -93,11 +93,11 @@ class BeagleService public static function getDiscoverPosts() { - if ((bool) config_cache('federation.activitypub.enabled') == false) { + if ((bool) config_cache('federation.activitypub.enabled') === false) { return []; } - if ((bool) config('instance.discover.beagle_api') == false) { + if ((bool) config('instance.discover.beagle_api') === false) { return []; } diff --git a/app/Services/MediaStorageService.php b/app/Services/MediaStorageService.php index bb7f8a739..3cd770d97 100644 --- a/app/Services/MediaStorageService.php +++ b/app/Services/MediaStorageService.php @@ -17,7 +17,7 @@ class MediaStorageService { public static function store(Media $media) { - if ((bool) config_cache('pixelfed.cloud_storage') == true && config('filesystems.default') === 'local') { + if ((bool) config_cache('pixelfed.cloud_storage') === true && config('filesystems.default') === 'local') { (new self)->cloudStore($media); } } @@ -28,7 +28,7 @@ class MediaStorageService return; } - if ((bool) config_cache('pixelfed.cloud_storage') == true && config('filesystems.default') === 'local') { + if ((bool) config_cache('pixelfed.cloud_storage') === true && config('filesystems.default') === 'local') { return (new self)->cloudMove($media); } } diff --git a/app/Services/ModLogService.php b/app/Services/ModLogService.php index 65edba482..64ab76152 100644 --- a/app/Services/ModLogService.php +++ b/app/Services/ModLogService.php @@ -100,9 +100,8 @@ class ModLogService if ($res == true) { return $ml; - } else { - return; } + return null; } public function load($modLog) diff --git a/app/Services/ReblogService.php b/app/Services/ReblogService.php index 503f6e54a..0affe0b98 100644 --- a/app/Services/ReblogService.php +++ b/app/Services/ReblogService.php @@ -30,12 +30,10 @@ class ReblogService if (! Redis::zcard(self::CACHE_KEY.$profileId)) { if (Cache::has(self::CACHE_SKIP_KEY.$profileId)) { return false; - } else { - self::warmCache($profileId); - sleep(1); - - return self::getFromRedis($profileId, $statusId); } + self::warmCache($profileId); + sleep(1); + return self::getFromRedis($profileId, $statusId); } $minId = SnowflakeService::byDate(now()->subMonths(12)); @@ -62,12 +60,10 @@ class ReblogService if (! Redis::zcard(self::CACHE_KEY.$profileId)) { if (Cache::has(self::CACHE_SKIP_KEY.$profileId)) { return false; - } else { - self::warmCache($profileId); - sleep(1); - - return self::getFromDatabase($profileId, $statusId); } + self::warmCache($profileId); + sleep(1); + return self::getFromDatabase($profileId, $statusId); } return Redis::zscore(self::CACHE_KEY.$profileId, $statusId) != null; diff --git a/app/Services/ResilientMediaStorageService.php b/app/Services/ResilientMediaStorageService.php index e3463695c..387ce757b 100644 --- a/app/Services/ResilientMediaStorageService.php +++ b/app/Services/ResilientMediaStorageService.php @@ -64,7 +64,7 @@ class ResilientMediaStorageService if (config('filesystems.disks.alt-secondary.enabled')) { $drivers[] = 'alt-secondary'; } - if (empty($drivers)) { + if ($drivers === []) { return false; } $key = array_rand($drivers, 1); diff --git a/app/Services/Status/UpdateStatusService.php b/app/Services/Status/UpdateStatusService.php index efd3d67d9..811c89df4 100644 --- a/app/Services/Status/UpdateStatusService.php +++ b/app/Services/Status/UpdateStatusService.php @@ -68,7 +68,7 @@ class UpdateStatusService } if (isset($attributes['sensitive'])) { if ($status->is_nsfw != (bool) $attributes['sensitive'] && - (bool) $attributes['sensitive'] == false) { + (bool) $attributes['sensitive'] === false) { $exists = ModLog::whereObjectType('App\Status::class') ->whereObjectId($status->id) ->whereAction('admin.status.moderate') diff --git a/app/Services/UserFilterService.php b/app/Services/UserFilterService.php index 0c87524b4..d7e6e5ead 100644 --- a/app/Services/UserFilterService.php +++ b/app/Services/UserFilterService.php @@ -103,7 +103,7 @@ class UserFilterService public static function mute(int $profile_id, int $muted_id) { - if ($profile_id == $muted_id) { + if ($profile_id === $muted_id) { return false; } $key = self::USER_MUTES_KEY.$profile_id; @@ -131,7 +131,7 @@ class UserFilterService public static function block(int $profile_id, int $blocked_id) { - if ($profile_id == $blocked_id) { + if ($profile_id === $blocked_id) { return false; } $key = self::USER_BLOCKS_KEY.$profile_id; diff --git a/app/Services/UserStorageService.php b/app/Services/UserStorageService.php index 178d6d4fc..6b73f498c 100644 --- a/app/Services/UserStorageService.php +++ b/app/Services/UserStorageService.php @@ -67,7 +67,7 @@ class UserStorageService { $user = User::find($id); if (! $user || $user->status) { - return; + return null; } $updatedVal = (int) floor(Media::whereUserId($id)->sum('size') / 1000); $user->storage_used = $updatedVal; diff --git a/app/Services/WebfingerService.php b/app/Services/WebfingerService.php index 9cde3d917..50237c6cd 100644 --- a/app/Services/WebfingerService.php +++ b/app/Services/WebfingerService.php @@ -38,7 +38,7 @@ class WebfingerService } $profile = Helpers::profileFetch($link); - if (! $profile) { + if (!$profile instanceof \App\Models\Profile) { return []; } diff --git a/app/Transformer/Api/Mastodon/v1/NotificationTransformer.php b/app/Transformer/Api/Mastodon/v1/NotificationTransformer.php index 820533244..74c7e353b 100644 --- a/app/Transformer/Api/Mastodon/v1/NotificationTransformer.php +++ b/app/Transformer/Api/Mastodon/v1/NotificationTransformer.php @@ -34,12 +34,10 @@ class NotificationTransformer extends Fractal\TransformerAbstract $status = Status::with('media')->find($item->item_id); if ($status) { return $this->item($status, new StatusTransformer); - } else { - return; } - } else { return; } + return; } public function replaceTypeVerb($verb) diff --git a/app/Util/ActivityPub/Inbox/HandlesCreates.php b/app/Util/ActivityPub/Inbox/HandlesCreates.php index 950a102c0..d77f9c58c 100644 --- a/app/Util/ActivityPub/Inbox/HandlesCreates.php +++ b/app/Util/ActivityPub/Inbox/HandlesCreates.php @@ -176,7 +176,7 @@ trait HandlesCreates $vote->save(); $tallies = $poll->cached_tallies; - $tallies[$choice] = $tallies[$choice] + 1; + $tallies[$choice] += 1; $poll->cached_tallies = $tallies; $poll->votes_count = array_sum($tallies); $poll->save(); @@ -291,8 +291,8 @@ trait HandlesCreates { return is_array($to) && is_array($cc) && - count($to) == 1 && - count($cc) == 0 && + count($to) === 1 && + count($cc) === 0 && parse_url($to[0], PHP_URL_HOST) == config('pixelfed.domain.app'); } @@ -318,7 +318,7 @@ trait HandlesCreates protected function determineDirectMessageVisibility(Profile $profile, Profile $actor): bool { if ($profile->user->settings->public_dm == false || $profile->is_private) { - return $profile->follows($actor) != true; + return $profile->follows($actor) !== true; } return false; @@ -364,12 +364,12 @@ trait HandlesCreates } } - if ($photos && $videos == 0) { - $dm->type = $photos == 1 ? 'photo' : 'photos'; + if ($photos && $videos === 0) { + $dm->type = $photos === 1 ? 'photo' : 'photos'; $dm->save(); } - if ($videos && $photos == 0) { - $dm->type = $videos == 1 ? 'video' : 'videos'; + if ($videos && $photos === 0) { + $dm->type = $videos === 1 ? 'video' : 'videos'; $dm->save(); } } diff --git a/app/Util/ActivityPub/Inbox/HandlesUndos.php b/app/Util/ActivityPub/Inbox/HandlesUndos.php index c5f63d051..5a021619b 100644 --- a/app/Util/ActivityPub/Inbox/HandlesUndos.php +++ b/app/Util/ActivityPub/Inbox/HandlesUndos.php @@ -73,7 +73,7 @@ trait HandlesUndos ->forceDelete(); if ($status->reblogs_count) { - $status->reblogs_count = $status->reblogs_count - 1; + $status->reblogs_count -= 1; $status->saveQuietly(); } @@ -137,7 +137,7 @@ trait HandlesUndos $status = Helpers::statusFirstOrFetch($objectUri); - if (! $status) { + if (!$status instanceof \App\Models\Status) { return; } @@ -150,7 +150,7 @@ trait HandlesUndos ->forceDelete(); if ($deleted > 0 && $status->likes_count > 0) { - $status->likes_count = $status->likes_count - 1; + $status->likes_count -= 1; $status->saveQuietly(); StatusService::del($status->id); } diff --git a/app/Util/Blurhash/Blurhash.php b/app/Util/Blurhash/Blurhash.php index f4fd4518d..6970d5d42 100644 --- a/app/Util/Blurhash/Blurhash.php +++ b/app/Util/Blurhash/Blurhash.php @@ -35,7 +35,7 @@ class Blurhash $scale = 1 / ($width * $height); for ($y = 0; $y < $components_y; $y++) { for ($x = 0; $x < $components_x; $x++) { - $normalisation = $x == 0 && $y == 0 ? 1 : 2; + $normalisation = $x === 0 && $y === 0 ? 1 : 2; $r = $g = $b = 0; for ($i = 0; $i < $width; $i++) { for ($j = 0; $j < $height; $j++) { diff --git a/app/Util/Lexer/Autolink.php b/app/Util/Lexer/Autolink.php index f16b61e26..7c8bc3912 100755 --- a/app/Util/Lexer/Autolink.php +++ b/app/Util/Lexer/Autolink.php @@ -804,7 +804,7 @@ class Autolink extends Regex if ($this->noopener) { $rel[] = 'noopener'; } - if (! empty($rel)) { + if ($rel !== []) { $attributes['rel'] = implode(' ', $rel); } if ($this->target) { diff --git a/app/Util/Lexer/Classifier.php b/app/Util/Lexer/Classifier.php index 7f9b3b623..a09e05bf3 100644 --- a/app/Util/Lexer/Classifier.php +++ b/app/Util/Lexer/Classifier.php @@ -117,7 +117,7 @@ class Classifier } else { $ignored = explode(',', $ignored); } - if ($type == 'spam' && in_array($word, $ignored)) { + if ($type === 'spam' && in_array($word, $ignored)) { return; } if (! isset($this->words[$type][$word])) { diff --git a/app/Util/Lexer/Extractor.php b/app/Util/Lexer/Extractor.php index 7a97a5cb3..647ec45e4 100755 --- a/app/Util/Lexer/Extractor.php +++ b/app/Util/Lexer/Extractor.php @@ -87,10 +87,10 @@ class Extractor extends Regex 'hashtags' => $this->extractHashtags($tweet), 'urls' => $this->extractURLs($tweet), 'mentions' => $this->extractMentionedUsernames($tweet), - 'replyto' => $this->extractRepliedUsernames($tweet), + 'replyto' => $this->extractRepliedUsernames(), 'hashtags_with_indices' => $this->extractHashtagsWithIndices($tweet), 'urls_with_indices' => $this->extractURLsWithIndices($tweet), - 'mentions_with_indices' => $this->extractMentionedUsernamesWithIndices($tweet), + 'mentions_with_indices' => $this->extractMentionedUsernamesWithIndices(), ]; } @@ -184,7 +184,7 @@ class Extractor extends Regex } $screen_name = mb_strtolower($mentionWithIndex['screen_name']); - if (empty($screen_name) or in_array($screen_name, $usernamesOnly)) { + if (empty($screen_name) || in_array($screen_name, $usernamesOnly)) { continue; } $usernamesOnly[] = $screen_name; @@ -464,7 +464,7 @@ class Extractor extends Regex [$all, $before, $at, $username, $list_slug, $outer] = array_pad($match, 6, ['', 0]); $start_position = $at[1] > 0 ? StringUtils::strlen(substr($tweet, 0, $at[1])) : $at[1]; $end_position = $start_position + StringUtils::strlen($at[0]) + StringUtils::strlen($username[0]); - $screenname = trim($all[0]) == '@'.$username[0] ? $username[0] : trim($all[0]); + $screenname = trim($all[0]) === '@' . $username[0] ? $username[0] : trim($all[0]); if ($this->activeUsersOnly == true) { if (! AutolinkService::mentionedUsernameExists($screenname)) { diff --git a/app/Util/Lexer/Hashtag.php b/app/Util/Lexer/Hashtag.php index bb6e6f2f4..ab57a50b0 100644 --- a/app/Util/Lexer/Hashtag.php +++ b/app/Util/Lexer/Hashtag.php @@ -8,7 +8,7 @@ class Hashtag { $hashtags = false; preg_match_all("/(?'); } } diff --git a/app/Util/Lexer/LooseAutolink.php b/app/Util/Lexer/LooseAutolink.php index be58d3c37..966e52d20 100755 --- a/app/Util/Lexer/LooseAutolink.php +++ b/app/Util/Lexer/LooseAutolink.php @@ -208,7 +208,7 @@ class LooseAutolink extends Autolink if ($this->nofollow) { $rel[] = 'nofollow'; } - if (! empty($rel)) { + if ($rel !== []) { $link .= ' rel="'.implode(' ', $rel).'"'; } if ($this->target) { @@ -245,7 +245,7 @@ class LooseAutolink extends Autolink if ($this->nofollow) { $rel[] = 'nofollow'; } - if (! empty($rel)) { + if ($rel !== []) { $link .= ' rel="'.implode(' ', $rel).'"'; } if ($this->target) { diff --git a/app/Util/Lexer/Nickname.php b/app/Util/Lexer/Nickname.php index 38e522cc2..8a3160ead 100644 --- a/app/Util/Lexer/Nickname.php +++ b/app/Util/Lexer/Nickname.php @@ -9,7 +9,7 @@ class Nickname public static function normalizeProfileUrl($url) { if (! Str::contains($url, '@')) { - return; + return null; } if (Str::startsWith($url, 'acct:')) { @@ -20,7 +20,7 @@ class Nickname $url = substr($url, 1); if (! Str::contains($url, '@')) { - return; + return null; } } diff --git a/app/Util/Lexer/PrettyNumber.php b/app/Util/Lexer/PrettyNumber.php index 24b43d3e4..1eb910140 100644 --- a/app/Util/Lexer/PrettyNumber.php +++ b/app/Util/Lexer/PrettyNumber.php @@ -27,7 +27,7 @@ class PrettyNumber public static function size($expression, $kb = false, $short = true) { if ($kb) { - $expression = $expression * 1024; + $expression *= 1024; } $size = intval($expression); $precision = 0; diff --git a/app/Util/Lexer/Validator.php b/app/Util/Lexer/Validator.php index 6f614273b..18630c334 100755 --- a/app/Util/Lexer/Validator.php +++ b/app/Util/Lexer/Validator.php @@ -313,8 +313,7 @@ class Validator extends Regex } [$scheme, $authority, $path, $query, $fragment] = array_pad($matches, 5, ''); // Check scheme, path, query, fragment: - if (($require_protocol && ! ( - self::isValidMatch($scheme, self::$patterns['validate_url_scheme']) && preg_match('/^https?$/i', $scheme)) + if (($require_protocol && (!self::isValidMatch($scheme, self::$patterns['validate_url_scheme']) || !preg_match('/^https?$/i', $scheme)) ) || ! self::isValidMatch($path, self::$patterns['validate_url_path']) || ! self::isValidMatch($query, self::$patterns['validate_url_query'], true) || ! self::isValidMatch($fragment, self::$patterns['validate_url_fragment'], true)) { return false; diff --git a/app/Util/Localization/Localization.php b/app/Util/Localization/Localization.php index 6f211ef92..1203e32a1 100644 --- a/app/Util/Localization/Localization.php +++ b/app/Util/Localization/Localization.php @@ -122,7 +122,7 @@ class Localization { $locales = static::locales(); - if (empty($locales)) { + if ($locales === []) { return null; } diff --git a/app/Util/Sentiment/Bouncer.php b/app/Util/Sentiment/Bouncer.php index b26dd6cdc..b1a045bb5 100644 --- a/app/Util/Sentiment/Bouncer.php +++ b/app/Util/Sentiment/Bouncer.php @@ -50,7 +50,7 @@ class Bouncer ->whereIn('id', $ids) ->count(); - return $count >= 1 ? true : false; + return $count >= 1; }); if ($exemption == true) {