Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d1be34d

Browse filesBrowse files
feature #41318 [Form] Remove deprecated code (yceruto)
This PR was squashed before being merged into the 6.0 branch. Discussion ---------- [Form] Remove deprecated code | Q | A | ------------- | --- | Branch? | 6.0 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Commits ------- f6ed480 [Form] Remove deprecated code
2 parents 0e27af3 + f6ed480 commit d1be34d
Copy full SHA for d1be34d

File tree

15 files changed

+48
-610
lines changed
Filter options

15 files changed

+48
-610
lines changed

‎src/Symfony/Component/Form/ButtonBuilder.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/ButtonBuilder.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ public function getFormConfig()
471471
*
472472
* @throws BadMethodCallException
473473
*/
474-
public function setIsEmptyCallback(?callable $isEmptyCallback)
474+
public function setIsEmptyCallback(?callable $isEmptyCallback): static
475475
{
476476
throw new BadMethodCallException('Buttons do not support "is empty" callback.');
477477
}

‎src/Symfony/Component/Form/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/CHANGELOG.md
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
CHANGELOG
22
=========
33

4+
6.0
5+
---
6+
7+
* Remove `PropertyPathMaper`
8+
* Remove `Symfony\Component\Form\Extension\Validator\Util\ServiceParams`
9+
* Remove `FormPass` configuration
10+
* Add `FormConfigInterface::getIsEmptyCallback()` and `FormConfigBuilderInterface::setIsEmptyCallback()`
11+
* Change `$forms` parameter type of the `DataMapper::mapDataToForms()` method from `iterable` to `\Traversable`
12+
* Change `$forms` parameter type of the `DataMapper::mapFormsToData()` method from `iterable` to `\Traversable`
13+
* Change `$checkboxes` parameter type of the `CheckboxListMapper::mapDataToForms()` method from `iterable` to `\Traversable`
14+
* Change `$checkboxes` parameter type of the `CheckboxListMapper::mapFormsToData()` method from `iterable` to `\Traversable`
15+
* Change `$radios` parameter type of the `RadioListMapper::mapDataToForms()` method from `iterable` to `\Traversable`
16+
* Change `$radios` parameter type of the `RadioListMapper::mapFormsToData()` method from `iterable` to `\Traversable`
17+
418
5.3
519
---
620

