mirror of
https://github.com/filamentphp/filament.git
synced 2026-10-24 01:58:00 +08:00
fix random phpstan errors
This commit is contained in:
@@ -10,7 +10,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
php: [ 8.1, 8.0 ]
|
||||
php: [ 8.1, '8.0' ]
|
||||
laravel: [ 9.*, 8.* ]
|
||||
dependency-version: [ prefer-stable ]
|
||||
include:
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace Filament\AvatarProviders\Contracts;
|
||||
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
interface AvatarProvider
|
||||
{
|
||||
public function get(Authenticatable $user): string;
|
||||
public function get(Model $user): string;
|
||||
}
|
||||
|
||||
@@ -4,10 +4,11 @@ namespace Filament\AvatarProviders;
|
||||
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class UiAvatarsProvider implements Contracts\AvatarProvider
|
||||
{
|
||||
public function get(Authenticatable $user): string
|
||||
public function get(Model $user): string
|
||||
{
|
||||
return 'https://ui-avatars.com/api/?name=' . urlencode(Filament::getUserName($user)) . '&color=FFFFFF&background=111827';
|
||||
}
|
||||
|
||||
@@ -188,16 +188,12 @@ trait CanGenerateResources
|
||||
|
||||
$model = app($model);
|
||||
|
||||
if (! ($model instanceof Model)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
return $model
|
||||
->getConnection()
|
||||
->getDoctrineSchemaManager()
|
||||
->listTableDetails($model->getTable());
|
||||
} catch (Throwable $e) {
|
||||
} catch (Throwable $exception) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,17 +80,9 @@ class Login extends Component implements HasForms
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
$view = view('filament::login');
|
||||
|
||||
/*
|
||||
* Livewire uses a macro for the `layout()` method.
|
||||
*
|
||||
* @phpstan-ignore-next-line
|
||||
*/
|
||||
$view->layout('filament::components.layouts.base', [
|
||||
'title' => __('filament::login.title'),
|
||||
]);
|
||||
|
||||
return $view;
|
||||
return view('filament::login')
|
||||
->layout('filament::components.layouts.base', [
|
||||
'title' => __('filament::login.title'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ class MirrorConfigToSubpackages
|
||||
{
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
$config = app()->config;
|
||||
$config = config();
|
||||
|
||||
$darkMode = $config->get('filament.dark_mode');
|
||||
$config->set('forms.dark_mode', $darkMode);
|
||||
|
||||
@@ -12,8 +12,8 @@ class NavigationBuilder
|
||||
|
||||
public function group(string $name, array $items = []): static
|
||||
{
|
||||
$this->groups[$name] = collect($items)->each(
|
||||
fn (NavigationItem $item, $i) => $item->group($name)->sort($i)
|
||||
$this->groups[$name] = collect($items)->map(
|
||||
fn (NavigationItem $item, int $index) => $item->group($name)->sort($index),
|
||||
)->toArray();
|
||||
|
||||
return $this;
|
||||
|
||||
@@ -92,16 +92,8 @@ class Page extends Component implements Forms\Contracts\HasForms
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
$view = view(static::$view, $this->getViewData());
|
||||
|
||||
/*
|
||||
* Livewire uses a macro for the `layout()` method.
|
||||
*
|
||||
* @phpstan-ignore-next-line
|
||||
*/
|
||||
$view->layout(static::$layout, $this->getLayoutData());
|
||||
|
||||
return $view;
|
||||
return view(static::$view, $this->getViewData())
|
||||
->layout(static::$layout, $this->getLayoutData());
|
||||
}
|
||||
|
||||
protected function getBreadcrumbs(): array
|
||||
|
||||
@@ -41,11 +41,6 @@ trait CanCreateRecords
|
||||
->action(fn () => $this->create());
|
||||
}
|
||||
|
||||
protected function canCreate(): bool
|
||||
{
|
||||
return $this->can('create');
|
||||
}
|
||||
|
||||
protected function getCreateFormSchema(): array
|
||||
{
|
||||
return $this->getResourceForm()->getSchema();
|
||||
|
||||
@@ -29,11 +29,6 @@ trait CanEditRecords
|
||||
->action(fn () => $this->save());
|
||||
}
|
||||
|
||||
protected function canEdit(Model $record): bool
|
||||
{
|
||||
return $this->can('update', $record);
|
||||
}
|
||||
|
||||
protected function getEditFormSchema(): array
|
||||
{
|
||||
return $this->getResourceForm()->getSchema();
|
||||
|
||||
@@ -24,12 +24,6 @@ class BelongsToManyCheckboxList extends CheckboxList
|
||||
$relationship = $component->getRelationship();
|
||||
$relatedModels = $relationship->getResults();
|
||||
|
||||
if (! $relatedModels) {
|
||||
$component->state([]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$component->state(
|
||||
// Cast the related keys to a string, otherwise Livewire does not
|
||||
// know how to handle deselection.
|
||||
|
||||
@@ -27,12 +27,6 @@ class BelongsToManyMultiSelect extends MultiSelect
|
||||
$relationship = $component->getRelationship();
|
||||
$relatedModels = $relationship->getResults();
|
||||
|
||||
if (! $relatedModels) {
|
||||
$component->state([]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$component->state(
|
||||
// Cast the related keys to a string, otherwise JavaScript does not
|
||||
// know how to handle deselection.
|
||||
|
||||
Reference in New Issue
Block a user