Skip to content

Commit

Permalink
Add native return types
Browse files Browse the repository at this point in the history
stof committed Jun 25, 2024
1 parent 49f2c44 commit fd22eae
Showing 41 changed files with 82 additions and 260 deletions.
10 changes: 2 additions & 8 deletions src/Controller/SecurityController.php
Original file line number Diff line number Diff line change
@@ -49,18 +49,12 @@ public function loginAction(): Response
]);
}

/**
* @return never
*/
public function checkAction()
public function checkAction(): never
{
throw new \RuntimeException('You must configure the check path to be handled by the firewall using form_login in your security firewall configuration.');
}

/**
* @return never
*/
public function logoutAction()
public function logoutAction(): never
{
throw new \RuntimeException('You must activate the logout in your security firewall configuration.');
}
28 changes: 7 additions & 21 deletions src/Doctrine/UserManager.php
Original file line number Diff line number Diff line change
@@ -43,21 +43,16 @@ public function __construct(PasswordUpdaterInterface $passwordUpdater, Canonical
$this->class = $class;
}

/**
* @return void
*/
public function deleteUser(UserInterface $user)
public function deleteUser(UserInterface $user): void
{
$this->objectManager->remove($user);
$this->objectManager->flush();
}

/**
* @return string
*
* @phpstan-return class-string<UserInterface>
*/
public function getClass()
public function getClass(): string
{
if (false !== strpos($this->class, ':')) {
$metadata = $this->objectManager->getClassMetadata($this->class);
@@ -67,34 +62,25 @@ public function getClass()
return $this->class;
}

/**
* @return UserInterface|null
*/
public function findUserBy(array $criteria)
public function findUserBy(array $criteria): ?UserInterface
{
return $this->getRepository()->findOneBy($criteria);
}

/**
* @return iterable<UserInterface>
*/
public function findUsers()
public function findUsers(): iterable
{
return $this->getRepository()->findAll();
}

/**
* @return void
*/
public function reloadUser(UserInterface $user)
public function reloadUser(UserInterface $user): void
{
$this->objectManager->refresh($user);
}

/**
* @return void
*/
public function updateUser(UserInterface $user, $andFlush = true)
public function updateUser(UserInterface $user, $andFlush = true): void
{
$this->updateCanonicalFields($user);
$this->updatePassword($user);
@@ -108,7 +94,7 @@ public function updateUser(UserInterface $user, $andFlush = true)
/**
* @return ObjectRepository<UserInterface>
*/
protected function getRepository()
protected function getRepository(): ObjectRepository
{
return $this->objectManager->getRepository($this->getClass());
}
4 changes: 1 addition & 3 deletions src/Event/FilterUserResponseEvent.php
Original file line number Diff line number Diff line change
@@ -35,10 +35,8 @@ public function getResponse(): Response

/**
* Sets a new response object.
*
* @return void
*/
public function setResponse(Response $response)
public function setResponse(Response $response): void
{
$this->response = $response;
}
5 changes: 1 addition & 4 deletions src/Event/FormEvent.php
Original file line number Diff line number Diff line change
@@ -52,10 +52,7 @@ public function getRequest(): Request
return $this->request;
}

/**
* @return void
*/
public function setResponse(Response $response)
public function setResponse(Response $response): void
{
$this->response = $response;
}
5 changes: 1 addition & 4 deletions src/Event/GetResponseNullableUserEvent.php
Original file line number Diff line number Diff line change
@@ -54,10 +54,7 @@ public function getRequest(): Request
return $this->request;
}

/**
* @return void
*/
public function setResponse(Response $response)
public function setResponse(Response $response): void
{
$this->response = $response;
}
5 changes: 1 addition & 4 deletions src/Event/GetResponseUserEvent.php
Original file line number Diff line number Diff line change
@@ -20,10 +20,7 @@ final class GetResponseUserEvent extends UserEvent
*/
private $response;

