fix: multiple bugs

- adds laravel 11 casts support to phpstan https://github.com/larastan/larastan/blob/2.x/UPGRADE.md#upgrading-to-296-from-295
- fixes multiple bugs found by phpstan
- removes dead code in torrent filter trait
- ignores three new files in phpstan.neon temp until debugged for timeouts
This commit is contained in:
HDVinnie
2024-06-19 13:43:59 -04:00
parent e634dfe730
commit c4cd52e23b
41 changed files with 106 additions and 110 deletions
@@ -539,11 +539,11 @@ class TorrentController extends BaseController
->when($request->filled('malId'), fn ($query) => $query->ofMal((int) $request->malId))
->when($request->filled('playlistId'), fn ($query) => $query->ofPlaylist((int) $request->playlistId))
->when($request->filled('collectionId'), fn ($query) => $query->ofCollection((int) $request->collectionId))
->when($request->filled('primaryLanguages'), fn ($query) => $query->ofOriginalLanguage($request->primaryLanguages))
->when($request->filled('primaryLanguages'), fn ($query) => $query->ofPrimaryLanguage($request->primaryLanguages))
->when($request->filled('adult'), fn ($query) => $query->ofAdult($request->boolean('adult')))
->when($request->filled('free'), fn ($query) => $query->ofFreeleech($request->free))
->when($request->filled('doubleup'), fn ($query) => $query->doubleup())
->when($request->filled('refundable'), fn ($query) => $query->ofRefundable($request->boolean('refundable')))
->when($request->filled('refundable'), fn ($query) => $query->refundable())
->when($request->filled('featured'), fn ($query) => $query->featured())
->when($request->filled('stream'), fn ($query) => $query->streamOptimized())
->when($request->filled('sd'), fn ($query) => $query->sd())
+1 -1
View File
@@ -53,7 +53,7 @@ class LeakerSearch extends Component
public string $sortDirection = 'desc';
/**
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator<User>
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator<History>
*/
#[Computed]
final public function leakers(): \Illuminate\Contracts\Pagination\LengthAwarePaginator
+1 -1
View File
@@ -63,7 +63,7 @@ class PersonSearch extends Component
* @return \Illuminate\Database\Eloquent\Collection<int, Person>
*/
#[Computed]
final public function firstCharacters()
final public function firstCharacters(): \Illuminate\Database\Eloquent\Collection
{
return Person::selectRaw('substr(name, 1, 1) as alpha, count(*) as count')
->when($this->search !== '', fn ($query) => $query->where('name', 'LIKE', '%'.$this->search.'%'))
+5 -5
View File
@@ -42,31 +42,31 @@ class TorrentRequestSearch extends Component
public string $requestor = '';
/**
* @var string[]
* @var array<int>
*/
#[Url(history: true)]
public array $categories = [];
/**
* @var string[]
* @var array<int>
*/
#[Url(history: true)]
public array $types = [];
/**
* @var string[]
* @var array<int>
*/
#[Url(history: true)]
public array $resolutions = [];
/**
* @var string[]
* @var array<int>
*/
#[Url(history: true)]
public array $genres = [];
/**
* @var string[]
* @var array<int>
*/
#[Url(history: true)]
public array $primaryLanguages = [];
+6 -6
View File
@@ -80,37 +80,37 @@ class TorrentSearch extends Component
public ?int $seasonNumber = null;
/**
* @var string[]
* @var array<int>
*/
#[Url(history: true)]
public array $categories = [];
/**
* @var string[]
* @var array<int>
*/
#[Url(history: true)]
public array $types = [];
/**
* @var string[]
* @var array<int>
*/
#[Url(history: true)]
public array $resolutions = [];
/**
* @var string[]
* @var array<int>
*/
#[Url(history: true)]
public array $genres = [];
/**
* @var string[]
* @var array<int>
*/
#[Url(history: true)]
public array $regions = [];
/**
* @var string[]
* @var array<int>
*/
#[Url(history: true)]
public array $distributors = [];
+1 -1
View File
@@ -55,7 +55,7 @@ class WatchlistSearch extends Component
}
/**
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator<\App\Models\User>
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator<Watchlist>
*/
#[Computed]
final public function users(): \Illuminate\Contracts\Pagination\LengthAwarePaginator
+1 -1
View File
@@ -46,7 +46,7 @@ class Apikey extends Model
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
* @return array{deleted_at: 'datetime'}
*/
protected function casts(): array
{
+1 -1
View File
@@ -47,7 +47,7 @@ class Application extends Model
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
* @return array{moderated_at: 'datetime'}
*/
protected function casts(): array
{
+5
View File
@@ -35,6 +35,11 @@ class Audit extends Model
{
use HasFactory;
/**
* @var string[]
*/
public array $values = [];
/**
* The attributes that are mass assignable.
*
+5 -5
View File
@@ -45,15 +45,15 @@ class BonExchange extends Model
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
* @return array{upload: 'bool', download: 'bool', personal_freeleech: 'bool', invite: 'bool'}
*/
protected function casts(): array
{
return [
'upload' => 'boolean',
'download' => 'boolean',
'personal_freeleech' => 'boolean',
'invite' => 'boolean',
'upload' => 'bool',
'download' => 'bool',
'personal_freeleech' => 'bool',
'invite' => 'bool',
];
}
+1 -1
View File
@@ -61,7 +61,7 @@ class BonTransactions extends Model
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
* @return array{cost: 'decimal:2'}
*/
protected function casts(): array
{
+1 -1
View File
@@ -46,7 +46,7 @@ class Bot extends Model
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
* @return array{name: 'string', cost: 'decimal:2'}
*/
protected function casts(): array
{
+5 -5
View File
@@ -50,15 +50,15 @@ class Category extends Model
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
* @return array{music_meta: 'bool', game_meta: 'bool', tv_meta: 'bool', movie_meta: 'bool'}
*/
protected function casts(): array
{
return [
'music_meta' => 'boolean',
'game_meta' => 'boolean',
'tv_meta' => 'boolean',
'movie_meta' => 'boolean',
'music_meta' => 'bool',
'game_meta' => 'bool',
'tv_meta' => 'bool',
'movie_meta' => 'bool',
];
}
+8 -5
View File
@@ -51,13 +51,16 @@ class Comment extends Model
protected $guarded = [];
/**
* The attributes that should be cast.
* Get the attributes that should be cast.
*
* @var array<string, string>
* @return array{anon: 'bool'}
*/
protected $casts = [
'anon' => 'bool',
];
protected function casts(): array
{
return [
'anon' => 'bool',
];
}
/**
* Belongs To A User.
-7
View File
@@ -34,13 +34,6 @@ class Credit extends Model
{
use HasFactory;
/**
* Indicates if the IDs are auto-incrementing.
*
* @var bool
*/
public $incrementing = true;
/**
* Indicates If The Model Should Be Timestamped.
*
+1 -1
View File
@@ -45,7 +45,7 @@ class EmailUpdate extends Model
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
* @return array{created_at: 'datetime', deleted_at: 'datetime'}
*/
protected function casts(): array
{
+4 -4
View File
@@ -47,14 +47,14 @@ class ForumPermission extends Model
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
* @return array{read_topic: 'bool', reply_topic: 'bool', start_topic: 'bool'}
*/
protected function casts(): array
{
return [
'read_topic' => 'boolean',
'reply_topic' => 'boolean',
'start_topic' => 'boolean',
'read_topic' => 'bool',
'reply_topic' => 'bool',
'start_topic' => 'bool',
];
}
+1 -1
View File
@@ -37,7 +37,7 @@ class Gift extends Model
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
* @return array{created_at: 'datetime'}
*/
protected function casts(): array
{
+2 -2
View File
@@ -62,12 +62,12 @@ class Group extends Model
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
* @return array{system_required: 'bool', min_ratio: 'decimal:2'}
*/
protected function casts(): array
{
return [
'system_required' => 'boolean',
'system_required' => 'bool',
'min_ratio' => 'decimal:2',
];
}
+3 -3
View File
@@ -62,14 +62,14 @@ class History extends Model
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
* @return array{completed_at: 'datetime', hitrun: 'bool', prewarn: 'bool'}
*/
protected function casts(): array
{
return [
'completed_at' => 'datetime',
'hitrun' => 'boolean',
'prewarn' => 'boolean',
'hitrun' => 'bool',
'prewarn' => 'bool',
];
}
+3 -3
View File
@@ -39,13 +39,13 @@ class Like extends Model
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
* @return array{like: 'bool', dislike: 'bool'}
*/
protected function casts(): array
{
return [
'like' => 'boolean',
'dislike' => 'boolean',
'like' => 'bool',
'dislike' => 'bool',
];
}
+1 -1
View File
@@ -46,7 +46,7 @@ class Passkey extends Model
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
* @return array{deleted_at: 'datetime'}
*/
protected function casts(): array
{
+4 -4
View File
@@ -46,14 +46,14 @@ class Peer extends Model
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
* @return array{active: 'bool', seeder: 'bool', connectable: 'bool'}
*/
protected function casts(): array
{
return [
'active' => 'boolean',
'seeder' => 'boolean',
'connectable' => 'boolean',
'active' => 'bool',
'seeder' => 'bool',
'connectable' => 'bool',
];
}
+1 -1
View File
@@ -37,7 +37,7 @@ class PostTip extends Model
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
* @return array{created_at: 'datetime'}
*/
protected function casts(): array
{
+2 -2
View File
@@ -46,12 +46,12 @@ class Resurrection extends Model
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
* @return array{rewarded: 'bool'}
*/
protected function casts(): array
{
return [
'rewarded' => 'boolean',
'rewarded' => 'bool',
];
}
+1 -1
View File
@@ -52,7 +52,7 @@ class Rss extends Model
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
* @return array{name: 'string', json_torrent: 'array', expected_fields: 'array'}
*/
protected function casts(): array
{
+1 -1
View File
@@ -46,7 +46,7 @@ class Rsskey extends Model
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
* @return array{deleted_at: 'datetime'}
*/
protected function casts(): array
{
+1 -1
View File
@@ -55,7 +55,7 @@ class Subtitle extends Model
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
* @return array{moderated_at: 'datetime'}
*/
protected function casts(): array
{
+1 -1
View File
@@ -49,7 +49,7 @@ class Ticket extends Model
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
* @return array{closed_at: 'datetime', reminded_at: 'datetime'}
*/
protected function casts(): array
{
+9 -9
View File
@@ -54,20 +54,20 @@ class Topic extends Model
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
* @return array{last_post_created_at: 'datetime', pinned: 'bool', approved: 'bool', denied: 'bool', solved: 'bool', invalid: 'bool', bug: 'bool', suggestion: 'bool', implemented: 'bool'}
*/
protected function casts(): array
{
return [
'last_post_created_at' => 'datetime',
'pinned' => 'boolean',
'approved' => 'boolean',
'denied' => 'boolean',
'solved' => 'boolean',
'invalid' => 'boolean',
'bug' => 'boolean',
'suggestion' => 'boolean',
'implemented' => 'boolean',
'pinned' => 'bool',
'approved' => 'bool',
'denied' => 'bool',
'solved' => 'bool',
'invalid' => 'bool',
'bug' => 'bool',
'suggestion' => 'bool',
'implemented' => 'bool',
];
}
+7 -7
View File
@@ -98,21 +98,21 @@ class Torrent extends Model
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
* @return array{tmdb: 'int', igdb: 'int', bumped_at: 'datetime', fl_until: 'datetime', du_until: 'datetime', doubleup: 'bool', refundable: 'bool', featured: 'bool', moderated_at: 'datetime', sticky: 'bool'}
*/
protected function casts(): array
{
return [
'tmdb' => 'integer',
'igdb' => 'integer',
'tmdb' => 'int',
'igdb' => 'int',
'bumped_at' => 'datetime',
'fl_until' => 'datetime',
'du_until' => 'datetime',
'doubleup' => 'boolean',
'refundable' => 'boolean',
'featured' => 'boolean',
'doubleup' => 'bool',
'refundable' => 'bool',
'featured' => 'bool',
'moderated_at' => 'datetime',
'sticky' => 'boolean',
'sticky' => 'bool',
];
}
+3 -3
View File
@@ -75,15 +75,15 @@ class TorrentRequest extends Model
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
* @return array{filled_when: 'datetime', approved_when: 'datetime', tmdb: 'int', igdb: 'int', bounty: 'decimal:2'}
*/
protected function casts(): array
{
return [
'filled_when' => 'datetime',
'approved_when' => 'datetime',
'tmdb' => 'integer',
'igdb' => 'integer',
'tmdb' => 'int',
'igdb' => 'int',
'bounty' => 'decimal:2',
];
}
+1 -1
View File
@@ -53,7 +53,7 @@ class TorrentRequestBounty extends Model
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
* @return array{seedbonus: 'decimal:2'}
*/
protected function casts(): array
{
+1 -1
View File
@@ -37,7 +37,7 @@ class TorrentTip extends Model
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
* @return array{created_at: 'datetime'}
*/
protected function casts(): array
{
+8 -8
View File
@@ -111,7 +111,7 @@ class User extends Authenticatable implements MustVerifyEmail
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
* @return array{last_login: 'datetime', last_action: 'datetime', disabled_at: 'datetime', hidden: 'bool', can_comment: 'bool', can_download: 'bool', can_request: 'bool', can_invite: 'bool', can_upload: 'bool', can_chat: 'bool', seedbonus: 'decimal:2'}
*/
protected function casts(): array
{
@@ -119,13 +119,13 @@ class User extends Authenticatable implements MustVerifyEmail
'last_login' => 'datetime',
'last_action' => 'datetime',
'disabled_at' => 'datetime',
'hidden' => 'boolean',
'can_comment' => 'boolean',
'can_download' => 'boolean',
'can_request' => 'boolean',
'can_invite' => 'boolean',
'can_upload' => 'boolean',
'can_chat' => 'boolean',
'hidden' => 'bool',
'can_comment' => 'bool',
'can_download' => 'bool',
'can_request' => 'bool',
'can_invite' => 'bool',
'can_upload' => 'bool',
'can_chat' => 'bool',
'seedbonus' => 'decimal:2',
];
}
+1 -1
View File
@@ -76,7 +76,7 @@ class UserNotification extends Model
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
* @return array{json_account_groups: 'array', json_mention_groups: 'array', json_request_groups: 'array', json_torrent_groups: 'array', json_forum_groups: 'array', json_following_groups: 'array', json_subscription_groups: 'array', json_bon_groups: 'array'}
*/
protected function casts(): array
{
+1 -1
View File
@@ -94,7 +94,7 @@ class UserPrivacy extends Model
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
* @return array{hidden: 'bool', json_profile_groups: 'array', json_torrent_groups: 'array', json_forum_groups: 'array', json_bon_groups: 'array', json_comment_groups: 'array', json_wishlist_groups: 'array', json_follower_groups: 'array', json_achievement_groups: 'array', json_rank_groups: 'array', json_request_groups: 'array', json_other_groups: 'array'}
*/
protected function casts(): array
{
+1 -1
View File
@@ -43,7 +43,7 @@ class UserSetting extends Model
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
* @return array{censor: 'bool', chat_hidden: 'bool', torrent_filters: 'bool', show_poster: 'bool'}
*/
protected function casts(): array
{
+2 -2
View File
@@ -48,13 +48,13 @@ class Warning extends Model
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
* @return array{expires_on: 'datetime', active: 'bool'}
*/
protected function casts(): array
{
return [
'expires_on' => 'datetime',
'active' => 'boolean',
'active' => 'bool',
];
}
-8
View File
@@ -327,14 +327,6 @@ trait TorrentFilter
$query->where('refundable', '=', 1);
}
/**
* @param Builder<Torrent> $query
*/
public function scopeOfRefundable(Builder $query, int $refundable): void
{
$query->where('refundable', '=', $refundable);
}
/**
* @param Builder<Torrent> $query
*/
+3
View File
@@ -15,5 +15,8 @@ parameters:
excludePaths:
- app/Helpers/Markdown
- app/Helpers/MarkdownExtra
- app/Http/Livewire/PersonCredit
- app/Http/Livewire/TorrentSearch
- routes/web.php
level: 7
checkOctaneCompatibility: true