Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type hints #378

Merged
merged 1 commit into from
Oct 1, 2021
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
18 changes: 3 additions & 15 deletions src/Action/CheckRegistrationMailAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,12 @@

final class CheckRegistrationMailAction
{
/**
* @var UserManagerInterface
*/
private $userManager;
private UserManagerInterface $userManager;

/**
* @var Environment
*/
private $twig;
private Environment $twig;

/**
* @var RouterInterface
*/
private $router;
private RouterInterface $router;

/**
* CheckRegistrationMailAction constructor.
*/
public function __construct(UserManagerInterface $userManager, Environment $twig, RouterInterface $router)
{
$this->userManager = $userManager;
Expand Down
15 changes: 3 additions & 12 deletions src/Action/ConfirmRegistrationAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,11 @@

final class ConfirmRegistrationAction
{
/**
* @var EventDispatcherInterface
*/
private $eventDispatcher;
private EventDispatcherInterface $eventDispatcher;

/**
* @var UserManagerInterface
*/
private $userManager;
private UserManagerInterface $userManager;

/**
* @var RouterInterface
*/
private $router;
private RouterInterface $router;

public function __construct(
EventDispatcherInterface $eventDispatcher,
Expand Down
35 changes: 10 additions & 25 deletions src/Action/EditProfileAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,41 +32,26 @@

final class EditProfileAction
{
/**
* @var EventDispatcherInterface
*/
private $eventDispatcher;
private EventDispatcherInterface $eventDispatcher;

/**
* @var FormFactoryInterface
*/
private $formFactory;
private FormFactoryInterface $formFactory;

/**
* @var UserManagerInterface
*/
private $userManager;
private UserManagerInterface $userManager;

/**
* @var Environment
*/
private $twig;
private Environment $twig;

/**
* @var RouterInterface
*/
private $router;
private RouterInterface $router;

private Security $security;

/**
* @var Security
* @phpstan-var class-string<Profile>
*/
private $security;
private string $formModel;

/**
* @var string
* @phpstan-param class-string<Profile> $formModel
*/
private $formModel;

public function __construct(
EventDispatcherInterface $eventDispatcher,
FormFactoryInterface $formFactory,
Expand Down
30 changes: 9 additions & 21 deletions src/Action/RegistrationAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,36 +30,24 @@

final class RegistrationAction
{
/**
* @var EventDispatcherInterface
*/
private $eventDispatcher;
private EventDispatcherInterface $eventDispatcher;

/**
* @var FormFactoryInterface
*/
private $formFactory;
private FormFactoryInterface $formFactory;

/**
* @var UserManagerInterface
*/
private $userManager;
private UserManagerInterface $userManager;

/**
* @var Environment
*/
private $twig;
private Environment $twig;

private RouterInterface $router;

/**
* @var RouterInterface
* @phpstan-var class-string<Registration>
*/
private $router;
private string $formModel;

/**
* @var string
* @phpstan-param class-string<Registration> $formModel
*/
private $formModel;

public function __construct(
EventDispatcherInterface $eventDispatcher,
FormFactoryInterface $formFactory,
Expand Down
15 changes: 3 additions & 12 deletions src/Action/RegistrationConfirmedAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,11 @@

final class RegistrationConfirmedAction
{
/**
* @var Environment
*/
private $twig;
private Environment $twig;

/**
* @var Security
*/
private $security;
private Security $security;

/**
* @var TokenStorageInterface
*/
private $tokenStorage;
private TokenStorageInterface $tokenStorage;

public function __construct(Environment $twig, Security $security, TokenStorageInterface $tokenStorage)
{
Expand Down
12 changes: 3 additions & 9 deletions src/Action/ShowProfileAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,9 @@

final class ShowProfileAction
{
/**
* @var Environment
*/
private $twig;

/**
* @var Security
*/
private $security;
private Environment $twig;

private Security $security;

public function __construct(Environment $twig, Security $security)
{
Expand Down
17 changes: 4 additions & 13 deletions src/Event/GetResponseRegistrationEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,19 @@

class GetResponseRegistrationEvent extends Event
{
/**
* @var Request|null
*/
protected $request;
protected ?Request $request;

/**
* @var Registration
*/
protected $registration;
protected Registration $registration;

/**
* @var Response|null
*/
private $response;
private ?Response $response = null;

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

public function setResponse(Response $response): void
public function setResponse(?Response $response): void
{
$this->response = $response;
}
Expand Down
6 changes: 2 additions & 4 deletions src/Event/UserFormEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@

final class UserFormEvent extends FormEvent
{
/**
* @var UserInterface
*/
private $user;
private UserInterface $user;

public function __construct(UserInterface $user, FormInterface $form, Request $request)
{
parent::__construct($form, $request);

$this->user = $user;
}

Expand Down
17 changes: 4 additions & 13 deletions src/EventListener/AlreadyLoggedinListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,10 @@

final class AlreadyLoggedinListener implements EventSubscriberInterface
{
/**
* @var Security
*/
private $security;

/**
* @var RouterInterface
*/
private $router;

/**
* AlreadyLoggedinListener constructor.
*/
private Security $security;

private RouterInterface $router;

public function __construct(Security $security, RouterInterface $router)
{
$this->security = $security;
Expand Down
10 changes: 2 additions & 8 deletions src/EventListener/AuthenticationListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,9 @@

final class AuthenticationListener implements EventSubscriberInterface
{
/**
* @var LoginManagerInterface
*/
private $loginManager;
private LoginManagerInterface $loginManager;

/**
* @var string
*/
private $firewallName;
private string $firewallName;

public function __construct(LoginManagerInterface $loginManager, string $firewallName)
{
Expand Down
20 changes: 4 additions & 16 deletions src/EventListener/EmailConfirmationListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,13 @@

final class EmailConfirmationListener implements EventSubscriberInterface
{
/**
* @var MailerInterface
*/
private $mailer;
private MailerInterface $mailer;

/**
* @var TokenGeneratorInterface
*/
private $tokenGenerator;
private TokenGeneratorInterface $tokenGenerator;

/**
* @var UrlGeneratorInterface
*/
private $router;
private UrlGeneratorInterface $router;

/**
* @var SessionInterface
*/
private $session;
private SessionInterface $session;

public function __construct(
MailerInterface $mailer,
Expand Down
12 changes: 3 additions & 9 deletions src/EventListener/FlashListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,14 @@ final class FlashListener implements EventSubscriberInterface
/**
* @var string[]
*/
private static $successMessages = [
private static array $successMessages = [
NucleosProfileEvents::PROFILE_EDIT_COMPLETED => 'profile.flash.updated',
NucleosProfileEvents::REGISTRATION_COMPLETED => 'registration.flash.user_created',
];

/**
* @var FlashBagInterface
*/
private $flashBag;
private FlashBagInterface $flashBag;

/**
* @var TranslatorInterface
*/
private $translator;
private TranslatorInterface $translator;

public function __construct(FlashBagInterface $flashBag, TranslatorInterface $translator)
{
Expand Down
10 changes: 2 additions & 8 deletions src/Form/Model/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,9 @@

class Profile
{
/**
* @var string|null
*/
protected $locale;
protected ?string $locale = null;

/**
* @var string|null
*/
protected $timezone;
protected ?string $timezone = null;

public static function fromUser(UserInterface $user): self
{
Expand Down
15 changes: 3 additions & 12 deletions src/Form/Model/Registration.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,11 @@

class Registration
{
/**
* @var string|null
*/
protected $username;
protected ?string $username = null;

/**
* @var string|null
*/
protected $email;
protected ?string $email = null;

/**
* @var string|null
*/
protected $plainPassword;
protected ?string $plainPassword = null;

public function getUsername(): ?string
{
Expand Down
Loading