Skip to content

Commit c8d5e0d

Browse files
authored
minor #1500 [make:registration] add missing property types
1 parent 0a43269 commit c8d5e0d

File tree

1 file changed

+28
-23
lines changed

1 file changed

+28
-23
lines changed

src/Maker/MakeRegistrationForm.php

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,18 @@
6868
*/
6969
final class MakeRegistrationForm extends AbstractMaker
7070
{
71-
private $userClass;
72-
private $usernameField;
73-
private $passwordField;
74-
private $willVerifyEmail = false;
75-
private $verifyEmailAnonymously = false;
76-
private $idGetter;
77-
private $emailGetter;
78-
private $fromEmailAddress;
79-
private $fromEmailName;
71+
private string $userClass;
72+
private string $usernameField;
73+
private string $passwordField;
74+
private bool $willVerifyEmail = false;
75+
private bool $verifyEmailAnonymously = false;
76+
private string $idGetter;
77+
private string $emailGetter;
78+
private string $fromEmailAddress;
79+
private string $fromEmailName;
8080
private ?Authenticator $autoLoginAuthenticator = null;
81-
private $redirectRouteName;
82-
private $addUniqueEntityConstraint;
81+
private string $redirectRouteName;
82+
private bool $addUniqueEntityConstraint = false;
8383

8484
public function __construct(
8585
private FileManager $fileManager,
@@ -99,7 +99,7 @@ public static function getCommandDescription(): string
9999
return 'Create a new registration form system';
100100
}
101101

102-
public function configureCommand(Command $command, InputConfiguration $inputConf): void
102+
public function configureCommand(Command $command, InputConfiguration $inputConfig): void
103103
{
104104
$command
105105
->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeRegistrationForm.txt'))
@@ -135,13 +135,12 @@ public function interact(InputInterface $input, ConsoleStyle $io, Command $comma
135135

136136
// see if it makes sense to add the UniqueEntity constraint
137137
$userClassDetails = new ClassDetails($this->userClass);
138-
$this->addUniqueEntityConstraint = false;
139138

140139
if (!$userClassDetails->hasAttribute(UniqueEntity::class)) {
141-
$this->addUniqueEntityConstraint = $io->confirm(sprintf('Do you want to add a <comment>#[UniqueEntity]</comment> validation attribute to your <comment>%s</comment> class to make sure duplicate accounts aren\'t created?', Str::getShortClassName($this->userClass)));
140+
$this->addUniqueEntityConstraint = (bool) $io->confirm(sprintf('Do you want to add a <comment>#[UniqueEntity]</comment> validation attribute to your <comment>%s</comment> class to make sure duplicate accounts aren\'t created?', Str::getShortClassName($this->userClass)));
142141
}
143142

144-
$this->willVerifyEmail = $io->confirm('Do you want to send an email to verify the user\'s email address after registration?', true);
143+
$this->willVerifyEmail = (bool) $io->confirm('Do you want to send an email to verify the user\'s email address after registration?');
145144

146145
if ($this->willVerifyEmail) {
147146
$this->checkComponentsExist($io);
@@ -151,7 +150,7 @@ public function interact(InputInterface $input, ConsoleStyle $io, Command $comma
151150
$emailText[] = 'having to log in. To allow multi device email verification, we can embed a user id in the verification link.';
152151
$io->text($emailText);
153152
$io->newLine();
154-
$this->verifyEmailAnonymously = $io->confirm('Would you like to include the user id in the verification link to allow anonymous email verification?', false);
153+
$this->verifyEmailAnonymously = (bool) $io->confirm('Would you like to include the user id in the verification link to allow anonymous email verification?', false);
155154

156155
$this->idGetter = $interactiveSecurityHelper->guessIdGetter($io, $this->userClass);
157156
$this->emailGetter = $interactiveSecurityHelper->guessEmailGetter($io, $this->userClass, 'email');
@@ -233,7 +232,18 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
233232
'Security\\'
234233
);
235234

235+
$verifyEmailVars = ['will_verify_email' => $this->willVerifyEmail];
236+
236237
if ($this->willVerifyEmail) {
238+
$verifyEmailVars = [
239+
'will_verify_email' => $this->willVerifyEmail,
240+
'email_verifier_class_details' => $verifyEmailServiceClassNameDetails,
241+
'verify_email_anonymously' => $this->verifyEmailAnonymously,
242+
'from_email' => $this->fromEmailAddress,
243+
'from_email_name' => addslashes($this->fromEmailName),
244+
'email_getter' => $this->emailGetter,
245+
];
246+
237247
$useStatements = new UseStatementGenerator([
238248
EntityManagerInterface::class,
239249
TemplatedEmail::class,
@@ -333,17 +343,12 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
333343
'form_class_name' => $formClassDetails->getShortName(),
334344
'user_class_name' => $userClassNameDetails->getShortName(),
335345
'password_field' => $this->passwordField,
336-
'will_verify_email' => $this->willVerifyEmail,
337-
'email_verifier_class_details' => $verifyEmailServiceClassNameDetails,
338-
'verify_email_anonymously' => $this->verifyEmailAnonymously,
339-
'from_email' => $this->fromEmailAddress,
340-
'from_email_name' => addslashes($this->fromEmailName),
341-
'email_getter' => $this->emailGetter,
342-
'redirect_route_name' => $this->redirectRouteName,
346+
'redirect_route_name' => $this->redirectRouteName ?? null,
343347
'translator_available' => $isTranslatorAvailable,
344348
],
345349
$userRepoVars,
346350
$autoLoginVars,
351+
$verifyEmailVars,
347352
)
348353
);
349354

0 commit comments

Comments
 (0)