‎src/Symfony/Component/Form/DependencyInjection/FormPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/DependencyInjection/FormPass.php
+12-31Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -30,32 +30,13 @@ class FormPass implements CompilerPassInterface
3030
{
3131
use PriorityTaggedServiceTrait;
3232

33-
private $formExtensionService;
34-
private $formTypeTag;
35-
private $formTypeExtensionTag;
36-
private $formTypeGuesserTag;
37-
private $formDebugCommandService;
38-
39-
public function __construct(string $formExtensionService = 'form.extension', string $formTypeTag = 'form.type', string $formTypeExtensionTag = 'form.type_extension', string $formTypeGuesserTag = 'form.type_guesser', string $formDebugCommandService = 'console.command.form_debug')
40-
{
41-
if (0 < \func_num_args()) {
42-
trigger_deprecation('symfony/http-kernel', '5.3', 'Configuring "%s" is deprecated.', __CLASS__);
43-
}
44-
45-
$this->formExtensionService = $formExtensionService;
46-
$this->formTypeTag = $formTypeTag;
47-
$this->formTypeExtensionTag = $formTypeExtensionTag;
48-
$this->formTypeGuesserTag = $formTypeGuesserTag;
49-
$this->formDebugCommandService = $formDebugCommandService;
50-
}
51-
5233
public function process(ContainerBuilder $container)
5334
{
54-
if (!$container->hasDefinition($this->formExtensionService)) {
35+
if (!$container->hasDefinition('form.extension')) {
5536
return;
5637
}
5738

58-
$definition = $container->getDefinition($this->formExtensionService);
39+
$definition = $container->getDefinition('form.extension');
5940
$definition->replaceArgument(0, $this->processFormTypes($container));
6041
$definition->replaceArgument(1, $this->processFormTypeExtensions($container));
6142
$definition->replaceArgument(2, $this->processFormTypeGuessers($container));
@@ -68,15 +49,15 @@ private function processFormTypes(ContainerBuilder $container): Reference
6849
$namespaces = ['Symfony\Component\Form\Extension\Core\Type' => true];
6950

7051
// Builds an array with fully-qualified type class names as keys and service IDs as values
71-
foreach ($container->findTaggedServiceIds($this->formTypeTag, true) as $serviceId => $tag) {
52+
foreach ($container->findTaggedServiceIds('form.type', true) as $serviceId => $tag) {
7253
// Add form type service to the service locator
7354
$serviceDefinition = $container->getDefinition($serviceId);
7455
$servicesMap[$formType = $serviceDefinition->getClass()] = new Reference($serviceId);
7556
$namespaces[substr($formType, 0, strrpos($formType, '\\'))] = true;
7657
}
7758

78-
if ($container->hasDefinition($this->formDebugCommandService)) {
79-
$commandDefinition = $container->getDefinition($this->formDebugCommandService);
59+
if ($container->hasDefinition('console.command.form_debug')) {
60+
$commandDefinition = $container->getDefinition('console.command.form_debug');
8061
$commandDefinition->setArgument(1, array_keys($namespaces));
8162
$commandDefinition->setArgument(2, array_keys($servicesMap));
8263
}
@@ -88,11 +69,11 @@ private function processFormTypeExtensions(ContainerBuilder $container): array
8869
{
8970
$typeExtensions = [];
9071
$typeExtensionsClasses = [];
91-
foreach ($this->findAndSortTaggedServices($this->formTypeExtensionTag, $container) as $reference) {
72+
foreach ($this->findAndSortTaggedServices('form.type_extension', $container) as $reference) {
9273
$serviceId = (string) $reference;
9374
$serviceDefinition = $container->getDefinition($serviceId);
9475

95-
$tag = $serviceDefinition->getTag($this->formTypeExtensionTag);
76+
$tag = $serviceDefinition->getTag('form.type_extension');
9677
$typeExtensionClass = $container->getParameterBag()->resolveValue($serviceDefinition->getClass());
9778

9879
if (isset($tag[0]['extended_type'])) {
@@ -117,8 +98,8 @@ private function processFormTypeExtensions(ContainerBuilder $container): array
11798
$typeExtensions[$extendedType] = new IteratorArgument($extensions);
11899
}
119100

120-
if ($container->hasDefinition($this->formDebugCommandService)) {
121-
$commandDefinition = $container->getDefinition($this->formDebugCommandService);
101+
if ($container->hasDefinition('console.command.form_debug')) {
102+
$commandDefinition = $container->getDefinition('console.command.form_debug');
122103
$commandDefinition->setArgument(3, $typeExtensionsClasses);
123104
}
124105

@@ -129,15 +110,15 @@ private function processFormTypeGuessers(ContainerBuilder $container): ArgumentI
129110
{
130111
$guessers = [];
131112
$guessersClasses = [];
132-
foreach ($container->findTaggedServiceIds($this->formTypeGuesserTag, true) as $serviceId => $tags) {
113+
foreach ($container->findTaggedServiceIds('form.type_guesser', true) as $serviceId => $tags) {
133114
$guessers[] = new Reference($serviceId);
134115

135116
$serviceDefinition = $container->getDefinition($serviceId);
136117
$guessersClasses[] = $serviceDefinition->getClass();
137118
}
138119

139-
if ($container->hasDefinition($this->formDebugCommandService)) {
140-
$commandDefinition = $container->getDefinition($this->formDebugCommandService);
120+
if ($container->hasDefinition('console.command.form_debug')) {
121+
$commandDefinition = $container->getDefinition('console.command.form_debug');
141122
$commandDefinition->setArgument(4, $guessersClasses);
142123
}
143124

‎src/Symfony/Component/Form/Extension/Core/DataMapper/CheckboxListMapper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Core/DataMapper/CheckboxListMapper.php
+2-10Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,8 @@ class CheckboxListMapper implements DataMapperInterface
2828
/**
2929
* {@inheritdoc}
3030
*/
31-
public function mapDataToForms($choices, iterable $checkboxes)
31+
public function mapDataToForms($choices, \Traversable $checkboxes)
3232
{
33-
if (\is_array($checkboxes)) {
34-
trigger_deprecation('symfony/form', '5.3', 'Passing an array as the second argument of the "%s()" method is deprecated, pass "\Traversable" instead.', __METHOD__);
35-
}
36-
3733
if (null === $choices) {
3834
$choices = [];
3935
}
@@ -51,12 +47,8 @@ public function mapDataToForms($choices, iterable $checkboxes)
5147
/**
5248
* {@inheritdoc}
5349
*/
54-
public function mapFormsToData(iterable $checkboxes, &$choices)
50+
public function mapFormsToData(\Traversable $checkboxes, &$choices)
5551
{
56-
if (\is_array($checkboxes)) {
57-
trigger_deprecation('symfony/form', '5.3', 'Passing an array as the first argument of the "%s()" method is deprecated, pass "\Traversable" instead.', __METHOD__);
58-
}
59-
6052
if (!\is_array($choices)) {
6153
throw new UnexpectedTypeException($choices, 'array');
6254
}

‎src/Symfony/Component/Form/Extension/Core/DataMapper/DataMapper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Core/DataMapper/DataMapper.php
+2-10Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,8 @@ public function __construct(DataAccessorInterface $dataAccessor = null)
3838
/**
3939
* {@inheritdoc}
4040
*/
41-
public function mapDataToForms($data, iterable $forms): void
41+
public function mapDataToForms($data, \Traversable $forms): void
4242
{
43-
if (\is_array($forms)) {
44-
trigger_deprecation('symfony/form', '5.3', 'Passing an array as the second argument of the "%s()" method is deprecated, pass "\Traversable" instead.', __METHOD__);
45-
}
46-
4743
$empty = null === $data || [] === $data;
4844

4945
if (!$empty && !\is_array($data) && !\is_object($data)) {
@@ -64,12 +60,8 @@ public function mapDataToForms($data, iterable $forms): void
6460
/**
6561
* {@inheritdoc}
6662
*/
67-
public function mapFormsToData(iterable $forms, &$data): void
63+
public function mapFormsToData(\Traversable $forms, &$data): void
6864
{
69-
if (\is_array($forms)) {
70-
trigger_deprecation('symfony/form', '5.3', 'Passing an array as the first argument of the "%s()" method is deprecated, pass "\Traversable" instead.', __METHOD__);
71-
}
72-
7365
if (null === $data) {
7466
return;
7567
}

‎src/Symfony/Component/Form/Extension/Core/DataMapper/PropertyPathMapper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Core/DataMapper/PropertyPathMapper.php
-113Lines changed: 0 additions & 113 deletions
This file was deleted.

‎src/Symfony/Component/Form/Extension/Core/DataMapper/RadioListMapper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Core/DataMapper/RadioListMapper.php
+2-6Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class RadioListMapper implements DataMapperInterface
2828
/**
2929
* {@inheritdoc}
3030
*/
31-
public function mapDataToForms($choice, iterable $radios)
31+
public function mapDataToForms($choice, \Traversable $radios)
3232
{
3333
if (\is_array($radios)) {
3434
trigger_deprecation('symfony/form', '5.3', 'Passing an array as the second argument of the "%s()" method is deprecated, pass "\Traversable" instead.', __METHOD__);
@@ -47,12 +47,8 @@ public function mapDataToForms($choice, iterable $radios)
4747
/**
4848
* {@inheritdoc}
4949
*/
50-
public function mapFormsToData(iterable $radios, &$choice)
50+
public function mapFormsToData(\Traversable $radios, &$choice)
5151
{
52-
if (\is_array($radios)) {
53-
trigger_deprecation('symfony/form', '5.3', 'Passing an array as the first argument of the "%s()" method is deprecated, pass "\Traversable" instead.', __METHOD__);
54-
}
55-
5652
if (null !== $choice && !\is_string($choice)) {
5753
throw new UnexpectedTypeException($choice, 'null or string');
5854
}

‎src/Symfony/Component/Form/Extension/Core/Type/FormType.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Core/Type/FormType.php
-7Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
use Symfony\Component\Form\Extension\Core\DataMapper\DataMapper;
1919
use Symfony\Component\Form\Extension\Core\EventListener\TrimListener;
2020
use Symfony\Component\Form\FormBuilderInterface;
21-
use Symfony\Component\Form\FormConfigBuilderInterface;
2221
use Symfony\Component\Form\FormInterface;
2322
use Symfony\Component\Form\FormView;
2423
use Symfony\Component\OptionsResolver\Options;
@@ -66,12 +65,6 @@ public function buildForm(FormBuilderInterface $builder, array $options)
6665
$builder->addEventSubscriber(new TrimListener());
6766
}
6867

69-
if (!method_exists($builder, 'setIsEmptyCallback')) {
70-
trigger_deprecation('symfony/form', '5.1', 'Not implementing the "%s::setIsEmptyCallback()" method in "%s" is deprecated.', FormConfigBuilderInterface::class, get_debug_type($builder));
71-
72-
return;
73-
}
74-
7568
$builder->setIsEmptyCallback($options['is_empty_callback']);
7669
}
7770

‎src/Symfony/Component/Form/Extension/Validator/Util/ServerParams.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Validator/Util/ServerParams.php
-25Lines changed: 0 additions & 25 deletions
This file was deleted.

‎src/Symfony/Component/Form/Form.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Form.php
+1-9Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -724,15 +724,7 @@ public function isEmpty()
724724
}
725725
}
726726

727-
if (!method_exists($this->config, 'getIsEmptyCallback')) {
728-
trigger_deprecation('symfony/form', '5.1', 'Not implementing the "%s::getIsEmptyCallback()" method in "%s" is deprecated.', FormConfigInterface::class, \get_class($this->config));
729-
730-
$isEmptyCallback = null;
731-
} else {
732-
$isEmptyCallback = $this->config->getIsEmptyCallback();
733-
}
734-
735-
if (null !== $isEmptyCallback) {
727+
if (null !== $isEmptyCallback = $this->config->getIsEmptyCallback()) {
736728
return $isEmptyCallback($this->modelData);
737729
}
738730

‎src/Symfony/Component/Form/FormConfigBuilder.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/FormConfigBuilder.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ public function getFormConfig()
773773
/**
774774
* {@inheritdoc}
775775
*/
776-
public function setIsEmptyCallback(?callable $isEmptyCallback)
776+
public function setIsEmptyCallback(?callable $isEmptyCallback): static
777777
{
778778
$this->isEmptyCallback = $isEmptyCallback;
779779

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.