/**
* @return void
*/
public function setResponse(Response $response)
public function setResponse(Response $response): void
{
$this->response = $response;
}
4 changes: 1 addition & 3 deletions src/EventListener/AuthenticationListener.php
Original file line number Diff line number Diff line change
@@ -56,10 +56,8 @@ public static function getSubscribedEvents(): array

/**
* @param string $eventName
*
* @return void
*/
public function authenticate(FilterUserResponseEvent $event, $eventName, EventDispatcherInterface $eventDispatcher)
public function authenticate(FilterUserResponseEvent $event, $eventName, EventDispatcherInterface $eventDispatcher): void
{
try {
$this->loginManager->logInUser($this->firewallName, $event->getUser(), $event->getResponse());
5 changes: 1 addition & 4 deletions src/EventListener/EmailConfirmationListener.php
Original file line number Diff line number Diff line change
@@ -45,10 +45,7 @@ public static function getSubscribedEvents(): array
];
}

/**
* @return void
*/
public function onRegistrationSuccess(FormEvent $event)
public function onRegistrationSuccess(FormEvent $event): void
{
/** @var \FOS\UserBundle\Model\UserInterface $user */
$user = $event->getForm()->getData();
4 changes: 1 addition & 3 deletions src/EventListener/FlashListener.php
Original file line number Diff line number Diff line change
@@ -64,10 +64,8 @@ public static function getSubscribedEvents(): array

/**
* @param string $eventName
*
* @return void
*/
public function addSuccessFlash(Event $event, $eventName)
public function addSuccessFlash(Event $event, $eventName): void
{
if (!isset(self::$successMessages[$eventName])) {
throw new \InvalidArgumentException('This event does not correspond to a known flash message');
10 changes: 2 additions & 8 deletions src/EventListener/LastLoginListener.php
Original file line number Diff line number Diff line change
@@ -45,21 +45,15 @@ public static function getSubscribedEvents(): array
];
}

/**
* @return void
*/
public function onImplicitLogin(UserEvent $event)
public function onImplicitLogin(UserEvent $event): void
{
$user = $event->getUser();

$user->setLastLogin(new \DateTime());
$this->userManager->updateUser($user);
}

/**
* @return void
*/
public function onSecurityInteractiveLogin(InteractiveLoginEvent $event)
public function onSecurityInteractiveLogin(InteractiveLoginEvent $event): void
{
$user = $event->getAuthenticationToken()->getUser();

10 changes: 2 additions & 8 deletions src/EventListener/ResettingListener.php
Original file line number Diff line number Diff line change
@@ -52,20 +52,14 @@ public static function getSubscribedEvents(): array
];
}

/**
* @return void
*/
public function onResettingResetInitialize(GetResponseUserEvent $event)
public function onResettingResetInitialize(GetResponseUserEvent $event): void
{
if (!$event->getUser()->isPasswordRequestNonExpired($this->tokenTtl)) {
$event->setResponse(new RedirectResponse($this->router->generate('fos_user_resetting_request')));
}
}

