From 69952ca4cb1ba406b92b7ea325ab3e522d54527b Mon Sep 17 00:00:00 2001 From: John Linhart Date: Wed, 13 Dec 2023 10:17:54 +0100 Subject: [PATCH] Rector @ work --- .../CoreBundle/ProcessSignal/ProcessSignalService.php | 2 +- app/bundles/SmsBundle/Controller/AjaxController.php | 8 ++------ app/bundles/SmsBundle/Event/TokensBuildEvent.php | 8 +------- .../Security/Authenticator/FormAuthenticator.php | 4 +--- 4 files changed, 5 insertions(+), 17 deletions(-) diff --git a/app/bundles/CoreBundle/ProcessSignal/ProcessSignalService.php b/app/bundles/CoreBundle/ProcessSignal/ProcessSignalService.php index 28faf30fb3f..0643725b7e1 100644 --- a/app/bundles/CoreBundle/ProcessSignal/ProcessSignalService.php +++ b/app/bundles/CoreBundle/ProcessSignal/ProcessSignalService.php @@ -22,7 +22,7 @@ public function registerSignalHandler(callable $beforeCallback = null, array $si return; } - $handler = function (int $signal) use ($beforeCallback) { + $handler = function (int $signal) use ($beforeCallback): void { if ($beforeCallback) { call_user_func($beforeCallback, $signal); } diff --git a/app/bundles/SmsBundle/Controller/AjaxController.php b/app/bundles/SmsBundle/Controller/AjaxController.php index 9565636e113..b0cb64808cd 100644 --- a/app/bundles/SmsBundle/Controller/AjaxController.php +++ b/app/bundles/SmsBundle/Controller/AjaxController.php @@ -66,14 +66,10 @@ public function getSmsCountStatsAction(Request $request, BroadcastQuery $broadca return new JsonResponse($data); } - /** - * @return JsonResponse - */ public function getBuilderTokensAction(Request $request, EventDispatcherInterface $eventDispatcher = null): JsonResponse { $query = $request->get('query', ''); $tokens = $this->getBuilderTokens($query); - /** @var EventDispatcherInterface $eventDispatcher */ $event = new TokensBuildEvent($tokens); $eventDispatcher->dispatch($event, SmsEvents::ON_SMS_TOKENS_BUILD); @@ -97,9 +93,9 @@ protected function getBuilderTokens($query): array $tokens = $components['tokens']; array_map( - function ($token, $value) use ($findTokens, &$returnTokens) { + function ($token, $value) use ($findTokens, &$returnTokens): void { foreach ($findTokens as $findToken) { - if (substr($token, 0, strlen($findToken)) === $findToken) { + if (str_starts_with($token, $findToken)) { $returnTokens[$token] = $value; } } diff --git a/app/bundles/SmsBundle/Event/TokensBuildEvent.php b/app/bundles/SmsBundle/Event/TokensBuildEvent.php index 57c13913994..f7bbe392130 100644 --- a/app/bundles/SmsBundle/Event/TokensBuildEvent.php +++ b/app/bundles/SmsBundle/Event/TokensBuildEvent.php @@ -6,17 +6,11 @@ class TokensBuildEvent extends Event { - /** - * @var array> - */ - private array $tokens; - /** * @param array> $tokens */ - public function __construct(array $tokens) + public function __construct(private array $tokens) { - $this->tokens = $tokens; } /** diff --git a/app/bundles/UserBundle/Security/Authenticator/FormAuthenticator.php b/app/bundles/UserBundle/Security/Authenticator/FormAuthenticator.php index d9968fc37ff..953c2d5b688 100644 --- a/app/bundles/UserBundle/Security/Authenticator/FormAuthenticator.php +++ b/app/bundles/UserBundle/Security/Authenticator/FormAuthenticator.php @@ -145,9 +145,7 @@ public function checkCredentials($credentials, UserInterface $user): bool $newUser->setUsername($user->getUserName()); $newUser->setPassword($user->getPassword()); - $authenticated = $this->hasher->isPasswordValid($newUser, $this->getPassword($credentials)); - - return $authenticated; + return $this->hasher->isPasswordValid($newUser, $this->getPassword($credentials)); } public function getPassword($credentials): ?string