Skip to content

Commit 5165e95

Browse files
committed
Refactor constraints to use named arguments
1 parent c86da84 commit 5165e95

File tree

3 files changed

+14
-22
lines changed

3 files changed

+14
-22
lines changed

src/Maker/MakeRegistrationForm.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -559,9 +559,7 @@ private function generateFormClass(ClassNameDetails $userClassDetails, Generator
559559
'options_code' => <<<EOF
560560
'mapped' => false,
561561
'constraints' => [
562-
new IsTrue([
563-
'message' => 'You should agree to our terms.',
564-
]),
562+
new IsTrue(message: 'You should agree to our terms.'),
565563
],
566564
EOF
567565
],
@@ -573,15 +571,13 @@ private function generateFormClass(ClassNameDetails $userClassDetails, Generator
573571
'mapped' => false,
574572
'attr' => ['autocomplete' => 'new-password'],
575573
'constraints' => [
576-
new NotBlank([
577-
'message' => 'Please enter a password',
578-
]),
579-
new Length([
580-
'min' => 6,
581-
'minMessage' => 'Your password should be at least {{ limit }} characters',
574+
new NotBlank(message: 'Please enter a password'),
575+
new Length(
576+
min: 6,
577+
minMessage: 'Your password should be at least {{ limit }} characters',
582578
// max length allowed by Symfony for security reasons
583-
'max' => 4096,
584-
]),
579+
max: 4096
580+
),
585581
],
586582
EOF
587583
],

templates/resetPassword/ChangePasswordFormType.tpl.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
1818
],
1919
'first_options' => [
2020
'constraints' => [
21-
new NotBlank([
22-
'message' => 'Please enter a password',
23-
]),
24-
new Length([
25-
'min' => 12,
26-
'minMessage' => 'Your password should be at least {{ limit }} characters',
21+
new NotBlank(message: 'Please enter a password'),
22+
new Length(
23+
min: 12,
24+
minMessage: 'Your password should be at least {{ limit }} characters',
2725
// max length allowed by Symfony for security reasons
28-
'max' => 4096,
29-
]),
26+
max: 4096
27+
),
3028
new PasswordStrength(),
3129
new NotCompromisedPassword(),
3230
],

templates/resetPassword/ResetPasswordRequestFormType.tpl.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
1212
->add('<?= $email_field ?>', EmailType::class, [
1313
'attr' => ['autocomplete' => 'email'],
1414
'constraints' => [
15-
new NotBlank([
16-
'message' => 'Please enter your email',
17-
]),
15+
new NotBlank(message: 'Please enter your email'),
1816
],
1917
])
2018
;

0 commit comments

Comments
 (0)