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

@ -24,11 +24,17 @@ class Index extends Page
public string $token = '';
/**
* @var array<string>
*/
protected $listeners = ['$refresh'];
public static function canAccess(): bool
{
return auth()->user()?->can('viewAny', PersonalAccessToken::class) ?? false;
/** @var \App\Models\User $user */
$user = auth()->user();
return $user->can('viewAny', PersonalAccessToken::class);
}
public function getWidgets(): array
@ -47,6 +53,9 @@ public function unmountAction(bool $shouldCancelParentActions = true, bool $shou
protected function getHeaderActions(): array
{
/** @var \App\Models\User $user */
$user = auth()->user();
return [
Action::make('read-the-docs')
->label('Read the Docs')
@ -59,8 +68,8 @@ protected function getHeaderActions(): array
->icon('heroicon-o-plus')
->modalHeading('Create a new Key')
->modalSubmitActionLabel('Create')
->form(function () {
if ($this->token) {
->form(function (): array {
if ($this->token !== '' && $this->token !== '0') {
return [];
}
@ -76,8 +85,8 @@ protected function getHeaderActions(): array
->required(),
];
})
->infolist(function () {
if ($this->token) {
->infolist(function (): array {
if ($this->token !== '' && $this->token !== '0') {
return [
TextEntry::make('token')
->state($this->token)
@ -91,12 +100,12 @@ protected function getHeaderActions(): array
})
->authorize('create', PersonalAccessToken::class)
->modalWidth(MaxWidth::Large)
->action(function (array $data) {
->action(function (array $data) use ($user): void {
$permissions = ['read'];
if ($data['permission'] === 'write') {
$permissions[] = 'write';
}
$token = auth()->user()->createToken($data['name'], $permissions);
$token = $user->createToken($data['name'], $permissions);
$this->dispatch('$refresh');
@ -105,11 +114,11 @@ protected function getHeaderActions(): array
$this->halt();
})
->modalSubmitAction(function () {
if ($this->token) {
if ($this->token !== '' && $this->token !== '0') {
return false;
}
})
->closeModalByClickingAway(fn () => ! $this->token),
->closeModalByClickingAway(fn (): bool => $this->token === '' || $this->token === '0'),
];
}
}