Skip to content

Commit 4e680ca

Browse files
committed
Add more type hints
1 parent ce2b797 commit 4e680ca

File tree

10 files changed

+39
-7
lines changed

10 files changed

+39
-7
lines changed

src/Action/RequestResetAction.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ private function getFlashBag(Request $request): ?FlashBagInterface
190190
return $session->getFlashBag();
191191
}
192192

193+
/**
194+
* @return FormInterface<mixed>
195+
*/
193196
private function createForm(): FormInterface
194197
{
195198
return $this->formFactory

src/Action/UpdateSecurityAction.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ public function __invoke(Request $request): Response
107107
]));
108108
}
109109

110+
/**
111+
* @return FormInterface<UserInterface>
112+
*/
110113
private function createForm(UserInterface $model): FormInterface
111114
{
112115
return $this->formFactory

src/Event/FormEvent.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,32 @@
1616
use Symfony\Component\HttpFoundation\Response;
1717
use Symfony\Contracts\EventDispatcher\Event;
1818

19+
/**
20+
* @template T
21+
*/
1922
class FormEvent extends Event
2023
{
24+
/**
25+
* @var FormInterface<T>
26+
*/
2127
private readonly FormInterface $form;
2228

2329
private readonly Request $request;
2430

2531
private ?Response $response = null;
2632

33+
/**
34+
* @param FormInterface<T> $form
35+
*/
2736
public function __construct(FormInterface $form, Request $request)
2837
{
2938
$this->form = $form;
3039
$this->request = $request;
3140
}
3241

42+
/**
43+
* @return FormInterface<T>
44+
*/
3345
public function getForm(): FormInterface
3446
{
3547
return $this->form;

src/EventListener/ResettingListener.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,13 @@ public function onResettingResetInitialize(GetResponseUserEvent $event): void
4747
}
4848
}
4949

50+
/**
51+
* @param FormEvent<Resetting> $event
52+
*/
5053
public function onResettingResetSuccess(FormEvent $event): void
5154
{
5255
$model = $event->getForm()->getData();
5356

54-
if (!$model instanceof Resetting) {
55-
return;
56-
}
57-
5857
$user = $model->getUser();
5958

6059
$user->setConfirmationToken(null);

src/Form/Type/AccountDeletionFormType.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
use Symfony\Component\Security\Core\Validator\Constraints\UserPassword;
2121
use Symfony\Component\Validator\Constraints\NotBlank;
2222

23+
/**
24+
* @extends AbstractType<AccountDeletion>
25+
*/
2326
final class AccountDeletionFormType extends AbstractType
2427
{
2528
/**

src/Form/Type/LoginFormType.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
2222
use Symfony\Contracts\Translation\TranslatorInterface;
2323

24+
/**
25+
* @extends AbstractType<mixed>
26+
*/
2427
final class LoginFormType extends AbstractType
2528
{
2629
private readonly AuthenticationUtils $authenticationUtils;

src/Form/Type/RequestPasswordFormType.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
use Symfony\Component\Form\FormBuilderInterface;
1515
use Symfony\Component\OptionsResolver\OptionsResolver;
1616

17+
/**
18+
* @extends AbstractType<mixed>
19+
*/
1720
final class RequestPasswordFormType extends AbstractType
1821
{
1922
public function buildForm(FormBuilderInterface $builder, array $options): void

src/Form/Type/ResettingFormType.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
use Symfony\Component\Form\FormBuilderInterface;
1919
use Symfony\Component\OptionsResolver\OptionsResolver;
2020

21+
/**
22+
* @extends AbstractType<Resetting>
23+
*/
2124
final class ResettingFormType extends AbstractType
2225
{
2326
/**

src/Form/Type/UpdateSecurityFormType.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
use Symfony\Component\Security\Core\Validator\Constraints\UserPassword;
2121
use Symfony\Component\Validator\Constraints\NotBlank;
2222

23+
/**
24+
* @extends AbstractType<UserInterface>
25+
*/
2326
final class UpdateSecurityFormType extends AbstractType
2427
{
2528
/**

tests/App/Entity/TestUser.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@
1515
use Doctrine\Common\Collections\Collection;
1616
use Doctrine\DBAL\Types\Types;
1717
use Doctrine\ORM\Mapping as ORM;
18-
use Nucleos\UserBundle\Model\GroupInterface;
1918
use Nucleos\UserBundle\Model\User;
2019

2120
/**
22-
* @phpstan-extends User<GroupInterface>
21+
* @phpstan-extends User<TestGroup>
2322
*/
2423
#[ORM\Entity]
2524
#[ORM\Table(name: 'user__user')]
@@ -31,11 +30,12 @@ class TestUser extends User
3130
protected int $id;
3231

3332
/**
34-
* @var Collection<array-key, GroupInterface>
33+
* @var Collection<array-key, TestGroup>
3534
*/
3635
#[ORM\ManyToMany(targetEntity: TestGroup::class)]
3736
#[ORM\JoinTable(name: 'user__user_group')]
3837
protected Collection $groups;
38+
3939
private static int $index = 1;
4040

4141
public function __construct()

0 commit comments

Comments
 (0)