Code improvements (#1649)

* use global namespace for faster lookups
* phpstan level 5
This commit is contained in:
Kevin Papst
2020-04-19 14:37:14 +02:00
committed by GitHub
parent 7b25e9acaf
commit 0f3fa8fdbe
183 changed files with 604 additions and 574 deletions

View File

@@ -92,11 +92,13 @@ class DashboardSubscriber implements EventSubscriberInterface
$section->setOrder(100);
if ($this->security->isGranted('view_user')) {
$query = new UserQuery();
$query->setCurrentUser($user);
$section->addWidget(
(new More())
->setId('userTotal')
->setTitle('stats.userTotal')
->setData($this->user->countUsersForQuery((new UserQuery())->setCurrentUser($user)))
->setData($this->user->countUsersForQuery($query))
->setOptions([
'route' => 'admin_user',
'icon' => 'user',
@@ -106,11 +108,13 @@ class DashboardSubscriber implements EventSubscriberInterface
}
if ($this->security->isGranted('view_customer')) {
$query = new CustomerQuery();
$query->setCurrentUser($user);
$section->addWidget(
(new More())
->setId('customerTotal')
->setTitle('stats.customerTotal')
->setData($this->customer->countCustomersForQuery((new CustomerQuery())->setCurrentUser($user)))
->setData($this->customer->countCustomersForQuery($query))
->setOptions([
'route' => 'admin_customer',
'icon' => 'customer',
@@ -120,11 +124,13 @@ class DashboardSubscriber implements EventSubscriberInterface
}
if ($this->security->isGranted('view_project')) {
$query = new ProjectQuery();
$query->setCurrentUser($user);
$section->addWidget(
(new More())
->setId('projectTotal')
->setTitle('stats.projectTotal')
->setData($this->project->countProjectsForQuery((new ProjectQuery())->setCurrentUser($user)))
->setData($this->project->countProjectsForQuery($query))
->setOptions([
'route' => 'admin_project',
'icon' => 'project',
@@ -134,11 +140,13 @@ class DashboardSubscriber implements EventSubscriberInterface
}
if ($this->security->isGranted('view_activity')) {
$query = new ActivityQuery();
$query->setCurrentUser($user);
$section->addWidget(
(new More())
->setId('activityTotal')
->setTitle('stats.activityTotal')
->setData($this->activity->countActivitiesForQuery((new ActivityQuery())->setCurrentUser($user)))
->setData($this->activity->countActivitiesForQuery($query))
->setOptions([
'route' => 'admin_activity',
'icon' => 'activity',
@@ -147,7 +155,7 @@ class DashboardSubscriber implements EventSubscriberInterface
);
}
if (count($section->getWidgets()) > 0) {
if (\count($section->getWidgets()) > 0) {
$event->addSection($section);
}
}

View File

@@ -12,6 +12,7 @@ namespace App\EventSubscriber;
use App\Event\ConfigureMainMenuEvent;
use App\Utils\MenuItemModel as KimaiMenuItemModel;
use KevinPapst\AdminLTEBundle\Event\SidebarMenuEvent;
use KevinPapst\AdminLTEBundle\Model\MenuItemInterface;
use KevinPapst\AdminLTEBundle\Model\MenuItemModel;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@@ -95,7 +96,7 @@ class MenuBuilderSubscriber implements EventSubscriberInterface
/**
* @param string $route
* @param MenuItemModel[] $items
* @param MenuItemInterface[] $items
*/
protected function activateByRoute($route, $items)
{

View File

@@ -59,7 +59,7 @@ class RedirectToLocaleSubscriber implements EventSubscriberInterface
}
$this->defaultLocale = $defaultLocale ?: $this->locales[0];
if (!in_array($this->defaultLocale, $this->locales)) {
if (!\in_array($this->defaultLocale, $this->locales)) {
throw new \UnexpectedValueException(
sprintf('The default locale ("%s") must be one of "%s".', $this->defaultLocale, $locales)
);