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

@ -21,8 +21,14 @@ class BackupsList extends Widget
{
public Server $server;
/**
* @var array<string>
*/
protected $listeners = ['$refresh'];
/**
* @return Builder<Backup>
*/
protected function getTableQuery(): Builder
{
return Backup::query()->where('server_id', $this->server->id);
@ -56,6 +62,9 @@ protected function getTableColumns(): array
public function table(Table $table): Table
{
/** @var \App\Models\User $user */
$user = auth()->user();
return $table
->heading(null)
->query($this->getTableQuery())
@ -65,8 +74,8 @@ public function table(Table $table): Table
->hiddenLabel()
->icon('heroicon-o-pencil')
->tooltip('Edit Configuration')
->disabled(fn (Backup $record) => ! in_array($record->status, ['running', 'failed']))
->authorize(fn (Backup $record) => auth()->user()->can('update', $record))
->disabled(fn (Backup $record): bool => ! in_array($record->status, ['running', 'failed']))
->authorize(fn (Backup $record) => $user->can('update', $record))
->modelLabel('Edit Backup')
->modalWidth(MaxWidth::Large)
->modalSubmitActionLabel('Update')
@ -80,7 +89,7 @@ public function table(Table $table): Table
TextInput::make('custom_interval')
->label('Custom Interval (Cron)')
->rules(fn (callable $get) => ManageBackup::rules($this->server, $get())['custom_interval'])
->visible(fn (callable $get) => $get('interval') === 'custom')
->visible(fn (callable $get): bool => $get('interval') === 'custom')
->default(fn (Backup $record) => $record->isCustomInterval() ? $record->interval : '')
->placeholder('0 * * * *'),
TextInput::make('keep')
@ -89,8 +98,8 @@ public function table(Table $table): Table
->rules(fn (callable $get) => ManageBackup::rules($this->server, $get())['keep'])
->helperText('How many backups to keep before deleting the oldest one'),
])
->action(function (Backup $backup, array $data) {
run_action($this, function () use ($data, $backup) {
->action(function (Backup $backup, array $data): void {
run_action($this, function () use ($data, $backup): void {
app(ManageBackup::class)->update($backup, $data);
$this->dispatch('$refresh');
@ -107,8 +116,8 @@ public function table(Table $table): Table
->modalHeading('Backup Files')
->color('gray')
->tooltip('Show backup files')
->disabled(fn (Backup $record) => ! in_array($record->status, ['running', 'failed']))
->authorize(fn (Backup $record) => auth()->user()->can('viewAny', [BackupFile::class, $record]))
->disabled(fn (Backup $record): bool => ! in_array($record->status, ['running', 'failed']))
->authorize(fn (Backup $record) => $user->can('viewAny', [BackupFile::class, $record]))
->modalContent(fn (Backup $record) => view('components.dynamic-widget', [
'widget' => BackupFilesList::class,
'params' => [
@ -124,7 +133,7 @@ public function table(Table $table): Table
->label('Run Backup')
->icon('heroicon-o-play')
->color('primary')
->action(function (Backup $record) {
->action(function (Backup $record): void {
app(RunBackup::class)->run($record);
$this->dispatch('$refresh');
@ -134,12 +143,12 @@ public function table(Table $table): Table
->hiddenLabel()
->icon('heroicon-o-trash')
->modalHeading('Delete Backup & Files')
->disabled(fn (Backup $record) => ! in_array($record->status, ['running', 'failed']))
->disabled(fn (Backup $record): bool => ! in_array($record->status, ['running', 'failed']))
->color('danger')
->tooltip('Delete')
->authorize(fn (Backup $record) => auth()->user()->can('delete', $record))
->authorize(fn (Backup $record) => $user->can('delete', $record))
->requiresConfirmation()
->action(function (Backup $record) {
->action(function (Backup $record): void {
app(ManageBackup::class)->delete($record);
$this->dispatch('$refresh');