Skip to content

Commit

Permalink
Rector @ work
Browse files Browse the repository at this point in the history
  • Loading branch information
escopecz committed Dec 13, 2023
1 parent fb114d9 commit 69952ca
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
8 changes: 2 additions & 6 deletions app/bundles/SmsBundle/Controller/AjaxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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;
}
}
Expand Down
8 changes: 1 addition & 7 deletions app/bundles/SmsBundle/Event/TokensBuildEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,11 @@

class TokensBuildEvent extends Event
{
/**
* @var array<string,array<int|string>>
*/
private array $tokens;

/**
* @param array<string,array<int|string>> $tokens
*/
public function __construct(array $tokens)
public function __construct(private array $tokens)
{
$this->tokens = $tokens;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 69952ca

Please sign in to comment.