From 5bfdcbf5c7b3cabf14e1f4b0ddf0141e56ddf544 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Mon, 26 Dec 2022 20:52:58 +0100 Subject: [PATCH] fix phpstan lvl 9 bugs --- Controller/ApiController.php | 2 ++ Controller/BackendController.php | 21 +++++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Controller/ApiController.php b/Controller/ApiController.php index e95e381..21c198c 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -172,7 +172,9 @@ final class ApiController extends Controller } if ($element->getStatus() === ClockingStatus::END) { + /** @var \Modules\HumanResourceTimeRecording\Models\Session $session */ $session = SessionMapper::get()->where('id', (int) $request->getData('session'))->execute(); + $session->addSessionElement($element); SessionMapper::update()->execute($session); } diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 1277af2..c0cd93c 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -45,6 +45,7 @@ final class BackendController extends Controller implements DashboardElementInte $view->setTemplate('/Modules/HumanResourceTimeRecording/Theme/Backend/dashboard'); $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1006301001, $request, $response)); + /** @var \Modules\HumanResourceTimeRecording\Models\Session[] $list */ $list = SessionMapper::getLastSessionsFromAllEmployees(); $view->addData('sessions', $list); @@ -69,14 +70,15 @@ final class BackendController extends Controller implements DashboardElementInte $view->setTemplate('/Modules/HumanResourceTimeRecording/Theme/Backend/private-dashboard'); $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1006303001, $request, $response)); + /** @var \Modules\HumanResourceManagement\Models\Employee $employee */ $employee = EmployeeMapper::get() ->with('profile') ->with('profile/account') ->where('profile/account', $request->header->account) - ->execute() - ->getId(); + ->execute(); - $lastOpenSession = SessionMapper::getMostPlausibleOpenSessionForEmployee($employee); + /** @var \Modules\HumanResourceTimeRecording\Models\Session $lastOpenSession */ + $lastOpenSession = SessionMapper::getMostPlausibleOpenSessionForEmployee($employee->getId()); $start = new SmartDateTime('now'); $start = $start->getEndOfDay(); @@ -84,7 +86,7 @@ final class BackendController extends Controller implements DashboardElementInte $limit->smartModify(0, -2, 0); $list = SessionMapper::getAll() - ->where('employee', $employee) + ->where('employee', $employee->getId()) ->where('createdAt', $start->format('Y-m-d H:i:s'), '<=') ->sort('id', OrderType::DESC) ->execute(); @@ -114,15 +116,17 @@ final class BackendController extends Controller implements DashboardElementInte $view->setTemplate('/Modules/HumanResourceTimeRecording/Theme/Backend/private-session'); $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1006303001, $request, $response)); - $session = SessionMapper::get()->where('id', (int) $request->getData('id'))->execute(); + /** @var \Modules\HumanResourceTimeRecording\Models\Session $session */ + $session = SessionMapper::get()->where('id', (int) $request->getData('id'))->execute(); + + /** @var \Modules\HumanResourceManagement\Models\Employee $employee */ $employee = EmployeeMapper::get() ->with('profile') ->with('profile/account') ->where('profile/account', $request->header->account) - ->execute() - ->getId(); + ->execute(); - if ($session->getEmployee()->getId() !== $employee) { + if ($session->employee->getId() !== $employee->getId()) { $view->addData('session', new NullSession()); } else { $view->addData('session', $session); @@ -149,6 +153,7 @@ final class BackendController extends Controller implements DashboardElementInte $view->setTemplate('/Modules/HumanResourceTimeRecording/Theme/Backend/hr-stats'); $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1006301001, $request, $response)); + /** @var \Modules\HumanResourceTimeRecording\Models\Session[] $list */ $list = SessionMapper::getLastSessionsFromAllEmployees(); $view->addData('sessions', $list);