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

@ -3,6 +3,7 @@
namespace App\Web\Pages\Settings\NotificationChannels\Widgets;
use App\Models\NotificationChannel;
use App\Models\User;
use App\Web\Pages\Settings\NotificationChannels\Actions\Edit;
use Filament\Support\Enums\MaxWidth;
use Filament\Tables\Actions\DeleteAction;
@ -15,18 +16,27 @@
class NotificationChannelsList extends Widget
{
/**
* @var array<string>
*/
protected $listeners = ['$refresh'];
/**
* @return Builder<NotificationChannel>
*/
protected function getTableQuery(): Builder
{
return NotificationChannel::getByProjectId(auth()->user()->current_project_id);
/** @var User $user */
$user = auth()->user();
return NotificationChannel::getByProjectId($user->current_project_id);
}
protected function getTableColumns(): array
{
return [
IconColumn::make('provider')
->icon(fn (NotificationChannel $record) => 'icon-'.$record->provider)
->icon(fn (NotificationChannel $record): string => 'icon-'.$record->provider)
->width(24),
TextColumn::make('label')
->default(fn (NotificationChannel $record) => $record->label)
@ -35,10 +45,8 @@ protected function getTableColumns(): array
TextColumn::make('id')
->label('Global')
->badge()
->color(fn (NotificationChannel $record) => $record->project_id ? 'gray' : 'success')
->formatStateUsing(function (NotificationChannel $record) {
return $record->project_id ? 'No' : 'Yes';
}),
->color(fn (NotificationChannel $record): string => $record->project_id ? 'gray' : 'success')
->formatStateUsing(fn (NotificationChannel $record): string => $record->project_id ? 'No' : 'Yes'),
TextColumn::make('created_at')
->label('Created At')
->formatStateUsing(fn (NotificationChannel $record) => $record->created_at_by_timezone)
@ -49,6 +57,9 @@ protected function getTableColumns(): array
public function table(Table $table): Table
{
/** @var User $user */
$user = auth()->user();
return $table
->heading(null)
->query($this->getTableQuery())
@ -56,20 +67,18 @@ public function table(Table $table): Table
->actions([
EditAction::make('edit')
->modalHeading('Edit Notification Channel')
->mutateRecordDataUsing(function (array $data, NotificationChannel $record) {
return [
'label' => $record->label,
'global' => ! $record->project_id,
];
})
->mutateRecordDataUsing(fn (array $data, NotificationChannel $record): array => [
'label' => $record->label,
'global' => ! $record->project_id,
])
->form(Edit::form())
->authorize(fn (NotificationChannel $record) => auth()->user()->can('update', $record))
->authorize(fn (NotificationChannel $record) => $user->can('update', $record))
->using(fn (array $data, NotificationChannel $record) => Edit::action($record, $data))
->modalWidth(MaxWidth::Medium),
DeleteAction::make('delete')
->modalHeading('Delete Notification Channel')
->authorize(fn (NotificationChannel $record) => auth()->user()->can('delete', $record))
->using(function (array $data, NotificationChannel $record) {
->authorize(fn (NotificationChannel $record) => $user->can('delete', $record))
->using(function (array $data, NotificationChannel $record): void {
$record->delete();
}),
]);