Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/Community/Concerns/ActsAsCommunityMember.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\Pivot;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Spatie\Permission\Models\Role as SpatieRole;
Expand Down Expand Up @@ -88,7 +89,7 @@ public function gameListEntries(?UserGameListType $type = null): HasMany
*/
public function displayableRoles(): BelongsToMany
{
/** @var BelongsToMany<SpatieRole> */
/** @var BelongsToMany<SpatieRole, $this, Pivot, 'pivot'> */
return $this->roles()->where('display', '>', 0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ public function table(Table $table): Table
->orWhere('achievements_unpublished', '>', 0);
})
->whereDoesntHave('gameAchievementSets', function (Builder $query) use ($attachedAchievementSetIds) {
/** @var Builder<GameAchievementSet> $query */
$query->core()->whereIn('achievement_set_id', $attachedAchievementSetIds);
})
->orderBy('Title')
Expand Down
3 changes: 3 additions & 0 deletions app/Helpers/database/user-auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ function authenticateFromCookie(
* TOKEN
*/

/**
* @param-out int|null $permissionOut
*/
function authenticateFromAppToken(
?string &$userOut,
string $token,
Expand Down
1 change: 1 addition & 0 deletions app/Helpers/util/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ function getMysqliConnection(): mysqli

/**
* @deprecated
* @param string &...$inputs
*/
function sanitize_sql_inputs(int|string|null &...$inputs): void
{
Expand Down
3 changes: 3 additions & 0 deletions app/Helpers/util/string.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
use App\Support\Rules\CtypeAlnum;
use Illuminate\Support\Facades\Validator;

/**
* @param string &...$outputs
*/
function sanitize_outputs(string|int|null &...$outputs): void
{
/** @var string $output */
Expand Down
1 change: 1 addition & 0 deletions app/Models/EventAchievement.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ public function scopeActive(Builder $query, ?Carbon $timestamp = null): Builder
public function scopePublished(Builder $query): Builder
{
return $query->whereHas('achievement', function ($q) {
/** @var Builder<Achievement> $q */
$q->published();
});
}
Expand Down
2 changes: 2 additions & 0 deletions app/Models/EventAward.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use App\Community\Enums\AwardType;
use App\Support\Database\Eloquent\BaseModel;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
Expand All @@ -32,6 +33,7 @@ public function getBadgeCountAttribute(): int
->where('AwardData', $this->event_id)
->where('AwardDataExtra', $this->tier_index)
->whereHas('user', function ($query) {
/** @var Builder<User> $query */
$query->tracked();
})
->count();
Expand Down
7 changes: 6 additions & 1 deletion app/Platform/Actions/UpdateAchievementMetricsAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
use App\Models\Achievement;
use App\Models\Game;
use App\Models\PlayerAchievement;
use App\Models\User;
use App\Platform\Services\SearchIndexingService;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;

Expand Down Expand Up @@ -37,7 +39,10 @@ public function update(Game $game, Collection $achievements): void
$achievementIds = $achievements->pluck('ID')->all();
$unlockStats = PlayerAchievement::query()
->whereIn('player_achievements.achievement_id', $achievementIds)
->whereHas('user', function ($query) { $query->tracked(); })
->whereHas('user', function ($query) {
/** @var Builder<User> $query */
$query->tracked();
})
->groupBy('player_achievements.achievement_id')
->selectRaw('
player_achievements.achievement_id,
Expand Down
64 changes: 2 additions & 62 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
parameters:
ignoreErrors:
-
message: '#^Call to an undefined method Illuminate\\Database\\Eloquent\\Builder\<Illuminate\\Database\\Eloquent\\Model\>\:\:core\(\)\.$#'
identifier: method.notFound
count: 1
path: app/Filament/Resources/GameResource/RelationManagers/AchievementSetsRelationManager.php

-
message: '#^Parameter &\$permissionOut by\-ref type of function authenticateFromAppToken\(\) expects int\|null, Illuminate\\Database\\Eloquent\\Collection\<int, Illuminate\\Database\\Eloquent\\Model\> given\.$#'
identifier: parameterByRef.type
message: '#^Parameter &\$permissionOut @param\-out type of function authenticateFromAppToken\(\) expects int\|null, Illuminate\\Database\\Eloquent\\Collection\<int, Illuminate\\Database\\Eloquent\\Model\> given\.$#'
identifier: paramOut.type
count: 1
path: app/Helpers/database/user-auth.php

Expand Down Expand Up @@ -72,12 +66,6 @@ parameters:
count: 1
path: app/Models/Achievement.php

-
message: '#^Return type \(Illuminate\\Database\\Eloquent\\Relations\\BelongsTo\<App\\Models\\Trigger, \$this\(App\\Models\\Achievement\)\>\) of method App\\Models\\Achievement\:\:currentTrigger\(\) should be compatible with return type \(Illuminate\\Database\\Eloquent\\Relations\\BelongsTo\<App\\Models\\Trigger, App\\Models\\Achievement\>\) of method App\\Platform\\Contracts\\HasVersionedTrigger\<App\\Models\\Achievement\>\:\:currentTrigger\(\)$#'
identifier: method.childReturnType
count: 1
path: app/Models/Achievement.php

-
message: '#^Unable to resolve the template type TNewPivotModel in call to method Illuminate\\Database\\Eloquent\\Relations\\BelongsToMany\<App\\Models\\User,\$this\(App\\Models\\Achievement\),Illuminate\\Database\\Eloquent\\Relations\\Pivot,string\>\:\:using\(\)$#'
identifier: argument.templateType
Expand Down Expand Up @@ -126,18 +114,6 @@ parameters:
count: 1
path: app/Models/Event.php

-
message: '#^Call to an undefined method Illuminate\\Database\\Eloquent\\Builder\<Illuminate\\Database\\Eloquent\\Model\>\:\:published\(\)\.$#'
identifier: method.notFound
count: 1
path: app/Models/EventAchievement.php

-
message: '#^Call to an undefined method Illuminate\\Database\\Eloquent\\Builder\<Illuminate\\Database\\Eloquent\\Model\>\:\:tracked\(\)\.$#'
identifier: method.notFound
count: 1
path: app/Models/EventAward.php

-
message: '#^Parameter \#1 \$class of method Illuminate\\Database\\Eloquent\\Relations\\BelongsToMany\<App\\Models\\User,\$this\(App\\Models\\EventAward\),Illuminate\\Database\\Eloquent\\Relations\\Pivot,string\>\:\:using\(\) expects class\-string\<Illuminate\\Database\\Eloquent\\Relations\\Pivot\>, string given\.$#'
identifier: argument.type
Expand Down Expand Up @@ -174,12 +150,6 @@ parameters:
count: 1
path: app/Models/Game.php

-
message: '#^Return type \(Illuminate\\Database\\Eloquent\\Relations\\BelongsTo\<App\\Models\\Trigger, \$this\(App\\Models\\Game\)\>\) of method App\\Models\\Game\:\:currentTrigger\(\) should be compatible with return type \(Illuminate\\Database\\Eloquent\\Relations\\BelongsTo\<App\\Models\\Trigger, App\\Models\\Game\>\) of method App\\Platform\\Contracts\\HasVersionedTrigger\<App\\Models\\Game\>\:\:currentTrigger\(\)$#'
identifier: method.childReturnType
count: 1
path: app/Models/Game.php

-
message: '#^Unable to resolve the template type TNewPivotModel in call to method Illuminate\\Database\\Eloquent\\Relations\\BelongsToMany\<App\\Models\\User,\$this\(App\\Models\\Game\),Illuminate\\Database\\Eloquent\\Relations\\Pivot,string\>\:\:using\(\)$#'
identifier: argument.templateType
Expand Down Expand Up @@ -222,12 +192,6 @@ parameters:
count: 1
path: app/Models/Leaderboard.php

-
message: '#^Return type \(Illuminate\\Database\\Eloquent\\Relations\\BelongsTo\<App\\Models\\Trigger, \$this\(App\\Models\\Leaderboard\)\>\) of method App\\Models\\Leaderboard\:\:currentTrigger\(\) should be compatible with return type \(Illuminate\\Database\\Eloquent\\Relations\\BelongsTo\<App\\Models\\Trigger, App\\Models\\Leaderboard\>\) of method App\\Platform\\Contracts\\HasVersionedTrigger\<App\\Models\\Leaderboard\>\:\:currentTrigger\(\)$#'
identifier: method.childReturnType
count: 1
path: app/Models/Leaderboard.php

-
message: '#^Parameter \#1 \$class of method Illuminate\\Database\\Eloquent\\Relations\\BelongsToMany\<App\\Models\\Emulator,\$this\(App\\Models\\Platform\),Illuminate\\Database\\Eloquent\\Relations\\Pivot,string\>\:\:using\(\) expects class\-string\<Illuminate\\Database\\Eloquent\\Relations\\Pivot\>, string given\.$#'
identifier: argument.type
Expand Down Expand Up @@ -258,12 +222,6 @@ parameters:
count: 1
path: app/Models/Trigger.php

-
message: '#^Method App\\Models\\User\:\:displayableRoles\(\) should return Illuminate\\Database\\Eloquent\\Relations\\BelongsToMany\<Spatie\\Permission\\Models\\Role, \$this\(App\\Models\\User\), Illuminate\\Database\\Eloquent\\Relations\\Pivot, ''pivot''\> but returns Illuminate\\Database\\Eloquent\\Relations\\BelongsToMany\<Spatie\\Permission\\Models\\Role, Illuminate\\Database\\Eloquent\\Relations\\Pivot, ''pivot''\>\.$#'
identifier: return.type
count: 1
path: app/Models/User.php

-
message: '#^Method App\\Models\\User\:\:whereName\(\) should return Illuminate\\Database\\Eloquent\\Builder\<App\\Models\\User\> but returns Illuminate\\Database\\Eloquent\\Builder\<static\(App\\Models\\User\)\>\.$#'
identifier: return.type
Expand All @@ -282,12 +240,6 @@ parameters:
count: 1
path: app/Models/User.php

-
message: '#^Type string in generic type Illuminate\\Database\\Eloquent\\Relations\\BelongsToMany\<Spatie\\Permission\\Models\\Role, Illuminate\\Database\\Eloquent\\Relations\\Pivot, string\> in PHPDoc tag @var is not subtype of template type TPivotModel of Illuminate\\Database\\Eloquent\\Relations\\Pivot \= Illuminate\\Database\\Eloquent\\Relations\\Pivot of class Illuminate\\Database\\Eloquent\\Relations\\BelongsToMany\.$#'
identifier: generics.notSubtype
count: 1
path: app/Models/User.php

-
message: '#^Unable to resolve the template type TNewPivotModel in call to method Illuminate\\Database\\Eloquent\\Relations\\BelongsToMany\<App\\Models\\Achievement,\$this\(App\\Models\\User\),Illuminate\\Database\\Eloquent\\Relations\\Pivot,string\>\:\:using\(\)$#'
identifier: argument.templateType
Expand All @@ -306,18 +258,6 @@ parameters:
count: 1
path: app/Platform/Actions/BuildGameListAction.php

-
message: '#^PHPDoc tag @var with type array\<int, array\{achievement\?\: array\}\> is not subtype of native type array\<int, array\{achievement\?\: array\{ID\: int, Title\: string, Description\: string, Points\: int, TrueRatio\: float, BadgeName\: string, Flags\: int\}\}\>\.$#'
identifier: varTag.nativeType
count: 1
path: app/Platform/Actions/BuildPlayerGameActivityDataAction.php

-
message: '#^Call to an undefined method Illuminate\\Database\\Eloquent\\Builder\<Illuminate\\Database\\Eloquent\\Model\>\:\:tracked\(\)\.$#'
identifier: method.notFound
count: 1
path: app/Platform/Actions/UpdateAchievementMetricsAction.php

-
message: '#^Parameter \#2 \$syncData of method App\\Platform\\Actions\\UpsertGameCoreAchievementSetFromLegacyFlagsAction\:\:syncAchievementSetAchievements\(\) expects Illuminate\\Support\\Collection\<int, array\{created_at\: Carbon\\Carbon\|string, updated_at\: Carbon\\Carbon\|string, order_column\: int\}\>, Illuminate\\Support\\Collection\<int, array\{created_at\: mixed, updated_at\: mixed, order_column\: mixed\}\> given\.$#'
identifier: argument.type
Expand Down
5 changes: 5 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ parameters:
# lib/database/user-activity.php
- '#Offset (.*) does not exist on#'
- '#Unable to resolve the template type TMapWithKeysValue in call to method Illuminate\\Support\\Collection<\*NEVER\*,\*NEVER\*>::mapWithKeys\(\)#'
# False positives from PHPStan being overly strict about closure type hints
- identifier: varTag.nativeType
# Laravel template covariance limitations - these are framework-level issues we can't resolve
- identifier: method.childReturnType
- '#Template type.*is not covariant#'

excludePaths:
# unrelated directories
Expand Down