Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ Changelog
* [BC break] Remove the `Symfony\Component\Security\Core\User\AdvancedUserInterface` methods from our `UserInterface`
* [BC break] Made `\FOS\UserBundle\Model\User::serialize` and `\FOS\UserBundle\Model\User::unserialize` final. Child classes needing to extend the serialization must override `__serialize` and `__unserialize` instead.
* [BC break] `\FOS\UserBundle\Event\GetResponseNullableUserEvent` no longer inherits from `\FOS\UserBundle\Event\GetResponseUserEvent` and `\FOS\UserBundle\Event\UserEvent` as that was breaking variance rules.
* [BC break] A few methods of `FOS\UserBundle\Model\User` now have return types (in methods where Symfony 6 requires them)
* Add support for Symfony 5.
* Add return types in most methods.

### 2.2.4 (2022-01-14)

* Fixed a deprecated warning reported by DebugClassLoader in the AdvancedUserInterface BC layer due to the change done in 2.2.3.
* Fixed a deprecation warning reported by DebugClassLoader in the AdvancedUserInterface BC layer due to the change done in 2.2.3.

### 2.2.3 (2022-01-14)

Expand Down
4 changes: 1 addition & 3 deletions Controller/ChangePasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,8 @@ public function __construct(EventDispatcherInterface $eventDispatcher, FactoryIn

/**
* Change user password.
*
* @return Response
*/
public function changePasswordAction(Request $request)
public function changePasswordAction(Request $request): Response
{
$user = $this->getUser();
if (!is_object($user) || !$user instanceof UserInterface) {
Expand Down
6 changes: 2 additions & 4 deletions Controller/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function __construct(EventDispatcherInterface $eventDispatcher, FactoryIn
/**
* Show the user.
*/
public function showAction()
public function showAction(): Response
{
$user = $this->getUser();
if (!is_object($user) || !$user instanceof UserInterface) {
Expand All @@ -63,10 +63,8 @@ public function showAction()

/**
* Edit the user.
*
* @return Response
*/
public function editAction(Request $request)
public function editAction(Request $request): Response
{
$user = $this->getUser();
if (!is_object($user) || !$user instanceof UserInterface) {
Expand Down
18 changes: 5 additions & 13 deletions Controller/RegistrationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ public function __construct(EventDispatcherInterface $eventDispatcher, FactoryIn
$this->tokenStorage = $tokenStorage;
}

/**
* @return Response
*/
public function registerAction(Request $request)
public function registerAction(Request $request): Response
{
$user = $this->userManager->createUser();
$user->setEnabled(true);
Expand Down Expand Up @@ -104,7 +101,7 @@ public function registerAction(Request $request)
/**
* Tell the user to check their email provider.
*/
public function checkEmailAction(Request $request)
public function checkEmailAction(Request $request): Response
{
$email = $request->getSession()->get('fos_user_send_confirmation_email/email');

Expand All @@ -128,10 +125,8 @@ public function checkEmailAction(Request $request)
* Receive the confirmation token from user email provider, login the user.
*
* @param string $token
*
* @return Response
*/
public function confirmAction(Request $request, $token)
public function confirmAction(Request $request, $token): Response
{
$userManager = $this->userManager;

Expand Down Expand Up @@ -162,7 +157,7 @@ public function confirmAction(Request $request, $token)
/**
* Tell the user his account is now confirmed.
*/
public function confirmedAction(Request $request)
public function confirmedAction(Request $request): Response
{
$user = $this->getUser();
if (!is_object($user) || !$user instanceof UserInterface) {
Expand All @@ -175,10 +170,7 @@ public function confirmedAction(Request $request)
]);
}

/**
* @return string|null
*/
private function getTargetUrlFromSession(SessionInterface $session)
private function getTargetUrlFromSession(SessionInterface $session): ?string
{
$key = sprintf('_security.%s.target_path', $this->tokenStorage->getToken()->getProviderKey());

Expand Down
14 changes: 4 additions & 10 deletions Controller/ResettingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,15 @@ public function __construct(EventDispatcherInterface $eventDispatcher, FactoryIn
/**
* Request reset user password: show form.
*/
public function requestAction()
public function requestAction(): Response
{
return $this->render('@FOSUser/Resetting/request.html.twig');
}

/**
* Request reset user password: submit form and send email.
*
* @return Response
*/
public function sendEmailAction(Request $request)
public function sendEmailAction(Request $request): Response
{
$username = $request->request->get('username');

Expand Down Expand Up @@ -123,10 +121,8 @@ public function sendEmailAction(Request $request)

/**
* Tell the user to check his email provider.
*
* @return Response
*/
public function checkEmailAction(Request $request)
public function checkEmailAction(Request $request): Response
{
$username = $request->query->get('username');

Expand All @@ -144,10 +140,8 @@ public function checkEmailAction(Request $request)
* Reset user password.
*
* @param string $token
*
* @return Response
*/
public function resetAction(Request $request, $token)
public function resetAction(Request $request, $token): Response
{
$user = $this->userManager->findUserByConfirmationToken($token);

Expand Down
9 changes: 2 additions & 7 deletions Controller/SecurityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ public function __construct(AuthenticationUtils $authenticationUtils, CsrfTokenM
$this->tokenManager = $tokenManager;
}

/**
* @return Response
*/
public function loginAction()
public function loginAction(): Response
{
$error = $this->authenticationUtils->getLastAuthenticationError();
$lastUsername = $this->authenticationUtils->getLastUsername();
Expand Down Expand Up @@ -67,10 +64,8 @@ public function logoutAction()
/**
* Renders the login template with the given parameters. Overwrite this function in
* an extended controller to provide additional data for the login template.
*
* @return Response
*/
protected function renderLogin(array $data)
protected function renderLogin(array $data): Response
{
return $this->render('@FOSUser/Security/login.html.twig', $data);
}
Expand Down
5 changes: 1 addition & 4 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@
*/
class Configuration implements ConfigurationInterface
{
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('fos_user');
$rootNode = $treeBuilder->getRootNode();
Expand Down
5 changes: 1 addition & 4 deletions DependencyInjection/FOSUserExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,7 @@ public function load(array $configs, ContainerBuilder $container)
}
}

/**
* {@inheritdoc}
*/
public function getNamespace()
public function getNamespace(): string
{
return 'http://friendsofsymfony.github.io/schema/dic/user';
}
Expand Down
2 changes: 1 addition & 1 deletion Doctrine/CouchDB/UserListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct(PasswordUpdaterInterface $passwordUpdater, Canonical
/**
* {@inheritdoc}
*/
public function getSubscribedEvents()
public function getSubscribedEvents(): array
{
return [
Event::prePersist,
Expand Down
2 changes: 1 addition & 1 deletion Doctrine/UserListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct(PasswordUpdaterInterface $passwordUpdater, Canonical
/**
* {@inheritdoc}
*/
public function getSubscribedEvents()
public function getSubscribedEvents(): array
{
return [
'prePersist',
Expand Down
5 changes: 1 addition & 4 deletions Event/FilterUserResponseEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ public function __construct(UserInterface $user, Request $request, Response $res
$this->response = $response;
}

/**
* @return Response
*/
public function getResponse()
public function getResponse(): Response
{
return $this->response;
}
Expand Down
15 changes: 3 additions & 12 deletions Event/FormEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,12 @@ public function __construct(FormInterface $form, Request $request)
$this->request = $request;
}

/**
* @return FormInterface
*/
public function getForm()
public function getForm(): FormInterface
{
return $this->form;
}

/**
* @return Request
*/
public function getRequest()
public function getRequest(): Request
{
return $this->request;
}
Expand All @@ -66,10 +60,7 @@ public function setResponse(Response $response)
$this->response = $response;
}

/**
* @return Response|null
*/
public function getResponse()
public function getResponse(): ?Response
{
return $this->response;
}
Expand Down
18 changes: 5 additions & 13 deletions Event/GetResponseNullableUserEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* Response user event that allows null user.
*
* @author Konstantinos Christofilos <kostas.christofilos@gmail.com>
* @final
*/
class GetResponseNullableUserEvent extends Event
{
Expand All @@ -38,24 +39,18 @@ class GetResponseNullableUserEvent extends Event
*/
private $response;

public function __construct(UserInterface $user = null, Request $request)
public function __construct(?UserInterface $user, Request $request)
{
$this->user = $user;
$this->request = $request;
}

/**
* @return UserInterface|null
*/
public function getUser()
public function getUser(): ?UserInterface
{
return $this->user;
}

/**
* @return Request
*/
public function getRequest()
public function getRequest(): Request
{
return $this->request;
}
Expand All @@ -65,10 +60,7 @@ public function setResponse(Response $response)
$this->response = $response;
}

/**
* @return Response|null
*/
public function getResponse()
public function getResponse(): ?Response
{
return $this->response;
}
Expand Down
8 changes: 4 additions & 4 deletions Event/GetResponseUserEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

use Symfony\Component\HttpFoundation\Response;

/**
* @final
*/
class GetResponseUserEvent extends UserEvent
{
/**
Expand All @@ -25,10 +28,7 @@ public function setResponse(Response $response)
$this->response = $response;
}

/**
* @return Response|null
*/
public function getResponse()
public function getResponse(): ?Response
{
return $this->response;
}
Expand Down
13 changes: 2 additions & 11 deletions Event/UserEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,18 @@ class UserEvent extends Event
*/
protected $user;

/**
* UserEvent constructor.
*/
public function __construct(UserInterface $user, Request $request = null)
{
$this->user = $user;
$this->request = $request;
}

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

/**
* @return Request|null
*/
public function getRequest()
public function getRequest(): ?Request
{
return $this->request;
}
Expand Down
2 changes: 1 addition & 1 deletion EventListener/AuthenticationListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function __construct(LoginManagerInterface $loginManager, $firewallName)
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents()
public static function getSubscribedEvents(): array
{
return [
FOSUserEvents::REGISTRATION_COMPLETED => 'authenticate',
Expand Down
5 changes: 1 addition & 4 deletions EventListener/EmailConfirmationListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ public function __construct(MailerInterface $mailer, TokenGeneratorInterface $to
$this->session = $session;
}

/**
* @return array
*/
public static function getSubscribedEvents()
public static function getSubscribedEvents(): array
{
return [
FOSUserEvents::REGISTRATION_SUCCESS => 'onRegistrationSuccess',
Expand Down
6 changes: 2 additions & 4 deletions EventListener/FlashListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function __construct(RequestStack $requestStack, TranslatorInterface $tra
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents()
public static function getSubscribedEvents(): array
{
return [
FOSUserEvents::CHANGE_PASSWORD_COMPLETED => 'addSuccessFlash',
Expand Down Expand Up @@ -91,10 +91,8 @@ private function getSession(): Session

/**
* @param string $message
*
* @return string
*/
private function trans($message, array $params = [])
private function trans($message, array $params = []): string
{
return $this->translator->trans($message, $params, 'FOSUserBundle');
}
Expand Down
Loading