From 6d8ad3885a8d90541d2363334abab8ed030f9309 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 3 Sep 2026 13:45:45 +0930 Subject: [PATCH] Convert string class references to ::class Applies the ::class conversion from pixelfed-staging PR #9 (patch 1/21), formatted with Pint (short imported ::class form). Excludes the ModelNamespaceMigrationTest namespace assertions, which intentionally compare against literal namespace strings. --- .../Admin/AdminReportController.php | 28 +++++++++---------- .../AdminShadowFilterController.php | 2 +- app/Http/Resources/AdminReport.php | 5 ++-- app/Models/AdminShadowFilter.php | 2 +- tests/Feature/NotificationServiceTest.php | 3 +- 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/app/Http/Controllers/Admin/AdminReportController.php b/app/Http/Controllers/Admin/AdminReportController.php index e05e846f2..293ac7b1f 100644 --- a/app/Http/Controllers/Admin/AdminReportController.php +++ b/app/Http/Controllers/Admin/AdminReportController.php @@ -230,7 +230,7 @@ trait AdminReportController AccountInterstitial::chunk(500, function ($reports) { foreach ($reports as $report) { - if (! in_array($report->item_type, ['App\Status', 'App\Models\Status'])) { + if (! in_array($report->item_type, ['App\Status', Status::class])) { continue; } @@ -339,7 +339,7 @@ trait AdminReportController if ($action == 'approve-all') { AccountInterstitial::whereType('post.autospam') - ->whereIn('item_type', ['App\Status', 'App\Models\Status']) + ->whereIn('item_type', ['App\Status', Status::class]) ->whereNull('appeal_handled_at') ->whereUserId($appeal->user_id) ->get() @@ -365,7 +365,7 @@ trait AdminReportController if ($action == 'mark-spammer') { AccountInterstitial::whereType('post.autospam') - ->whereIn('item_type', ['App\Status', 'App\Models\Status']) + ->whereIn('item_type', ['App\Status', Status::class]) ->whereNull('appeal_handled_at') ->whereUserId($appeal->user_id) ->update(['appeal_handled_at' => $now, 'is_spam' => true]); @@ -780,7 +780,7 @@ trait AdminReportController ->save(); Report::where('reported_profile_id', $profile->id) - ->whereIn('object_type', ['App\Story', 'App\Models\Story']) + ->whereIn('object_type', ['App\Story', Story::class]) ->whereNull('admin_seen') ->update([ 'admin_seen' => now(), @@ -807,9 +807,9 @@ trait AdminReportController case 'nsfw': $profile = null; - if (in_array($report->object_type, ['App\Profile', 'App\Models\Profile'])) { + if (in_array($report->object_type, ['App\Profile', Profile::class])) { $profile = Profile::find($report->object_id); - } elseif (in_array($report->object_type, ['App\Status', 'App\Models\Status'])) { + } elseif (in_array($report->object_type, ['App\Status', Status::class])) { $status = Status::find($report->object_id); if (! $status) { return [200]; @@ -867,9 +867,9 @@ trait AdminReportController case 'unlist': $profile = null; - if (in_array($report->object_type, ['App\Profile', 'App\Models\Profile'])) { + if (in_array($report->object_type, ['App\Profile', Profile::class])) { $profile = Profile::find($report->object_id); - } elseif (in_array($report->object_type, ['App\Status', 'App\Models\Status'])) { + } elseif (in_array($report->object_type, ['App\Status', Status::class])) { $status = Status::find($report->object_id); if (! $status) { return [200]; @@ -927,9 +927,9 @@ trait AdminReportController case 'private': $profile = null; - if (in_array($report->object_type, ['App\Profile', 'App\Models\Profile'])) { + if (in_array($report->object_type, ['App\Profile', Profile::class])) { $profile = Profile::find($report->object_id); - } elseif (in_array($report->object_type, ['App\Status', 'App\Models\Status'])) { + } elseif (in_array($report->object_type, ['App\Status', Status::class])) { $status = Status::find($report->object_id); if (! $status) { return [200]; @@ -991,9 +991,9 @@ trait AdminReportController } $profile = null; - if (in_array($report->object_type, ['App\Profile', 'App\Models\Profile'])) { + if (in_array($report->object_type, ['App\Profile', Profile::class])) { $profile = Profile::find($report->object_id); - } elseif (in_array($report->object_type, ['App\Status', 'App\Models\Status'])) { + } elseif (in_array($report->object_type, ['App\Status', Status::class])) { $status = Status::find($report->object_id); if (! $status) { return [200]; @@ -1304,7 +1304,7 @@ trait AdminReportController if ($action == 'mark-all-read') { AccountInterstitial::whereType('post.autospam') - ->whereIn('item_type', ['App\Status', 'App\Models\Status']) + ->whereIn('item_type', ['App\Status', Status::class]) ->whereNull('appeal_handled_at') ->whereUserId($appeal->user_id) ->update([ @@ -1315,7 +1315,7 @@ trait AdminReportController if ($action == 'mark-all-not-spam') { AccountInterstitial::whereType('post.autospam') - ->whereIn('item_type', ['App\Status', 'App\Models\Status']) + ->whereIn('item_type', ['App\Status', Status::class]) ->whereUserId($appeal->user_id) ->get() ->each(function ($report) use ($meta) { diff --git a/app/Http/Controllers/AdminShadowFilterController.php b/app/Http/Controllers/AdminShadowFilterController.php index 5e2ae3ab8..430973e19 100644 --- a/app/Http/Controllers/AdminShadowFilterController.php +++ b/app/Http/Controllers/AdminShadowFilterController.php @@ -37,7 +37,7 @@ class AdminShadowFilterController extends Controller ->pluck('id') ->toArray(); - return $q->whereIn('item_type', ['App\Profile', 'App\Models\Profile'])->whereIn('item_id', $ids); + return $q->whereIn('item_type', ['App\Profile', Profile::class])->whereIn('item_id', $ids); }) ->latest() ->paginate(10) diff --git a/app/Http/Resources/AdminReport.php b/app/Http/Resources/AdminReport.php index 470a4f715..8fc2977c1 100644 --- a/app/Http/Resources/AdminReport.php +++ b/app/Http/Resources/AdminReport.php @@ -2,6 +2,7 @@ namespace App\Http\Resources; +use App\Models\Status; use App\Models\Story; use App\Services\AccountService; use App\Services\StatusService; @@ -42,11 +43,11 @@ class AdminReport extends JsonResource 'created_at' => $this->created_at, ]; - if ($this->object_id && in_array($this->object_type, ['App\Models\Status', 'App\Status'])) { + if ($this->object_id && in_array($this->object_type, [Status::class, 'App\Status'])) { $res['status'] = StatusService::get($this->object_id, false); } - if ($this->object_id && in_array($this->object_type, ['App\Models\Story', 'App\Story'])) { + if ($this->object_id && in_array($this->object_type, [Story::class, 'App\Story'])) { $story = Story::find($this->object_id); if ($story) { $res['story'] = $story->toAdminEntity(); diff --git a/app/Models/AdminShadowFilter.php b/app/Models/AdminShadowFilter.php index d5b9f81cf..319d6d913 100644 --- a/app/Models/AdminShadowFilter.php +++ b/app/Models/AdminShadowFilter.php @@ -22,7 +22,7 @@ class AdminShadowFilter extends Model public function account() { - if (in_array($this->item_type, ['App\Profile', 'App\Models\Profile'])) { + if (in_array($this->item_type, ['App\Profile', Profile::class])) { return AccountService::get($this->item_id, true); } } diff --git a/tests/Feature/NotificationServiceTest.php b/tests/Feature/NotificationServiceTest.php index 3c14814e2..d0d356808 100644 --- a/tests/Feature/NotificationServiceTest.php +++ b/tests/Feature/NotificationServiceTest.php @@ -1,5 +1,6 @@ profile_id, null, 1, - 'App\Models\Group' + Group::class ); expect($notification->action)->toBeNull();