Skip to content

Commit

Permalink
[rector] Rector fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lee-to authored and github-actions[bot] committed Feb 24, 2025
1 parent 8d99177 commit ec5237f
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/Laravel/src/Support/MenuAutoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use MoonShine\Contracts\Core\CrudPageContract;
use MoonShine\Contracts\Core\DependencyInjection\CoreContract;
use MoonShine\Contracts\Core\PageContract;
use MoonShine\Contracts\Core\ResourceContract;
use MoonShine\Contracts\MenuManager\MenuAutoloaderContract;
use MoonShine\Contracts\MenuManager\MenuElementContract;
use MoonShine\Contracts\MenuManager\MenuFillerContract;
Expand Down Expand Up @@ -78,7 +77,7 @@ public function toArray(): array
$icon = $group?->icon;
$position = $order?->value;

$namespace = get_class($item);
$namespace = $item::class;
$data = ['filler' => $namespace, 'canSee' => $canSee?->method, 'position' => $position];

if ($label !== null) {
Expand Down Expand Up @@ -106,14 +105,14 @@ public function toArray(): array
$resolveItems($item, $items);
}

$excludePages = static fn(PageContract $page) => ! $page instanceof CrudPageContract;
$excludePages = static fn(PageContract $page): bool => ! $page instanceof CrudPageContract;

foreach ($this->core->getPages()->filter($excludePages)->toArray() as $item) {
$resolveItems($item, $items);
}

$sort = static fn($items) => (new Collection($items))->values()
->sortBy(fn($item) => $item['position'] ?? INF)
->sortBy(fn($item): mixed => $item['position'] ?? INF)
->values();

$result = $sort($items)->map(function ($item) use($sort) {
Expand Down Expand Up @@ -153,7 +152,7 @@ private function generateMenu(array $data): array
$group['translatable'] ? __($group['label']) : $group['label'],
$this->generateMenu($item['items']),
$group['icon'],
)->when($group['canSee'], fn(MenuGroup $ctx) => $ctx->canSee($this->canSee($group['class'], $group['canSee'])));
)->when($group['canSee'], fn(MenuGroup $ctx): MenuGroup => $ctx->canSee($this->canSee($group['class'], $group['canSee'])));
continue;
}

Expand All @@ -172,7 +171,7 @@ private function toMenuItem(string $filler, ?string $canSee = null): MenuItem
$label = $resolved->getTitle();

return MenuItem::make($label, $filler)
->when($canSee, fn(MenuItem $item) => $item->canSee($this->canSee($resolved, $canSee)));
->when($canSee, fn(MenuItem $item): MenuItem => $item->canSee($this->canSee($resolved, $canSee)));
}

/**
Expand Down

0 comments on commit ec5237f

Please sign in to comment.