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

@ -19,8 +19,14 @@ class RulesList extends Widget
{
public Server $server;
/**
* @var array<string>
*/
protected $listeners = ['$refresh'];
/**
* @return Builder<FirewallRule>
*/
protected function getTableQuery(): Builder
{
return FirewallRule::query()->where('server_id', $this->server->id);
@ -36,7 +42,7 @@ protected function getTableColumns(): array
TextColumn::make('type')
->sortable()
->badge()
->color(fn ($state) => $state === 'allow' ? 'success' : 'warning')
->color(fn ($state): string => $state === 'allow' ? 'success' : 'warning')
->label('Type')
->formatStateUsing(fn ($state) => Str::upper($state)),
TextColumn::make('id')
@ -62,12 +68,15 @@ protected function getTableColumns(): array
TextColumn::make('status')
->label('Status')
->badge()
->color(fn (FirewallRule $record) => $record->getStatusColor()),
->color(fn (FirewallRule $record): string => $record->getStatusColor()),
];
}
public function table(Table $table): Table
{
/** @var \App\Models\User $user */
$user = auth()->user();
return $table
->heading(null)
->query($this->getTableQuery())
@ -81,10 +90,10 @@ public function table(Table $table): Table
->modalHeading('Edit Firewall Rule')
->modalDescription('Edit the associated servers firewall rule.')
->modalSubmitActionLabel('Update')
->authorize(fn (FirewallRule $record) => auth()->user()->can('update', $record))
->form(fn ($record) => Index::getFirewallForm($record))
->action(function (FirewallRule $record, array $data) {
run_action($this, function () use ($record, $data) {
->authorize(fn (FirewallRule $record) => $user->can('update', $record))
->form(fn ($record): array => Index::getFirewallForm($record))
->action(function (FirewallRule $record, array $data): void {
run_action($this, function () use ($record, $data): void {
app(ManageRule::class)->update($record, $data);
$this->dispatch('$refresh');
@ -101,8 +110,8 @@ public function table(Table $table): Table
->color('danger')
->hiddenLabel()
->requiresConfirmation()
->authorize(fn (FirewallRule $record) => auth()->user()->can('delete', $record))
->action(function (FirewallRule $record) {
->authorize(fn (FirewallRule $record) => $user->can('delete', $record))
->action(function (FirewallRule $record): void {
try {
app(ManageRule::class)->delete($record);
} catch (\Exception $e) {