/**
* @return void
*/
public function onResettingResetSuccess(FormEvent $event)
public function onResettingResetSuccess(FormEvent $event): void
{
/** @var \FOS\UserBundle\Model\UserInterface $user */
$user = $event->getForm()->getData();
5 changes: 1 addition & 4 deletions src/Form/Factory/FactoryInterface.php
Original file line number Diff line number Diff line change
@@ -15,8 +15,5 @@

interface FactoryInterface
{
/**
* @return FormInterface
*/
public function createForm();
public function createForm(): FormInterface;
}
4 changes: 1 addition & 3 deletions src/Form/Factory/FormFactory.php
Original file line number Diff line number Diff line change
@@ -53,10 +53,8 @@ public function __construct(FormFactoryInterface $formFactory, $name, $type, ?ar

/**
* @param array<string, mixed> $options
*
* @return FormInterface
*/
public function createForm(array $options = [])
public function createForm(array $options = []): FormInterface
{
$options = array_merge(['validation_groups' => $this->validationGroups], $options);

8 changes: 2 additions & 6 deletions src/Mailer/MailerInterface.php
Original file line number Diff line number Diff line change
@@ -20,15 +20,11 @@ interface MailerInterface
{
/**
* Send an email to a user to confirm the account creation.
*
* @return void
*/
public function sendConfirmationEmailMessage(UserInterface $user);
public function sendConfirmationEmailMessage(UserInterface $user): void;

/**
* Send an email to a user to confirm the password reset.
*
* @return void
*/
public function sendResettingEmailMessage(UserInterface $user);
public function sendResettingEmailMessage(UserInterface $user): void;
}
10 changes: 2 additions & 8 deletions src/Mailer/NoopMailer.php
Original file line number Diff line number Diff line change
@@ -22,18 +22,12 @@
*/
final class NoopMailer implements MailerInterface
{
/**
* @return void
*/
public function sendConfirmationEmailMessage(UserInterface $user)
public function sendConfirmationEmailMessage(UserInterface $user): void
{
// nothing happens.
}

/**
* @return void
*/
public function sendResettingEmailMessage(UserInterface $user)
public function sendResettingEmailMessage(UserInterface $user): void
{
// nothing happens.
}
45 changes: 9 additions & 36 deletions src/Model/UserManager.php
Original file line number Diff line number Diff line change
@@ -31,37 +31,25 @@ public function __construct(PasswordUpdaterInterface $passwordUpdater, Canonical
$this->canonicalFieldsUpdater = $canonicalFieldsUpdater;
}

/**
* @return UserInterface
*/
public function createUser()
public function createUser(): UserInterface
{
$class = $this->getClass();
$user = new $class();

return $user;
}

/**
* @return UserInterface|null
*/
public function findUserByEmail($email)
public function findUserByEmail($email): ?UserInterface
{
return $this->findUserBy(['emailCanonical' => $this->canonicalFieldsUpdater->canonicalizeEmail($email)]);
}

/**
* @return UserInterface|null
*/
public function findUserByUsername($username)
public function findUserByUsername($username): ?UserInterface
{
return $this->findUserBy(['usernameCanonical' => $this->canonicalFieldsUpdater->canonicalizeUsername($username)]);
}

/**
* @return UserInterface|null
*/
public function findUserByUsernameOrEmail($usernameOrEmail)
public function findUserByUsernameOrEmail($usernameOrEmail): ?UserInterface
{
if (preg_match('/^.+\@\S+\.\S+$/', $usernameOrEmail)) {
$user = $this->findUserByEmail($usernameOrEmail);
@@ -73,42 +61,27 @@ public function findUserByUsernameOrEmail($usernameOrEmail)
return $this->findUserByUsername($usernameOrEmail);
}

/**
* @return UserInterface|null
*/
public function findUserByConfirmationToken($token)
public function findUserByConfirmationToken($token): ?UserInterface
{
return $this->findUserBy(['confirmationToken' => $token]);
}

/**
* @return void
*/
public function updateCanonicalFields(UserInterface $user)
public function updateCanonicalFields(UserInterface $user): void
{
$this->canonicalFieldsUpdater->updateCanonicalFields($user);
}

/**
* @return void
*/
public function updatePassword(UserInterface $user)
public function updatePassword(UserInterface $user): void
{
$this->passwordUpdater->hashPassword($user);
}

/**
* @return PasswordUpdaterInterface
*/
protected function getPasswordUpdater()
protected function getPasswordUpdater(): PasswordUpdaterInterface
{
return $this->passwordUpdater;
}

/**
* @return CanonicalFieldsUpdater
*/
protected function getCanonicalFieldsUpdater()
protected function getCanonicalFieldsUpdater(): CanonicalFieldsUpdater
{
return $this->canonicalFieldsUpdater;
}
50 changes: 13 additions & 37 deletions src/Model/UserManagerInterface.php
Original file line number Diff line number Diff line change
@@ -28,104 +28,80 @@ interface UserManagerInterface
{
/**
* Creates an empty user instance.
*
* @return UserInterface
*/
public function createUser();
public function createUser(): UserInterface;

/**
* Deletes a user.
*
* @return void
*/
public function deleteUser(UserInterface $user);
public function deleteUser(UserInterface $user): void;

/**
* Finds one user by the given criteria.
*
* @param array<string, mixed> $criteria
*
* @return UserInterface|null
*/
public function findUserBy(array $criteria);
public function findUserBy(array $criteria): ?UserInterface;

/**
* Find a user by its username.
*
* @param string $username
*
* @return UserInterface|null
*/
public function findUserByUsername($username);
public function findUserByUsername($username): ?UserInterface;

/**
* Finds a user by its email.
*
* @param string $email
*
* @return UserInterface|null
*/
public function findUserByEmail($email);
public function findUserByEmail($email): ?UserInterface;

/**
* Finds a user by its username or email.
*
* @param string $usernameOrEmail
*
* @return UserInterface|null
*/
public function findUserByUsernameOrEmail($usernameOrEmail);
public function findUserByUsernameOrEmail($usernameOrEmail): ?UserInterface;

/**
* Finds a user by its confirmationToken.
*
* @param string $token
*
* @return UserInterface|null
*/
public function findUserByConfirmationToken($token);
public function findUserByConfirmationToken($token): ?UserInterface;

/**
* Returns a collection with all user instances.
*
* @return iterable<UserInterface>
*/
public function findUsers();
public function findUsers(): iterable;

/**
* Returns the user's fully qualified class name.
*
* @return string
*
* @phpstan-return class-string<UserInterface>
*/
public function getClass();
public function getClass(): string;

/**
* Reloads a user.
*
* @return void
*/
public function reloadUser(UserInterface $user);
public function reloadUser(UserInterface $user): void;

/**
* Updates a user.
*
* @return void
*/
public function updateUser(UserInterface $user);
public function updateUser(UserInterface $user): void;

/**
* Updates the canonical username and email fields for a user.
*
* @return void
*/
public function updateCanonicalFields(UserInterface $user);
public function updateCanonicalFields(UserInterface $user): void;

/**
* Updates a user password if a plain password is set.
*
* @return void
*/
public function updatePassword(UserInterface $user);
public function updatePassword(UserInterface $user): void;
}
4 changes: 1 addition & 3 deletions src/Security/LoginManager.php
Original file line number Diff line number Diff line change
@@ -84,10 +84,8 @@ final public function logInUser($firewallName, UserInterface $user, ?Response $r

/**
* @param string $firewall
*
* @return UsernamePasswordToken
*/
protected function createToken($firewall, UserInterface $user)
protected function createToken($firewall, UserInterface $user): UsernamePasswordToken
{
return new UsernamePasswordToken($user, $firewall, $user->getRoles());
}
4 changes: 1 addition & 3 deletions src/Security/LoginManagerInterface.php
Original file line number Diff line number Diff line change
@@ -18,8 +18,6 @@ interface LoginManagerInterface
{
/**
* @param string $firewallName
*
* @return void
*/
public function logInUser($firewallName, UserInterface $user, ?Response $response = null);
public function logInUser($firewallName, UserInterface $user, ?Response $response = null): void;
}
5 changes: 1 addition & 4 deletions src/Util/CanonicalFieldsUpdater.php
Original file line number Diff line number Diff line change
@@ -31,10 +31,7 @@ public function __construct(CanonicalizerInterface $usernameCanonicalizer, Canon
$this->emailCanonicalizer = $emailCanonicalizer;
}

/**
* @return void
*/
public function updateCanonicalFields(UserInterface $user)
public function updateCanonicalFields(UserInterface $user): void
{
$user->setUsernameCanonical($this->canonicalizeUsername($user->getUsername()));
$user->setEmailCanonical($this->canonicalizeEmail($user->getEmail()));
2 changes: 1 addition & 1 deletion src/Util/Canonicalizer.php
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@

class Canonicalizer implements CanonicalizerInterface
{
public function canonicalize($string)
public function canonicalize($string): ?string
{
if (null === $string) {
return null;
4 changes: 1 addition & 3 deletions src/Util/CanonicalizerInterface.php
Original file line number Diff line number Diff line change
@@ -16,9 +16,7 @@ interface CanonicalizerInterface
/**
* @param string|null $string
*
* @return string|null
*
* @phpstan-return ($string is null ? null : string)
*/
public function canonicalize($string);
public function canonicalize($string): ?string;
}
5 changes: 1 addition & 4 deletions src/Util/HashingPasswordUpdater.php
Original file line number Diff line number Diff line change
@@ -29,10 +29,7 @@ public function __construct(PasswordHasherFactoryInterface $passwordHasherFactor
$this->passwordHasherFactory = $passwordHasherFactory;
}

/**
* @return void
*/
public function hashPassword(UserInterface $user)
public function hashPassword(UserInterface $user): void
{
$plainPassword = $user->getPlainPassword();

4 changes: 1 addition & 3 deletions src/Util/PasswordUpdaterInterface.php
Original file line number Diff line number Diff line change
@@ -23,8 +23,6 @@ interface PasswordUpdaterInterface
*
* The implement should be a no-op in case there is no new password (it should not erase the
* existing hash with a wrong one).
*
* @return void
*/
public function hashPassword(UserInterface $user);
public function hashPassword(UserInterface $user): void;
}
2 changes: 1 addition & 1 deletion src/Util/TokenGenerator.php
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@

class TokenGenerator implements TokenGeneratorInterface
{
public function generateToken()
public function generateToken(): string
{
return rtrim(strtr(base64_encode(random_bytes(32)), '+/', '-_'), '=');
}
5 changes: 1 addition & 4 deletions src/Util/TokenGeneratorInterface.php
Original file line number Diff line number Diff line change
@@ -13,8 +13,5 @@

interface TokenGeneratorInterface
{
/**
* @return string
*/
public function generateToken();
public function generateToken(): string;
}
20 changes: 5 additions & 15 deletions src/Util/UserManipulator.php
Original file line number Diff line number Diff line change
@@ -87,10 +87,8 @@ public function create($username, $password, $email, $active, $superadmin): User
* Activates the given user.
*
* @param string $username
*
* @return void
*/
public function activate($username)
public function activate($username): void
{
$user = $this->findUserByUsernameOrThrowException($username);
$user->setEnabled(true);
@@ -104,10 +102,8 @@ public function activate($username)
* Deactivates the given user.
*
* @param string $username
*
* @return void
*/
public function deactivate($username)
public function deactivate($username): void
{
$user = $this->findUserByUsernameOrThrowException($username);
$user->setEnabled(false);
@@ -122,10 +118,8 @@ public function deactivate($username)
*
* @param string $username
* @param string $password
*
* @return void
*/
public function changePassword($username, $password)
public function changePassword($username, $password): void
{
$user = $this->findUserByUsernameOrThrowException($username);
$user->setPlainPassword($password);
@@ -139,10 +133,8 @@ public function changePassword($username, $password)
* Promotes the given user.
*
* @param string $username
*
* @return void
*/
public function promote($username)
public function promote($username): void
{
$user = $this->findUserByUsernameOrThrowException($username);
$user->setSuperAdmin(true);
@@ -156,10 +148,8 @@ public function promote($username)
* Demotes the given user.
*
* @param string $username
*
* @return void
*/
public function demote($username)
public function demote($username): void
{
$user = $this->findUserByUsernameOrThrowException($username);
$user->setSuperAdmin(false);
5 changes: 1 addition & 4 deletions tests/Command/ActivateUserCommandTest.php
Original file line number Diff line number Diff line change
@@ -57,10 +57,7 @@ public function testExecuteInteractiveWithQuestionHelper()
$this->assertMatchesRegularExpression('/User "user" has been activated/', $commandTester->getDisplay());
}

/**
* @return CommandTester
*/
private function createCommandTester(UserManipulator $manipulator, ?Application $application = null)
private function createCommandTester(UserManipulator $manipulator, ?Application $application = null): CommandTester
{
if (null === $application) {
$application = new Application();
5 changes: 1 addition & 4 deletions tests/Command/ChangePasswordCommandTest.php
Original file line number Diff line number Diff line change
@@ -58,10 +58,7 @@ public function testExecuteInteractiveWithQuestionHelper()
$this->assertMatchesRegularExpression('/Changed password for user user/', $commandTester->getDisplay());
}

/**
* @return CommandTester
*/
private function createCommandTester(UserManipulator $userManipulator, ?Application $application = null)
private function createCommandTester(UserManipulator $userManipulator, ?Application $application = null): CommandTester
{
if (null === $application) {
$application = new Application();
5 changes: 1 addition & 4 deletions tests/Command/CreateUserCommandTest.php
Original file line number Diff line number Diff line change
@@ -61,10 +61,7 @@ public function testExecuteInteractiveWithQuestionHelper()
$this->assertMatchesRegularExpression('/Created user user/', $commandTester->getDisplay());
}

/**
* @return CommandTester
*/
private function createCommandTester(UserManipulator $manipulator, ?Application $application = null)
private function createCommandTester(UserManipulator $manipulator, ?Application $application = null): CommandTester
{
if (null === $application) {
$application = new Application();
5 changes: 1 addition & 4 deletions tests/Command/DeactivateUserCommandTest.php
Original file line number Diff line number Diff line change
@@ -57,10 +57,7 @@ public function testExecuteInteractiveWithQuestionHelper()
$this->assertMatchesRegularExpression('/User "user" has been deactivated/', $commandTester->getDisplay());
}

/**
* @return CommandTester
*/
private function createCommandTester(UserManipulator $manipulator, ?Application $application = null)
private function createCommandTester(UserManipulator $manipulator, ?Application $application = null): CommandTester
{
if (null === $application) {
$application = new Application();
5 changes: 1 addition & 4 deletions tests/Command/DemoteUserCommandTest.php
Original file line number Diff line number Diff line change
@@ -58,10 +58,7 @@ public function testExecuteInteractiveWithQuestionHelper()
$this->assertMatchesRegularExpression('/Role "role" has been removed from user "user"/', $commandTester->getDisplay());
}

/**
* @return CommandTester
*/
private function createCommandTester(UserManipulator $manipulator, ?Application $application = null)
private function createCommandTester(UserManipulator $manipulator, ?Application $application = null): CommandTester
{
if (null === $application) {
$application = new Application();
5 changes: 1 addition & 4 deletions tests/Command/PromoteUserCommandTest.php
Original file line number Diff line number Diff line change
@@ -58,10 +58,7 @@ public function testExecuteInteractiveWithQuestionHelper()
$this->assertMatchesRegularExpression('/Role "role" has been added to user "user"/', $commandTester->getDisplay());
}

/**
* @return CommandTester
*/
private function createCommandTester(UserManipulator $manipulator, ?Application $application = null)
private function createCommandTester(UserManipulator $manipulator, ?Application $application = null): CommandTester
{
if (null === $application) {
$application = new Application();
8 changes: 4 additions & 4 deletions tests/DependencyInjection/FOSUserExtensionTest.php
Original file line number Diff line number Diff line change
@@ -363,9 +363,9 @@ public function testUserManagerSetFactory($dbDriver, $doctrineService)
}

/**
* @return array
* @return iterable<array{string, string}>
*/
public function userManagerSetFactoryProvider()
public function userManagerSetFactoryProvider(): iterable
{
return [
['orm', 'doctrine'],
@@ -396,7 +396,7 @@ protected function createFullConfiguration()
*
* @return array<string, mixed>
*/
protected function getEmptyConfig()
protected function getEmptyConfig(): array
{
$yaml = <<<EOF
db_driver: mongodb
@@ -416,7 +416,7 @@ protected function getEmptyConfig()
/**
* @return array<string, mixed>
*/
protected function getFullConfig()
protected function getFullConfig(): array
{
$yaml = <<<EOF
db_driver: orm
5 changes: 1 addition & 4 deletions tests/Doctrine/UserManagerTest.php
Original file line number Diff line number Diff line change
@@ -101,10 +101,7 @@ public function testUpdateUser()
$this->userManager->updateUser($user);
}

/**
* @return mixed
*/
protected function getUser()
protected function getUser(): mixed
{
$userClass = static::USER_CLASS;

10 changes: 3 additions & 7 deletions tests/Model/UserManagerTest.php
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@

namespace FOS\UserBundle\Tests\Model;

use FOS\UserBundle\Model\User;
use FOS\UserBundle\Model\UserManager;
use FOS\UserBundle\Util\CanonicalFieldsUpdater;
use FOS\UserBundle\Util\PasswordUpdaterInterface;
@@ -174,21 +175,16 @@ public function testFindUserByUsernameOrEmailWithUsernameThatLooksLikeEmail()
$this->assertSame($user, $actualUser);
}

/**
* @return mixed
*/
private function getUser()
private function getUser(): User&MockObject
{
return $this->getMockBuilder('FOS\UserBundle\Model\User')
->getMockForAbstractClass();
}

/**
* @param array{PasswordUpdaterInterface, CanonicalFieldsUpdater} $args
*
* @return UserManager&MockObject
*/
private function getUserManager(array $args)
private function getUserManager(array $args): UserManager&MockObject
{
return $this->getMockBuilder('FOS\UserBundle\Model\UserManager')
->setConstructorArgs($args)
5 changes: 1 addition & 4 deletions tests/Model/UserTest.php
Original file line number Diff line number Diff line change
@@ -98,10 +98,7 @@ public function testIsEqualTo()
$this->assertFalse($user->isEqualTo($user4));
}

/**
* @return User
*/
protected function getUser()
protected function getUser(): User
{
return $this->getMockForAbstractClass('FOS\UserBundle\Model\User');
}
2 changes: 1 addition & 1 deletion tests/Routing/RoutingTest.php
Original file line number Diff line number Diff line change
@@ -52,7 +52,7 @@ public function testLoadRouting($routeName, $path, array $methods)
/**
* @return iterable<array{string, string, string[]}>
*/
public function loadRoutingProvider()
public function loadRoutingProvider(): iterable
{
return [
['fos_user_change_password', '/change-password', ['GET', 'POST']],
5 changes: 1 addition & 4 deletions tests/Util/CanonicalFieldsUpdaterTest.php
Original file line number Diff line number Diff line change
@@ -61,10 +61,7 @@ public function testUpdateCanonicalFields()
$this->assertSame('user@example.com', $user->getEmailCanonical());
}

/**
* @return CanonicalizerInterface&MockObject
*/
private function getMockCanonicalizer()
private function getMockCanonicalizer(): CanonicalizerInterface&MockObject
{
return $this->getMockBuilder('FOS\UserBundle\Util\CanonicalizerInterface')->getMock();
}
2 changes: 1 addition & 1 deletion tests/Util/CanonicalizerTest.php
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ public function testCanonicalize(?string $source, ?string $expectedResult)
/**
* @return iterable<array{string|null, string|null}>
*/
public function canonicalizeProvider()
public function canonicalizeProvider(): iterable
{
return [
[null, null],
8 changes: 2 additions & 6 deletions tests/Util/UserManipulatorTest.php
Original file line number Diff line number Diff line change
@@ -373,10 +373,8 @@ public function testRemoveRole()
/**
* @param string $event
* @param bool $once
*
* @return MockObject&EventDispatcherInterface
*/
protected function getEventDispatcherMock($event, $once = true)
protected function getEventDispatcherMock($event, $once = true): MockObject&EventDispatcherInterface
{
$eventDispatcherMock = $this->getMockBuilder(EventDispatcherInterface::class)->getMock();

@@ -389,10 +387,8 @@ protected function getEventDispatcherMock($event, $once = true)

/**
* @param bool $once
*
* @return MockObject&RequestStack
*/
protected function getRequestStackMock($once = true)
protected function getRequestStackMock($once = true): MockObject&RequestStack
{
$requestStackMock = $this->getMockBuilder(RequestStack::class)->getMock();

0 comments on commit fd22eae

Please sign in to comment.