Skip to content

Commit 43f04bb

Browse files
committed
Change FormTypeValidatorExtension construct signature
1 parent 6d5ac90 commit 43f04bb

File tree

5 files changed

+26
-4
lines changed

5 files changed

+26
-4
lines changed

UPGRADE-6.3.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ DependencyInjection
77
* Deprecate `PhpDumper` options `inline_factories_parameter` and `inline_class_loader_parameter`, use `inline_factories` and `inline_class_loader` instead
88
* Deprecate undefined and numeric keys with `service_locator` config, use string aliases instead
99

10+
Form
11+
----
12+
13+
* Change the signature of `FormTypeValidatorExtension::__construct(ValidatorInterface $validator, bool $legacyErrorMessages = true, FormRendererInterface $formRenderer = null, TranslatorInterface $translator = null)` to `__construct(ValidatorInterface $validator, FormRendererInterface $formRenderer = null, TranslatorInterface $translator = null)`
14+
1015
FrameworkBundle
1116
---------------
1217

src/Symfony/Bundle/FrameworkBundle/Resources/config/form.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@
132132
->set('form.type_extension.form.validator', FormTypeValidatorExtension::class)
133133
->args([
134134
service('validator'),
135-
false,
136135
service('twig.form.renderer')->ignoreOnInvalid(),
137136
service('translator')->ignoreOnInvalid(),
138137
])

src/Symfony/Component/Form/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
6.3
5+
---
6+
7+
* Change the signature of `FormTypeValidatorExtension::__construct(ValidatorInterface $validator, bool $legacyErrorMessages = true, FormRendererInterface $formRenderer = null, TranslatorInterface $translator = null)` to `__construct(ValidatorInterface $validator, FormRendererInterface $formRenderer = null, TranslatorInterface $translator = null)`
8+
49
6.2
510
---
611

src/Symfony/Component/Form/Extension/Validator/Type/FormTypeValidatorExtension.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,23 @@ class FormTypeValidatorExtension extends BaseValidatorExtension
2929
{
3030
private ValidatorInterface $validator;
3131
private ViolationMapper $violationMapper;
32-
private bool $legacyErrorMessages;
3332

34-
public function __construct(ValidatorInterface $validator, bool $legacyErrorMessages = true, FormRendererInterface $formRenderer = null, TranslatorInterface $translator = null)
33+
/**
34+
* @param ValidatorInterface $validator
35+
* @param FormRendererInterface|null $formRenderer
36+
* @param TranslatorInterface|null $translator
37+
*/
38+
public function __construct(ValidatorInterface $validator/* , FormRendererInterface $formRenderer = null, TranslatorInterface $translator = null*/)
3539
{
40+
if (\func_num_args() > 3) {
41+
trigger_deprecation('symfony/form', '6.3', 'The signature of constructor requires 3 arguments: "ValidatorInterface $validator, FormRendererInterface $formRenderer = null, TranslatorInterface $translator = null". Passing argument $legacyErrorMessages is deprecated.', __METHOD__);
42+
$formRenderer = func_get_arg(2);
43+
$translator = func_get_arg(3);
44+
} else {
45+
$formRenderer = func_get_arg(1);
46+
$translator = func_get_arg(2);
47+
}
48+
3649
$this->validator = $validator;
3750
$this->violationMapper = new ViolationMapper($formRenderer, $translator);
3851
}

src/Symfony/Component/Form/Extension/Validator/ValidatorExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function loadTypeGuesser(): ?FormTypeGuesserInterface
6060
protected function loadTypeExtensions(): array
6161
{
6262
return [
63-
new Type\FormTypeValidatorExtension($this->validator, $this->legacyErrorMessages, $this->formRenderer, $this->translator),
63+
new Type\FormTypeValidatorExtension($this->validator, $this->formRenderer, $this->translator),
6464
new Type\RepeatedTypeValidatorExtension(),
6565
new Type\SubmitTypeValidatorExtension(),
6666
];

0 commit comments

Comments
 (0)