Skip to content

Commit

Permalink
Add more type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 committed Feb 9, 2025
1 parent 59ad737 commit 35f5018
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/Action/RequestResetAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ private function getFlashBag(Request $request): ?FlashBagInterface
return $session->getFlashBag();
}

/**
* @return FormInterface<mixed>
*/
private function createForm(): FormInterface
{
return $this->formFactory
Expand Down
3 changes: 3 additions & 0 deletions src/Action/UpdateSecurityAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ public function __invoke(Request $request): Response
]));
}

/**
* @return FormInterface<UserInterface>
*/
private function createForm(UserInterface $model): FormInterface
{
return $this->formFactory
Expand Down
12 changes: 12 additions & 0 deletions src/Event/FormEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,32 @@
use Symfony\Component\HttpFoundation\Response;
use Symfony\Contracts\EventDispatcher\Event;

/**
* @template T
*/
class FormEvent extends Event
{
/**
* @var FormInterface<T>
*/
private readonly FormInterface $form;

private readonly Request $request;

private ?Response $response = null;

/**
* @param FormInterface<T> $form
*/
public function __construct(FormInterface $form, Request $request)
{
$this->form = $form;
$this->request = $request;
}

/**
* @return FormInterface<T>
*/
public function getForm(): FormInterface
{
return $this->form;
Expand Down
7 changes: 3 additions & 4 deletions src/EventListener/ResettingListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,13 @@ public function onResettingResetInitialize(GetResponseUserEvent $event): void
}
}

/**
* @param FormEvent<Resetting> $event
*/
public function onResettingResetSuccess(FormEvent $event): void
{
$model = $event->getForm()->getData();

if (!$model instanceof Resetting) {
return;
}

$user = $model->getUser();

$user->setConfirmationToken(null);
Expand Down

0 comments on commit 35f5018

Please sign in to comment.