From 4b1d45c3c91052336e1e4c58aa5b98978f2fe989 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Stan=C4=9Bk?= Date: Wed, 27 Dec 2017 22:58:20 +0100 Subject: [PATCH] php version, coding standard --- .travis.yml | 2 +- app/model/User/User.php | 4 ++-- app/model/User/VariableSymbol.php | 2 +- app/services/ApplicationService.php | 37 ++++++++++++++++++----------- app/utils/Validators.php | 2 +- 5 files changed, 28 insertions(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index e943a7d7a..c6e115821 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: php -php: 5.6 +php: 7.1 before_install: - composer self-update diff --git a/app/model/User/User.php b/app/model/User/User.php index c46dd7918..8c3d270c5 100644 --- a/app/model/User/User.php +++ b/app/model/User/User.php @@ -390,8 +390,8 @@ public function removeRole(Role $role) public function isInRole(Role $role) { return $this->roles->filter(function ($item) use ($role) { - return $item == $role; - })->count() != 0; + return $item == $role; + })->count() != 0; } /** diff --git a/app/model/User/VariableSymbol.php b/app/model/User/VariableSymbol.php index a816f1753..06f3dd3bc 100644 --- a/app/model/User/VariableSymbol.php +++ b/app/model/User/VariableSymbol.php @@ -48,4 +48,4 @@ public function setVariableSymbol(string $variableSymbol) { $this->variableSymbol = $variableSymbol; } -} \ No newline at end of file +} diff --git a/app/services/ApplicationService.php b/app/services/ApplicationService.php index af9cb060e..c83cbe623 100644 --- a/app/services/ApplicationService.php +++ b/app/services/ApplicationService.php @@ -9,7 +9,6 @@ use App\Model\Mailing\Template; use App\Model\Mailing\TemplateVariable; use App\Model\Settings\Settings; -use App\Model\Settings\SettingsException; use App\Model\Settings\SettingsRepository; use App\Model\Structure\DiscountRepository; use App\Model\Structure\Subevent; @@ -26,8 +25,6 @@ use Doctrine\Common\Collections\Collection; use Kdyby\Translation\Translator; use Nette; -use Ublaboo\Mailing\Exception\MailingException; -use Ublaboo\Mailing\Exception\MailingMailCreationException; /** @@ -170,8 +167,12 @@ public function updateRoles(User $user, Collection $roles, ?User $createdBy, boo //pokud se role nezmenily, nic se neprovede if ($roles->count() == $oldRoles->count()) { - $rolesArray = $roles->map(function (Role $role) {return $role->getId();})->toArray(); - $oldRolesArray = $oldRoles->map(function (Role $role) {return $role->getId();})->toArray(); + $rolesArray = $roles->map(function (Role $role) { + return $role->getId(); + })->toArray(); + $oldRolesArray = $oldRoles->map(function (Role $role) { + return $role->getId(); + })->toArray(); if (array_diff($rolesArray, $oldRolesArray) === array_diff($oldRolesArray, $rolesArray)) return; @@ -190,8 +191,8 @@ public function updateRoles(User $user, Collection $roles, ?User $createdBy, boo })) { $user->setApproved(TRUE); } elseif (!$approve && $roles->exists(function (int $key, Role $role) use ($oldRoles) { - return !$role->isApprovedAfterRegistration() && !$oldRoles->contains($role); - })) { + return !$role->isApprovedAfterRegistration() && !$oldRoles->contains($role); + })) { $user->setApproved(FALSE); } @@ -236,7 +237,9 @@ public function updateRoles(User $user, Collection $roles, ?User $createdBy, boo $this->mailService->sendMailFromTemplate($user, '', Template::ROLES_CHANGED, [ TemplateVariable::SEMINAR_NAME => $this->settingsRepository->getValue(Settings::SEMINAR_NAME), - TemplateVariable::USERS_ROLES => implode(', ', $roles->map(function (Role $role) {return $role->getName();})->toArray()) + TemplateVariable::USERS_ROLES => implode(', ', $roles->map(function (Role $role) { + return $role->getName(); + })->toArray()) ]); } @@ -306,8 +309,12 @@ public function updateSubeventsApplication(SubeventsApplication $application, Co //pokud se podakce nezmenily, nic se neprovede if ($subevents->count() == $oldSubevents->count()) { - $subeventsArray = $subevents->map(function (Subevent $subevent) {return $subevent->getId();})->toArray(); - $oldSubeventsArray = $oldSubevents->map(function (Subevent $subevent) {return $subevent->getId();})->toArray(); + $subeventsArray = $subevents->map(function (Subevent $subevent) { + return $subevent->getId(); + })->toArray(); + $oldSubeventsArray = $oldSubevents->map(function (Subevent $subevent) { + return $subevent->getId(); + })->toArray(); if (array_diff($subeventsArray, $oldSubeventsArray) === array_diff($oldSubeventsArray, $subeventsArray)) return; @@ -396,8 +403,10 @@ public function updatePayment(Application $application, string $variableSymbol, && $maturityDate == $oldMaturityDate) return; - $this->applicationRepository->getEntityManager()->transactional(function ($em) use ($application, - $variableSymbol, $paymentMethod, $paymentDate, $incomeProofPrintedDate, $maturityDate, $createdBy) { + $this->applicationRepository->getEntityManager()->transactional(function ($em) use ( + $application, + $variableSymbol, $paymentMethod, $paymentDate, $incomeProofPrintedDate, $maturityDate, $createdBy + ) { $user = $application->getUser(); $newApplication = clone $application; @@ -449,8 +458,8 @@ private function createRolesApplication(User $user, Collection $roles, User $cre { $user->setApproved(TRUE); if (!$approve && $roles->exists(function (int $key, Role $role) { - return !$role->isApprovedAfterRegistration(); - })) + return !$role->isApprovedAfterRegistration(); + })) $user->setApproved(FALSE); $user->setRoles($roles); diff --git a/app/utils/Validators.php b/app/utils/Validators.php index 467ae0cb0..cf4703b4a 100644 --- a/app/utils/Validators.php +++ b/app/utils/Validators.php @@ -199,4 +199,4 @@ public function validateSubeventsRegistered(Collection $selectedSubevents, User } return TRUE; } -} \ No newline at end of file +}