Skip to content

Commit a49cf9f

Browse files
authored
chore: upgrade to laravel 11 (RetroAchievements#2627)
1 parent bfe3061 commit a49cf9f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+2216
-1898
lines changed

Diff for: app/Community/Commands/ConvertUserShortcodesToUseIds.php

+8
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ private function migrateForumShortcodes(): void
4141
// Collect all usernames to fetch user IDs in bulk.
4242
$usernames = [];
4343

44+
/** @var ForumTopicComment $forumTopicComment */
4445
foreach ($forumTopicComments as $forumTopicComment) {
4546
preg_match_all('/\[user=([^\]]+)\]/', $forumTopicComment->Payload, $matches);
4647
$usernames = array_merge($usernames, array_map('strtolower', $matches[1]));
@@ -51,6 +52,7 @@ private function migrateForumShortcodes(): void
5152
$users = User::whereIn(DB::raw('LOWER(User)'), $usernames)->get()->keyBy(fn ($user) => strtolower($user->User));
5253

5354
// Process each comment.
55+
/** @var ForumTopicComment $forumTopicComment */
5456
foreach ($forumTopicComments as $forumTopicComment) {
5557
$originalPayload = $forumTopicComment->Payload;
5658
$updatedPayload = preg_replace_callback('/\[user=([^\]]+)\]/i', function ($matches) use ($users) {
@@ -86,6 +88,7 @@ private function migrateMessageShortcodes(): void
8688
// Collect all usernames to fetch user IDs in bulk.
8789
$usernames = [];
8890

91+
/** @var Message $message */
8992
foreach ($messages as $message) {
9093
preg_match_all('/\[user=([^\]]+)\]/', $message->body, $matches);
9194
$usernames = array_merge($usernames, array_map('strtolower', $matches[1]));
@@ -96,6 +99,7 @@ private function migrateMessageShortcodes(): void
9699
$users = User::whereIn(DB::raw('LOWER(User)'), $usernames)->get()->keyBy(fn ($user) => strtolower($user->User));
97100

98101
// Process each message.
102+
/** @var Message $message */
99103
foreach ($messages as $message) {
100104
$originalBody = $message->body;
101105
$updatedBody = preg_replace_callback('/\[user=([^\]]+)\]/i', function ($matches) use ($users) {
@@ -131,6 +135,7 @@ private function undoForumMigration(): void
131135
// Collect all user IDs to fetch usernames in bulk.
132136
$userIds = [];
133137

138+
/** @var ForumTopicComment $forumTopicComment */
134139
foreach ($forumTopicComments as $forumTopicComment) {
135140
preg_match_all('/\[user=(\d+)\]/i', $forumTopicComment->Payload, $matches);
136141
$userIds = array_merge($userIds, $matches[1]);
@@ -141,6 +146,7 @@ private function undoForumMigration(): void
141146
$users = User::whereIn('ID', $userIds)->get()->keyBy('ID');
142147

143148
// Process each comment.
149+
/** @var ForumTopicComment $forumTopicComment */
144150
foreach ($forumTopicComments as $forumTopicComment) {
145151
$originalPayload = $forumTopicComment->Payload;
146152
$updatedPayload = preg_replace_callback('/\[user=(\d+)\]/i', function ($matches) use ($users) {
@@ -176,6 +182,7 @@ private function undoMessagesMigration(): void
176182
// Collect all user IDs to fetch usernames in bulk.
177183
$userIds = [];
178184

185+
/** @var Message $message */
179186
foreach ($messages as $message) {
180187
preg_match_all('/\[user=(\d+)\]/i', $message->body, $matches);
181188
$userIds = array_merge($userIds, $matches[1]);
@@ -186,6 +193,7 @@ private function undoMessagesMigration(): void
186193
$users = User::whereIn('ID', $userIds)->get()->keyBy('ID');
187194

188195
// Process each message.
196+
/** @var Message $message */
189197
foreach ($messages as $message) {
190198
$originalBody = $message->body;
191199
$updatedBody = preg_replace_callback('/\[user=(\d+)\]/i', function ($matches) use ($users) {

Diff for: app/Community/Controllers/ForumTopicController.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ public function show(Request $request, ForumTopic $topic, ?string $slug = null):
5959
$topic->load([
6060
'forum',
6161
'user',
62-
/*
63-
* eager loading won't let us have a grid paginator for a morphed relationship
64-
*/
62+
/*
63+
* eager loading won't let us have a grid paginator for a morphed relationship
64+
*/
6565
// 'comments' => function($query){
6666
// $query->sort('created_at', 'asc')->paginate();
6767
// },

Diff for: app/Components/Concerns/DeferLoading.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function ready(): void
2222
/**
2323
* @return array|LengthAwarePaginator<Model>|Collection<int, Model>|null
2424
*/
25-
protected function loadDeferred(): array|null|LengthAwarePaginator|Collection
25+
protected function loadDeferred(): array|LengthAwarePaginator|Collection|null
2626
{
2727
if ($this->defer && !$this->ready) {
2828
return null;

Diff for: app/Components/Supersearch.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private function performSearches(array $searchables): void
100100
/**
101101
* @return Collection<int, Model>|null
102102
*/
103-
private function searchResource(string $resourceName, string $resourceClass, array $options = []): Collection|null
103+
private function searchResource(string $resourceName, string $resourceClass, array $options = []): ?Collection
104104
{
105105
try {
106106
$query = $this->resourceQuery($resourceName);

Diff for: app/Concerns/HasAvatar.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace App\Concerns;
66

7-
use Spatie\Image\Manipulations;
7+
use Spatie\Image\Enums\Fit;
88

99
trait HasAvatar
1010
{
@@ -50,8 +50,8 @@ public function registerAvatarMediaCollection(): void
5050
$this->addMediaConversion($iconSize)
5151
->nonQueued()
5252
->format('png')
53-
->fit(Manipulations::FIT_CONTAIN, $width, $height)->apply()
54-
->fit(Manipulations::FIT_FILL, $width, $height)
53+
->fit(Fit::Contain, $width, $height)
54+
->fit(Fit::Fill, $width, $height)
5555
->optimize();
5656
}
5757
});

Diff for: app/Data/ForumTopicData.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ public function __construct(
1717
public int $id,
1818
public string $title,
1919
public Carbon $createdAt,
20-
public ?UserData $user = null,
2120
public Lazy|ForumTopicCommentData $latestComment,
2221
public Lazy|int $commentCount24h,
2322
public Lazy|int $oldestComment24hId,
2423
public Lazy|int $commentCount7d,
2524
public Lazy|int $oldestComment7dId,
26-
) {
25+
public ?UserData $user = null,
26+
) {
2727
}
2828

2929
public static function fromRecentlyActiveTopic(array $topic): self

Diff for: app/Filament/Pages/ResourceAuditLog.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function getFieldLabel(string $name): string
7575
}
7676

7777
/**
78-
* @return Collection<string, \Illuminate\Contracts\Support\Htmlable|string|null>
78+
* @return Collection<int|string, mixed>
7979
*/
8080
protected function createFieldLabelMap(): Collection
8181
{

Diff for: app/Filament/Resources/GameResource.php

+20-20
Original file line numberDiff line numberDiff line change
@@ -303,25 +303,25 @@ public static function form(Form $form): Form
303303
}
304304
}),
305305

306-
Forms\Components\DatePicker::make('released_at')
307-
->label('Earliest Release Date')
308-
->native(false)
309-
->minDate('1970-01-01')
310-
->maxDate(now())
311-
->displayFormat('F j, Y')
312-
->reactive(),
313-
314-
Forms\Components\ToggleButtons::make('released_at_granularity')
315-
->label('Release Date Precision')
316-
->options([
317-
'day' => 'Day',
318-
'month' => 'Month',
319-
'year' => 'Year',
320-
])
321-
->inline()
322-
->default('day')
323-
->reactive(),
324-
]),
306+
Forms\Components\DatePicker::make('released_at')
307+
->label('Earliest Release Date')
308+
->native(false)
309+
->minDate('1970-01-01')
310+
->maxDate(now())
311+
->displayFormat('F j, Y')
312+
->reactive(),
313+
314+
Forms\Components\ToggleButtons::make('released_at_granularity')
315+
->label('Release Date Precision')
316+
->options([
317+
'day' => 'Day',
318+
'month' => 'Month',
319+
'year' => 'Year',
320+
])
321+
->inline()
322+
->default('day')
323+
->reactive(),
324+
]),
325325
]);
326326
}
327327

@@ -437,7 +437,7 @@ public static function table(Table $table): Table
437437
Tables\Actions\Action::make('audit-log')
438438
->url(fn ($record) => GameResource::getUrl('audit-log', ['record' => $record]))
439439
->icon('fas-clock-rotate-left'),
440-
]),
440+
]),
441441
])
442442
->bulkActions([
443443
Tables\Actions\BulkActionGroup::make([

Diff for: app/Filament/Resources/GameResource/RelationManagers/MemoryNotesRelationManager.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function table(Table $table): Table
8686
->label('Body')
8787
->autosize()
8888
->required(),
89-
])
89+
])
9090
->modalHeading(function (MemoryNote $memoryNote): string {
9191
return "Edit Note at {$memoryNote->address_hex}";
9292
})

Diff for: app/Filament/Resources/LeaderboardResource/RelationManagers/EntriesRelationManager.php

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace App\Filament\Resources\LeaderboardResource\RelationManagers;
66

7+
use App\Models\Leaderboard;
78
use App\Models\LeaderboardEntry;
89
use App\Platform\Actions\RemoveLeaderboardEntry;
910
use App\Platform\Enums\ValueFormat;
@@ -59,6 +60,7 @@ public function table(Table $table): Table
5960
->dateTime(),
6061
])
6162
->defaultSort('score', function () {
63+
/** @var Leaderboard $leaderboard */
6264
$leaderboard = $this->getRelationship()->getParent();
6365

6466
return $leaderboard->rank_asc ? 'asc' : 'desc';

Diff for: app/Helpers/database/forum.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ function generateGameForumTopic(User $user, int $gameId): ?ForumTopicComment
329329
}
330330

331331
/**
332-
* @return Collection<int, array>
332+
* @return Collection<int, non-empty-array>
333333
*/
334334
function getRecentForumPosts(
335335
int $offset,
@@ -382,6 +382,7 @@ function getRecentForumPosts(
382382
ORDER BY LatestComments.DateCreated DESC
383383
LIMIT 0, :limit";
384384

385+
/** @var Collection<int, non-empty-array> */
385386
return legacyDbFetchAll($query, $bindings)
386387
->map(function ($post) use ($numMessageChars) {
387388
$post['ShortMsg'] = mb_substr($post['Payload'], 0, $numMessageChars);

Diff for: app/Helpers/database/hash.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ function getGameIDFromMD5(string $md5): int
5757
*/
5858
function getHashList(int $offset, int $count, ?string $searchedHash): array
5959
{
60-
$query = GameHash::with(['user', 'game' => function ($query) {
61-
$query->select('ID', 'Title', 'ImageIcon', 'ConsoleID');
62-
},
63-
'game.system' => function ($query) {
64-
$query->select('ID', 'Name');
65-
}])
60+
$query =
61+
GameHash::with(['user', 'game' => function ($query) {
62+
$query->select('ID', 'Title', 'ImageIcon', 'ConsoleID');
63+
}, 'game.system' => function ($query) {
64+
$query->select('ID', 'Name');
65+
}])
6666
->select('md5', 'game_id', 'user_id', 'created_at');
6767

6868
if (!empty($searchedHash)) {

Diff for: app/Helpers/render/game.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,9 @@ function renderGameBreadcrumb(array|int $data, bool $addLinkToLastCrumb = true):
104104
:rawTitle="$rawTitle"
105105
:showTags="$showTags"
106106
/>', [
107-
'rawTitle' => $mainTitle,
108-
'showTags' => false,
109-
]
110-
);
107+
'rawTitle' => $mainTitle,
108+
'showTags' => false,
109+
]);
111110

112111
if ($renderedMain !== $mainTitle) {
113112
// In the rare case of a same-console derived game sharing identical

Diff for: app/Helpers/util/recaptcha.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,11 @@ function recaptcha_check_answer($privkey, $remoteip, $challenge, $response, $ext
167167
RECAPTCHA_VERIFY_SERVER,
168168
"/recaptcha/api/verify",
169169
[
170-
'privatekey' => $privkey,
171-
'remoteip' => $remoteip,
172-
'challenge' => $challenge,
173-
'response' => $response,
174-
] + $extra_params
170+
'privatekey' => $privkey,
171+
'remoteip' => $remoteip,
172+
'challenge' => $challenge,
173+
'response' => $response,
174+
] + $extra_params
175175
);
176176

177177
$answers = explode("\n", $response[1]);

Diff for: app/Models/Achievement.php

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class Achievement extends BaseModel implements HasComments
4141
/*
4242
* Shared Traits
4343
*/
44+
/** @use HasFactory<AchievementFactory> */
4445
use HasFactory;
4546

4647
use Searchable;

Diff for: app/Models/AchievementSet.php

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
class AchievementSet extends BaseModel
1717
{
18+
/** @use HasFactory<AchievementSetFactory> */
1819
use HasFactory;
1920
use SoftDeletes;
2021
// TODO use LogsActivity;

Diff for: app/Models/AchievementSetClaim.php

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
class AchievementSetClaim extends BaseModel
1818
{
19+
/** @use HasFactory<AchievementSetClaimFactory> */
1920
use HasFactory;
2021

2122
// TODO rename SetClaim to achievement_set_claims

Diff for: app/Models/Comment.php

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class Comment extends BaseModel
1818
{
1919
use Searchable;
2020
use SoftDeletes;
21+
/** @use HasFactory<CommentFactory> */
2122
use HasFactory;
2223

2324
// TODO rename Comment table to comments

Diff for: app/Models/Emulator.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use Illuminate\Database\Eloquent\Relations\HasOne;
1313
use Illuminate\Database\Eloquent\SoftDeletes;
1414
use Spatie\EloquentSortable\SortableTrait;
15-
use Spatie\Image\Manipulations;
15+
use Spatie\Image\Enums\Fit;
1616
use Spatie\MediaLibrary\HasMedia;
1717
use Spatie\MediaLibrary\InteractsWithMedia;
1818
use Spatie\MediaLibrary\MediaCollections\Models\Media;
@@ -40,15 +40,15 @@ public function registerMediaCollections(): void
4040
$this->addMediaConversion('2xl')
4141
->nonQueued()
4242
->format('png')
43-
->fit(Manipulations::FIT_MAX, 500, 500);
43+
->fit(Fit::Max, 500, 500);
4444
$this->addMediaConversion('32')
4545
->nonQueued()
4646
->format('png')
47-
->fit(Manipulations::FIT_MAX, 64, 64);
47+
->fit(Fit::Max, 64, 64);
4848
$this->addMediaConversion('64')
4949
->nonQueued()
5050
->format('png')
51-
->fit(Manipulations::FIT_MAX, 64, 64);
51+
->fit(Fit::Max, 64, 64);
5252
});
5353
}
5454

Diff for: app/Models/ForumTopic.php

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace App\Models;
66

77
use App\Support\Database\Eloquent\BaseModel;
8+
use Database\Factories\ForumTopicFactory;
89
use Illuminate\Database\Eloquent\Builder;
910
use Illuminate\Database\Eloquent\Factories\HasFactory;
1011
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -16,6 +17,7 @@
1617

1718
class ForumTopic extends BaseModel
1819
{
20+
/** @use HasFactory<ForumTopicFactory> */
1921
use HasFactory;
2022
use Searchable;
2123
use SoftDeletes;

Diff for: app/Models/ForumTopicComment.php

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
class ForumTopicComment extends BaseModel
1616
{
17+
/** @use HasFactory<ForumTopicCommentFactory> */
1718
use HasFactory;
1819
use Searchable;
1920
use SoftDeletes;

Diff for: app/Models/Game.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
use Laravel\Scout\Searchable;
2121
use Spatie\Activitylog\LogOptions;
2222
use Spatie\Activitylog\Traits\LogsActivity;
23-
use Spatie\Image\Manipulations;
23+
use Spatie\Image\Enums\Fit;
2424
use Spatie\MediaLibrary\HasMedia;
2525
use Spatie\MediaLibrary\InteractsWithMedia;
2626

@@ -38,6 +38,7 @@ class Game extends BaseModel implements HasComments, HasMedia
3838
use LogsActivity {
3939
LogsActivity::activities as auditLog;
4040
}
41+
/** @use HasFactory<GameFactory> */
4142
use HasFactory;
4243
use InteractsWithMedia;
4344

@@ -165,8 +166,8 @@ public function registerMediaCollections(): void
165166
$this->addMediaConversion($iconSize)
166167
->nonQueued()
167168
->format('png')
168-
->fit(Manipulations::FIT_CONTAIN, $width, $height)->apply()
169-
->fit(Manipulations::FIT_FILL, $width, $height)
169+
->fit(Fit::Contain, $width, $height)
170+
->fit(Fit::Fill, $width, $height)
170171
->optimize();
171172
}
172173
});

0 commit comments

Comments
 (0)