Skip to content

Commit bd4abf2

Browse files
committed
fix(maker): generate validator constraints compatible with Symfony 8
1 parent eba3045 commit bd4abf2

File tree

6 files changed

+34
-31
lines changed

6 files changed

+34
-31
lines changed

src/Maker/MakeRegistrationForm.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -559,9 +559,9 @@ 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(
563+
message: 'You should agree to our terms.',
564+
),
565565
],
566566
EOF
567567
],
@@ -573,15 +573,15 @@ private function generateFormClass(ClassNameDetails $userClassDetails, Generator
573573
'mapped' => false,
574574
'attr' => ['autocomplete' => 'new-password'],
575575
'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',
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',
582582
// max length allowed by Symfony for security reasons
583-
'max' => 4096,
584-
]),
583+
max: 4096,
584+
),
585585
],
586586
EOF
587587
],

src/Test/MakerTestEnvironment.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public function prepareDirectory(): void
163163
$dependencies = $this->determineMissingDependencies();
164164
if ($dependencies) {
165165
// -v actually silences the "very" verbose output in case of an error
166-
$composerProcess = MakerTestProcess::create(\sprintf('composer require %s -v', implode(' ', $dependencies)), $this->path)
166+
$composerProcess = MakerTestProcess::create(\sprintf('composer require %s -v -W', implode(' ', $dependencies)), $this->path)
167167
->run(true)
168168
;
169169

templates/resetPassword/ChangePasswordFormType.tpl.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ 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(
22+
message: 'Please enter a password',
23+
),
24+
new Length(
25+
min: 12,
26+
minMessage: 'Your password should be at least {{ limit }} characters',
2727
// max length allowed by Symfony for security reasons
28-
'max' => 4096,
29-
]),
28+
max: 4096,
29+
),
3030
new PasswordStrength(),
3131
new NotCompromisedPassword(),
3232
],

templates/resetPassword/ResetPasswordRequestFormType.tpl.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ 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(
16+
message: 'Please enter your email',
17+
),
1818
],
1919
])
2020
;

tests/Doctrine/EntityRegeneratorTest.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,12 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load
175175
],
176176
];
177177

178-
if (null !== $doctrineBundleVersion = InstalledVersions::getVersion('doctrine/doctrine-bundle')) {
179-
if (version_compare($doctrineBundleVersion, '2.8.0', '>=')) {
180-
$orm['enable_lazy_ghost_objects'] = true;
181-
}
182-
if (\PHP_VERSION_ID >= 80400 && version_compare($doctrineBundleVersion, '2.15.0', '>=')) {
183-
$orm['enable_native_lazy_objects'] = true;
184-
}
178+
if (
179+
\PHP_VERSION_ID >= 80400
180+
&& null !== $doctrineBundleVersion = InstalledVersions::getVersion('doctrine/doctrine-bundle')
181+
&& version_compare($doctrineBundleVersion, '2.15.0', '>=')
182+
) {
183+
$orm['enable_native_lazy_objects'] = true;
185184
}
186185

187186
$c->prependExtensionConfig('doctrine', [

tests/Util/TemplateLinterTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,14 @@ public function testPhpCsFixerVersion(): void
4444

4545
$fixerPath = \sprintf('%s/src/Resources/bin/php-cs-fixer-v%s.phar', \dirname(__DIR__, 2), TemplateLinter::BUNDLED_PHP_CS_FIXER_VERSION);
4646

47-
$process = Process::fromShellCommandline(\sprintf('%s -V', $fixerPath));
47+
$process = new Process([\PHP_BINARY, $fixerPath, '-V']);
4848

4949
$process->run();
5050

51+
if (!$process->isSuccessful() || '' === trim($process->getOutput())) {
52+
$this->markTestSkipped('php-cs-fixer binary could not be executed in this environment.');
53+
}
54+
5155
self::assertStringContainsString(TemplateLinter::BUNDLED_PHP_CS_FIXER_VERSION, $process->getOutput());
5256
}
5357

0 commit comments

Comments
 (0)