Skip to content

Commit 4c0a2a8

Browse files
authored
Merge pull request #3069 from stof/return_types
Add return types in all methods
2 parents 8ccde38 + 62eaceb commit 4c0a2a8

14 files changed

+106
-13
lines changed

Doctrine/CouchDB/UserListener.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ public function getSubscribedEvents(): array
4242
];
4343
}
4444

45-
public function prePersist(LifecycleEventArgs $args)
45+
public function prePersist(LifecycleEventArgs $args): void
4646
{
4747
$object = $args->getDocument();
4848
if ($object instanceof UserInterface) {
4949
$this->updateUserFields($object);
5050
}
5151
}
5252

53-
public function preUpdate(LifecycleEventArgs $args)
53+
public function preUpdate(LifecycleEventArgs $args): void
5454
{
5555
$object = $args->getDocument();
5656
if ($object instanceof UserInterface) {
@@ -61,7 +61,7 @@ public function preUpdate(LifecycleEventArgs $args)
6161
/**
6262
* Updates the user properties.
6363
*/
64-
private function updateUserFields(UserInterface $user)
64+
private function updateUserFields(UserInterface $user): void
6565
{
6666
$this->canonicalFieldsUpdater->updateCanonicalFields($user);
6767
$this->passwordUpdater->hashPassword($user);

Doctrine/UserListener.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function getSubscribedEvents(): array
5252
/**
5353
* Pre persist listener based on doctrine common.
5454
*/
55-
public function prePersist(LifecycleEventArgs $args)
55+
public function prePersist(LifecycleEventArgs $args): void
5656
{
5757
$object = $args->getObject();
5858
if ($object instanceof UserInterface) {
@@ -63,7 +63,7 @@ public function prePersist(LifecycleEventArgs $args)
6363
/**
6464
* Pre update listener based on doctrine common.
6565
*/
66-
public function preUpdate(LifecycleEventArgs $args)
66+
public function preUpdate(LifecycleEventArgs $args): void
6767
{
6868
$object = $args->getObject();
6969
if ($object instanceof UserInterface) {
@@ -75,7 +75,7 @@ public function preUpdate(LifecycleEventArgs $args)
7575
/**
7676
* Updates the user properties.
7777
*/
78-
private function updateUserFields(UserInterface $user)
78+
private function updateUserFields(UserInterface $user): void
7979
{
8080
$this->canonicalFieldsUpdater->updateCanonicalFields($user);
8181
$this->passwordUpdater->hashPassword($user);
@@ -84,7 +84,7 @@ private function updateUserFields(UserInterface $user)
8484
/**
8585
* Recomputes change set for Doctrine implementations not doing it automatically after the event.
8686
*/
87-
private function recomputeChangeSet(ObjectManager $om, UserInterface $user)
87+
private function recomputeChangeSet(ObjectManager $om, UserInterface $user): void
8888
{
8989
$meta = $om->getClassMetadata(get_class($user));
9090

Doctrine/UserManager.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,20 @@ public function __construct(PasswordUpdaterInterface $passwordUpdater, Canonical
4343
$this->class = $class;
4444
}
4545

46+
/**
47+
* @return void
48+
*/
4649
public function deleteUser(UserInterface $user)
4750
{
4851
$this->objectManager->remove($user);
4952
$this->objectManager->flush();
5053
}
5154

55+
/**
56+
* @return string
57+
*
58+
* @phpstan-return class-string<UserInterface>
59+
*/
5260
public function getClass()
5361
{
5462
if (false !== strpos($this->class, ':')) {
@@ -59,21 +67,33 @@ public function getClass()
5967
return $this->class;
6068
}
6169

70+
/**
71+
* @return UserInterface|null
72+
*/
6273
public function findUserBy(array $criteria)
6374
{
6475
return $this->getRepository()->findOneBy($criteria);
6576
}
6677

78+
/**
79+
* @return \Traversable<UserInterface>
80+
*/
6781
public function findUsers()
6882
{
6983
return $this->getRepository()->findAll();
7084
}
7185

86+
/**
87+
* @return void
88+
*/
7289
public function reloadUser(UserInterface $user)
7390
{
7491
$this->objectManager->refresh($user);
7592
}
7693

94+
/**
95+
* @return void
96+
*/
7797
public function updateUser(UserInterface $user, $andFlush = true)
7898
{
7999
$this->updateCanonicalFields($user);
@@ -86,7 +106,7 @@ public function updateUser(UserInterface $user, $andFlush = true)
86106
}
87107

88108
/**
89-
* @return ObjectRepository
109+
* @return ObjectRepository<UserInterface>
90110
*/
91111
protected function getRepository()
92112
{

Form/Factory/FormFactory.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace FOS\UserBundle\Form\Factory;
1313

1414
use Symfony\Component\Form\FormFactoryInterface;
15+
use Symfony\Component\Form\FormInterface;
1516

1617
class FormFactory implements FactoryInterface
1718
{
@@ -38,9 +39,9 @@ class FormFactory implements FactoryInterface
3839
/**
3940
* FormFactory constructor.
4041
*
41-
* @param string $name
42-
* @param string $type
43-
* @param array $validationGroups
42+
* @param string $name
43+
* @param string $type
44+
* @param string[]|null $validationGroups
4445
*/
4546
public function __construct(FormFactoryInterface $formFactory, $name, $type, array $validationGroups = null)
4647
{
@@ -50,6 +51,9 @@ public function __construct(FormFactoryInterface $formFactory, $name, $type, arr
5051
$this->validationGroups = $validationGroups;
5152
}
5253

54+
/**
55+
* @return FormInterface
56+
*/
5357
public function createForm(array $options = [])
5458
{
5559
$options = array_merge(['validation_groups' => $this->validationGroups], $options);

Mailer/MailerInterface.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,15 @@ interface MailerInterface
2020
{
2121
/**
2222
* Send an email to a user to confirm the account creation.
23+
*
24+
* @return void
2325
*/
2426
public function sendConfirmationEmailMessage(UserInterface $user);
2527

2628
/**
2729
* Send an email to a user to confirm the password reset.
30+
*
31+
* @return void
2832
*/
2933
public function sendResettingEmailMessage(UserInterface $user);
3034
}

Mailer/NoopMailer.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,17 @@
2424
*/
2525
class NoopMailer implements MailerInterface
2626
{
27+
/**
28+
* @return void
29+
*/
2730
public function sendConfirmationEmailMessage(UserInterface $user)
2831
{
2932
// nothing happens.
3033
}
3134

35+
/**
36+
* @return void
37+
*/
3238
public function sendResettingEmailMessage(UserInterface $user)
3339
{
3440
// nothing happens.

Mailer/TwigSwiftMailer.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ public function __construct(\Swift_Mailer $mailer, UrlGeneratorInterface $router
4848
$this->parameters = $parameters;
4949
}
5050

51+
/**
52+
* @return void
53+
*/
5154
public function sendConfirmationEmailMessage(UserInterface $user)
5255
{
5356
$template = $this->parameters['template']['confirmation'];
@@ -61,6 +64,9 @@ public function sendConfirmationEmailMessage(UserInterface $user)
6164
$this->sendMessage($template, $context, $this->parameters['from_email']['confirmation'], (string) $user->getEmail());
6265
}
6366

67+
/**
68+
* @return void
69+
*/
6470
public function sendResettingEmailMessage(UserInterface $user)
6571
{
6672
$template = $this->parameters['template']['resetting'];
@@ -79,6 +85,8 @@ public function sendResettingEmailMessage(UserInterface $user)
7985
* @param array $context
8086
* @param array $fromEmail
8187
* @param string $toEmail
88+
*
89+
* @return void
8290
*/
8391
protected function sendMessage($templateName, $context, $fromEmail, $toEmail)
8492
{

Model/UserManager.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ public function __construct(PasswordUpdaterInterface $passwordUpdater, Canonical
3131
$this->canonicalFieldsUpdater = $canonicalFieldsUpdater;
3232
}
3333

34+
/**
35+
* @return UserInterface
36+
*/
3437
public function createUser()
3538
{
3639
$class = $this->getClass();
@@ -39,16 +42,25 @@ public function createUser()
3942
return $user;
4043
}
4144

45+
/**
46+
* @return UserInterface|null
47+
*/
4248
public function findUserByEmail($email)
4349
{
4450
return $this->findUserBy(['emailCanonical' => $this->canonicalFieldsUpdater->canonicalizeEmail($email)]);
4551
}
4652

53+
/**
54+
* @return UserInterface|null
55+
*/
4756
public function findUserByUsername($username)
4857
{
4958
return $this->findUserBy(['usernameCanonical' => $this->canonicalFieldsUpdater->canonicalizeUsername($username)]);
5059
}
5160

61+
/**
62+
* @return UserInterface|null
63+
*/
5264
public function findUserByUsernameOrEmail($usernameOrEmail)
5365
{
5466
if (preg_match('/^.+\@\S+\.\S+$/', $usernameOrEmail)) {
@@ -61,16 +73,25 @@ public function findUserByUsernameOrEmail($usernameOrEmail)
6173
return $this->findUserByUsername($usernameOrEmail);
6274
}
6375

76+
/**
77+
* @return UserInterface|null
78+
*/
6479
public function findUserByConfirmationToken($token)
6580
{
6681
return $this->findUserBy(['confirmationToken' => $token]);
6782
}
6883

84+
/**
85+
* @return void
86+
*/
6987
public function updateCanonicalFields(UserInterface $user)
7088
{
7189
$this->canonicalFieldsUpdater->updateCanonicalFields($user);
7290
}
7391

92+
/**
93+
* @return void
94+
*/
7495
public function updatePassword(UserInterface $user)
7596
{
7697
$this->passwordUpdater->hashPassword($user);

Model/UserManagerInterface.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ public function createUser();
3535

3636
/**
3737
* Deletes a user.
38+
*
39+
* @return void
3840
*/
3941
public function deleteUser(UserInterface $user);
4042

@@ -84,34 +86,44 @@ public function findUserByConfirmationToken($token);
8486
/**
8587
* Returns a collection with all user instances.
8688
*
87-
* @return \Traversable
89+
* @return \Traversable<UserInterface>
8890
*/
8991
public function findUsers();
9092

9193
/**
9294
* Returns the user's fully qualified class name.
9395
*
9496
* @return string
97+
*
98+
* @phpstan-return class-string<UserInterface>
9599
*/
96100
public function getClass();
97101

98102
/**
99103
* Reloads a user.
104+
*
105+
* @return void
100106
*/
101107
public function reloadUser(UserInterface $user);
102108

103109
/**
104110
* Updates a user.
111+
*
112+
* @return void
105113
*/
106114
public function updateUser(UserInterface $user);
107115

108116
/**
109117
* Updates the canonical username and email fields for a user.
118+
*
119+
* @return void
110120
*/
111121
public function updateCanonicalFields(UserInterface $user);
112122

113123
/**
114124
* Updates a user password if a plain password is set.
125+
*
126+
* @return void
115127
*/
116128
public function updatePassword(UserInterface $user);
117129
}

Security/LoginManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function __construct(TokenStorageInterface $tokenStorage, UserCheckerInte
7373
$this->rememberMeHandler = $rememberMeHandler;
7474
}
7575

76-
final public function logInUser($firewallName, UserInterface $user, Response $response = null)
76+
final public function logInUser($firewallName, UserInterface $user, Response $response = null): void
7777
{
7878
$this->userChecker->checkPreAuth($user);
7979

0 commit comments

Comments
 (0)