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.
pull/7059/head
Your Name 3 weeks ago
parent 802db3791d
commit 6d8ad3885a

@ -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) {

@ -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)

@ -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();

@ -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);
}
}

@ -1,5 +1,6 @@
<?php
use App\Models\Group;
use App\Models\Notification;
use App\Models\Profile;
use App\Models\Status;
@ -62,7 +63,7 @@ describe('NotificationService::createNotification', function () {
$user->profile_id,
null,
1,
'App\Models\Group'
Group::class
);
expect($notification->action)->toBeNull();

Loading…
Cancel
Save