Skip to content

Commit

Permalink
Fix phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed Apr 9, 2024
1 parent 247131e commit 0196101
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
15 changes: 8 additions & 7 deletions src/Admin/Pool.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,20 @@ public function getDashboardGroups(): array
$groups = [];

foreach ($this->adminGroups as $name => $adminGroup) {
$items = array_values(array_filter(array_map(function (array $item): ?AdminInterface {
$items = [];
foreach ($adminGroup['items'] as $item) {
// NEXT_MAJOR: Remove the '' check
if (!isset($item['admin']) || '' === $item['admin']) {
return null;
continue;
}

$admin = $this->getInstance($item['admin']);

// NEXT_MAJOR: Keep the if part.
// NEXT_MAJOR: Keep the "if" part.
// @phpstan-ignore-next-line
if (method_exists($admin, 'showInDashboard')) {
if (!$admin->showInDashboard()) {
return null;
continue;
}
} else {
@trigger_error(sprintf(
Expand All @@ -111,12 +112,12 @@ public function getDashboardGroups(): array
* @psalm-suppress DeprecatedMethod, DeprecatedConstant
*/
if (!$admin->showIn(AbstractAdmin::CONTEXT_DASHBOARD)) {
return null;
continue;
}
}

return $admin;
}, $adminGroup['items'])));
$items[] = $admin;
}

if ([] !== $items) {
$groups[$name] = ['items' => $items] + $adminGroup;
Expand Down
7 changes: 6 additions & 1 deletion src/Controller/CRUDController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1481,7 +1481,12 @@ final protected function assertObjectExists(Request $request, bool $strict = fal
*/
final protected function getSelectedTab(Request $request): array
{
return array_filter(['_tab' => (string) $request->request->get('_tab')]);
$tab = (string) $request->request->get('_tab');
if ('' === $tab) {
return [];
}

return ['_tab' => $tab];
}

/**
Expand Down

0 comments on commit 0196101

Please sign in to comment.