Add phpstan level 7(#544)

This commit is contained in:
Saeed Vaziry
2025-03-12 13:31:10 +01:00
committed by GitHub
parent c22bb1fa80
commit 493cbb0849
437 changed files with 4505 additions and 2193 deletions

View File

@ -23,6 +23,7 @@
*/
class Backup extends AbstractModel
{
/** @use HasFactory<\Database\Factories\BackupFactory> */
use HasFactory;
protected $fillable = [
@ -46,13 +47,18 @@ public static function boot(): void
{
parent::boot();
static::deleting(function (Backup $backup) {
$backup->files()->each(function (BackupFile $file) {
static::deleting(function ($backup): void {
/** @var Backup $backup */
$backup->files()->each(function ($file): void {
/** @var BackupFile $file */
$file->delete();
});
});
}
/**
* @var array<string, string>
*/
public static array $statusColors = [
BackupStatus::RUNNING => 'success',
BackupStatus::FAILED => 'danger',
@ -62,31 +68,46 @@ public static function boot(): void
public function isCustomInterval(): bool
{
$intervals = array_keys(config('core.cronjob_intervals'));
$intervals = array_filter($intervals, fn ($interval) => $interval !== 'custom');
$intervals = array_filter($intervals, fn ($interval): bool => $interval !== 'custom');
return ! in_array($this->interval, $intervals);
}
/**
* @return BelongsTo<Server, covariant $this>
*/
public function server(): BelongsTo
{
return $this->belongsTo(Server::class);
}
/**
* @return BelongsTo<StorageProvider, covariant $this>
*/
public function storage(): BelongsTo
{
return $this->belongsTo(StorageProvider::class, 'storage_id');
}
/**
* @return BelongsTo<Database, covariant $this>
*/
public function database(): BelongsTo
{
return $this->belongsTo(Database::class)->withTrashed();
}
/**
* @return HasMany<BackupFile, covariant $this>
*/
public function files(): HasMany
{
return $this->hasMany(BackupFile::class, 'backup_id');
}
/**
* @return HasOne<BackupFile, covariant $this>
*/
public function lastFile(): HasOne
{
return $this->hasOne(BackupFile::class, 'backup_id')->latest();