Skip to content

Commit b0bb650

Browse files
committed
remove remaining deprecation layers
1 parent 90b9ddf commit b0bb650

File tree

73 files changed

+55
-725
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+55
-725
lines changed

src/Symfony/Component/Form/ChoiceList/Factory/CachingFactoryDecorator.php

+3-8
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,8 @@ public function getDecoratedFactory()
8989
* @param callable|Cache\ChoiceFilter|null $filter The callable or static option for
9090
* filtering the choices
9191
*/
92-
public function createListFromChoices(iterable $choices, $value = null/*, $filter = null*/)
92+
public function createListFromChoices(iterable $choices, $value = null, $filter = null)
9393
{
94-
$filter = \func_num_args() > 2 ? func_get_arg(2) : null;
95-
9694
if ($choices instanceof \Traversable) {
9795
$choices = iterator_to_array($choices);
9896
}
@@ -134,10 +132,8 @@ public function createListFromChoices(iterable $choices, $value = null/*, $filte
134132
* @param callable|Cache\ChoiceFilter|null $filter The callable or static option for
135133
* filtering the choices
136134
*/
137-
public function createListFromLoader(ChoiceLoaderInterface $loader, $value = null/*, $filter = null*/)
135+
public function createListFromLoader(ChoiceLoaderInterface $loader, $value = null, $filter = null)
138136
{
139-
$filter = \func_num_args() > 2 ? func_get_arg(2) : null;
140-
141137
$cache = true;
142138

143139
if ($loader instanceof Cache\ChoiceLoader) {
@@ -181,9 +177,8 @@ public function createListFromLoader(ChoiceLoaderInterface $loader, $value = nul
181177
* @param array|callable|Cache\ChoiceAttr|null $attr The option or static option generating the HTML attributes
182178
* @param array|callable|Cache\ChoiceTranslationParameters $labelTranslationParameters The parameters used to translate the choice labels
183179
*/
184-
public function createView(ChoiceListInterface $list, $preferredChoices = null, $label = null, $index = null, $groupBy = null, $attr = null/*, $labelTranslationParameters = []*/)
180+
public function createView(ChoiceListInterface $list, $preferredChoices = null, $label = null, $index = null, $groupBy = null, $attr = null, $labelTranslationParameters = [])
185181
{
186-
$labelTranslationParameters = \func_num_args() > 6 ? func_get_arg(6) : [];
187182
$cache = true;
188183

189184
if ($preferredChoices instanceof Cache\PreferredChoice) {

src/Symfony/Component/Form/ChoiceList/Factory/ChoiceListFactoryInterface.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ interface ChoiceListFactoryInterface
3535
*
3636
* @return ChoiceListInterface The choice list
3737
*/
38-
public function createListFromChoices(iterable $choices, callable $value = null/*, callable $filter = null*/);
38+
public function createListFromChoices(iterable $choices, callable $value = null, callable $filter = null);
3939

4040
/**
4141
* Creates a choice list that is loaded with the given loader.
@@ -48,7 +48,7 @@ public function createListFromChoices(iterable $choices, callable $value = null/
4848
*
4949
* @return ChoiceListInterface The choice list
5050
*/
51-
public function createListFromLoader(ChoiceLoaderInterface $loader, callable $value = null/*, callable $filter = null*/);
51+
public function createListFromLoader(ChoiceLoaderInterface $loader, callable $value = null, callable $filter = null);
5252

5353
/**
5454
* Creates a view for the given choice list.
@@ -84,5 +84,5 @@ public function createListFromLoader(ChoiceLoaderInterface $loader, callable $va
8484
*
8585
* @return ChoiceListView The choice list view
8686
*/
87-
public function createView(ChoiceListInterface $list, $preferredChoices = null, $label = null, callable $index = null, callable $groupBy = null, $attr = null/*, $labelTranslationParameters = []*/);
87+
public function createView(ChoiceListInterface $list, $preferredChoices = null, $label = null, callable $index = null, callable $groupBy = null, $attr = null, $labelTranslationParameters = []);
8888
}

src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php

+3-12
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,9 @@ class DefaultChoiceListFactory implements ChoiceListFactoryInterface
3232
{
3333
/**
3434
* {@inheritdoc}
35-
*
36-
* @param callable|null $filter
3735
*/
38-
public function createListFromChoices(iterable $choices, callable $value = null/*, callable $filter = null*/)
36+
public function createListFromChoices(iterable $choices, callable $value = null, callable $filter = null)
3937
{
40-
$filter = \func_num_args() > 2 ? func_get_arg(2) : null;
41-
4238
if ($filter) {
4339
// filter the choice list lazily
4440
return $this->createListFromLoader(new FilterChoiceLoaderDecorator(
@@ -53,13 +49,9 @@ public function createListFromChoices(iterable $choices, callable $value = null/
5349

5450
/**
5551
* {@inheritdoc}
56-
*
57-
* @param callable|null $filter
5852
*/
59-
public function createListFromLoader(ChoiceLoaderInterface $loader, callable $value = null/*, callable $filter = null*/)
53+
public function createListFromLoader(ChoiceLoaderInterface $loader, callable $value = null, callable $filter = null)
6054
{
61-
$filter = \func_num_args() > 2 ? func_get_arg(2) : null;
62-
6355
if ($filter) {
6456
$loader = new FilterChoiceLoaderDecorator($loader, $filter);
6557
}
@@ -72,9 +64,8 @@ public function createListFromLoader(ChoiceLoaderInterface $loader, callable $va
7264
*
7365
* @param array|callable $labelTranslationParameters The parameters used to translate the choice labels
7466
*/
75-
public function createView(ChoiceListInterface $list, $preferredChoices = null, $label = null, callable $index = null, callable $groupBy = null, $attr = null/*, $labelTranslationParameters = []*/)
67+
public function createView(ChoiceListInterface $list, $preferredChoices = null, $label = null, callable $index = null, callable $groupBy = null, $attr = null, $labelTranslationParameters = [])
7668
{
77-
$labelTranslationParameters = \func_num_args() > 6 ? func_get_arg(6) : [];
7869
$preferredViews = [];
7970
$preferredViewsOrder = [];
8071
$otherViews = [];

src/Symfony/Component/Form/ChoiceList/Factory/PropertyAccessDecorator.php

+3-8
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,8 @@ public function getDecoratedFactory()
6666
*
6767
* @return ChoiceListInterface The choice list
6868
*/
69-
public function createListFromChoices(iterable $choices, $value = null/*, $filter = null*/)
69+
public function createListFromChoices(iterable $choices, $value = null, $filter = null)
7070
{
71-
$filter = \func_num_args() > 2 ? func_get_arg(2) : null;
72-
7371
if (\is_string($value)) {
7472
$value = new PropertyPath($value);
7573
}
@@ -109,10 +107,8 @@ public function createListFromChoices(iterable $choices, $value = null/*, $filte
109107
*
110108
* @return ChoiceListInterface The choice list
111109
*/
112-
public function createListFromLoader(ChoiceLoaderInterface $loader, $value = null/*, $filter = null*/)
110+
public function createListFromLoader(ChoiceLoaderInterface $loader, $value = null, $filter = null)
113111
{
114-
$filter = \func_num_args() > 2 ? func_get_arg(2) : null;
115-
116112
if (\is_string($value)) {
117113
$value = new PropertyPath($value);
118114
}
@@ -154,9 +150,8 @@ public function createListFromLoader(ChoiceLoaderInterface $loader, $value = nul
154150
*
155151
* @return ChoiceListView The choice list view
156152
*/
157-
public function createView(ChoiceListInterface $list, $preferredChoices = null, $label = null, $index = null, $groupBy = null, $attr = null/*, $labelTranslationParameters = []*/)
153+
public function createView(ChoiceListInterface $list, $preferredChoices = null, $label = null, $index = null, $groupBy = null, $attr = null, $labelTranslationParameters = [])
158154
{
159-
$labelTranslationParameters = \func_num_args() > 6 ? func_get_arg(6) : [];
160155
$accessor = $this->propertyAccessor;
161156

162157
if (\is_string($label)) {

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

-4
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ class RadioListMapper implements DataMapperInterface
3030
*/
3131
public function mapDataToForms($choice, \Traversable $radios)
3232
{
33-
if (\is_array($radios)) {
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 (!\is_string($choice)) {
3834
throw new UnexpectedTypeException($choice, 'string');
3935
}

src/Symfony/Component/Form/Extension/Core/DataTransformer/PercentToLocalizedStringTransformer.php

+5-9
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ class PercentToLocalizedStringTransformer implements DataTransformerInterface
3939
/**
4040
* @see self::$types for a list of supported types
4141
*
42-
* @param int $scale The scale
43-
* @param string $type One of the supported types
44-
* @param int|null $roundingMode A value from \NumberFormatter, such as \NumberFormatter::ROUND_HALFUP
45-
* @param bool $html5Format Use an HTML5 specific format, see https://www.w3.org/TR/html51/sec-forms.html#date-time-and-number-formats
42+
* @param int $scale The scale
43+
* @param string $type One of the supported types
44+
* @param int $roundingMode A value from \NumberFormatter, such as \NumberFormatter::ROUND_HALFUP
45+
* @param bool $html5Format Use an HTML5 specific format, see https://www.w3.org/TR/html51/sec-forms.html#date-time-and-number-formats
4646
*
4747
* @throws UnexpectedTypeException if the given value of type is unknown
4848
*/
49-
public function __construct(int $scale = null, string $type = null, ?int $roundingMode = null, bool $html5Format = false)
49+
public function __construct(int $scale = null, string $type = null, int $roundingMode = \NumberFormatter::ROUND_HALFUP, bool $html5Format = false)
5050
{
5151
if (null === $scale) {
5252
$scale = 0;
@@ -56,10 +56,6 @@ public function __construct(int $scale = null, string $type = null, ?int $roundi
5656
$type = self::FRACTIONAL;
5757
}
5858

59-
if (null === $roundingMode && (\func_num_args() < 4 || func_get_arg(3))) {
60-
trigger_deprecation('symfony/form', '5.1', 'Not passing a rounding mode to "%s()" is deprecated. Starting with Symfony 6.0 it will default to "\NumberFormatter::ROUND_HALFUP".', __METHOD__);
61-
}
62-
6359
if (!\in_array($type, self::$types, true)) {
6460
throw new UnexpectedTypeException($type, implode('", "', self::$types));
6561
}

src/Symfony/Component/Form/Extension/Core/Type/BirthdayType.php

+1-6
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\Form\Extension\Core\Type;
1313

1414
use Symfony\Component\Form\AbstractType;
15-
use Symfony\Component\OptionsResolver\Options;
1615
use Symfony\Component\OptionsResolver\OptionsResolver;
1716

1817
class BirthdayType extends AbstractType
@@ -24,11 +23,7 @@ public function configureOptions(OptionsResolver $resolver)
2423
{
2524
$resolver->setDefaults([
2625
'years' => range((int) date('Y') - 120, date('Y')),
27-
'invalid_message' => function (Options $options, $previousValue) {
28-
return ($options['legacy_error_messages'] ?? true)
29-
? $previousValue
30-
: 'Please enter a valid birthdate.';
31-
},
26+
'invalid_message' => 'Please enter a valid birthdate.',
3227
]);
3328

3429
$resolver->setAllowedTypes('years', 'array');

src/Symfony/Component/Form/Extension/Core/Type/CheckboxType.php

+1-6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use Symfony\Component\Form\FormBuilderInterface;
1717
use Symfony\Component\Form\FormInterface;
1818
use Symfony\Component\Form\FormView;
19-
use Symfony\Component\OptionsResolver\Options;
2019
use Symfony\Component\OptionsResolver\OptionsResolver;
2120

2221
class CheckboxType extends AbstractType
@@ -61,11 +60,7 @@ public function configureOptions(OptionsResolver $resolver)
6160
'empty_data' => $emptyData,
6261
'compound' => false,
6362
'false_values' => [null],
64-
'invalid_message' => function (Options $options, $previousValue) {
65-
return ($options['legacy_error_messages'] ?? true)
66-
? $previousValue
67-
: 'The checkbox has an invalid value.';
68-
},
63+
'invalid_message' => 'The checkbox has an invalid value.',
6964
'is_empty_callback' => static function ($modelData): bool {
7065
return false === $modelData;
7166
},

src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php

+2-24
Original file line numberDiff line numberDiff line change
@@ -52,31 +52,13 @@ class ChoiceType extends AbstractType
5252
private $choiceListFactory;
5353
private $translator;
5454

55-
/**
56-
* @param TranslatorInterface $translator
57-
*/
58-
public function __construct(ChoiceListFactoryInterface $choiceListFactory = null, $translator = null)
55+
public function __construct(ChoiceListFactoryInterface $choiceListFactory = null, TranslatorInterface $translator = null)
5956
{
6057
$this->choiceListFactory = $choiceListFactory ?? new CachingFactoryDecorator(
6158
new PropertyAccessDecorator(
6259
new DefaultChoiceListFactory()
6360
)
6461
);
65-
66-
// BC, to be removed in 6.0
67-
if ($this->choiceListFactory instanceof CachingFactoryDecorator) {
68-
return;
69-
}
70-
71-
$ref = new \ReflectionMethod($this->choiceListFactory, 'createListFromChoices');
72-
73-
if ($ref->getNumberOfParameters() < 3) {
74-
trigger_deprecation('symfony/form', '5.1', 'Not defining a third parameter "callable|null $filter" in "%s::%s()" is deprecated.', $ref->class, $ref->name);
75-
}
76-
77-
if (null !== $translator && !$translator instanceof TranslatorInterface) {
78-
throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be han instance of "%s", "%s" given.', __METHOD__, TranslatorInterface::class, \is_object($translator) ? \get_class($translator) : \gettype($translator)));
79-
}
8062
$this->translator = $translator;
8163
}
8264

@@ -390,11 +372,7 @@ public function configureOptions(OptionsResolver $resolver)
390372
'data_class' => null,
391373
'choice_translation_domain' => true,
392374
'trim' => false,
393-
'invalid_message' => function (Options $options, $previousValue) {
394-
return ($options['legacy_error_messages'] ?? true)
395-
? $previousValue
396-
: 'The selected choice is invalid.';
397-
},
375+
'invalid_message' => 'The selected choice is invalid.',
398376
]);
399377

400378
$resolver->setNormalizer('placeholder', $placeholderNormalizer);

src/Symfony/Component/Form/Extension/Core/Type/CollectionType.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,7 @@ public function configureOptions(OptionsResolver $resolver)
121121
'entry_type' => TextType::class,
122122
'entry_options' => [],
123123
'delete_empty' => false,
124-
'invalid_message' => function (Options $options, $previousValue) {
125-
return ($options['legacy_error_messages'] ?? true)
126-
? $previousValue
127-
: 'The collection is invalid.';
128-
},
124+
'invalid_message' => 'The collection is invalid.',
129125
]);
130126

131127
$resolver->setNormalizer('entry_options', $entryOptionsNormalizer);

src/Symfony/Component/Form/Extension/Core/Type/ColorType.php

+1-6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use Symfony\Component\Form\FormError;
1717
use Symfony\Component\Form\FormEvent;
1818
use Symfony\Component\Form\FormEvents;
19-
use Symfony\Component\OptionsResolver\Options;
2019
use Symfony\Component\OptionsResolver\OptionsResolver;
2120
use Symfony\Contracts\Translation\TranslatorInterface;
2221

@@ -70,11 +69,7 @@ public function configureOptions(OptionsResolver $resolver)
7069
{
7170
$resolver->setDefaults([
7271
'html5' => false,
73-
'invalid_message' => function (Options $options, $previousValue) {
74-
return ($options['legacy_error_messages'] ?? true)
75-
? $previousValue
76-
: 'Please select a valid color.';
77-
},
72+
'invalid_message' => 'Please select a valid color.',
7873
]);
7974

8075
$resolver->setAllowedTypes('html5', 'bool');

src/Symfony/Component/Form/Extension/Core/Type/CountryType.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,7 @@ public function configureOptions(OptionsResolver $resolver)
4343
'choice_translation_domain' => false,
4444
'choice_translation_locale' => null,
4545
'alpha3' => false,
46-
'invalid_message' => function (Options $options, $previousValue) {
47-
return ($options['legacy_error_messages'] ?? true)
48-
? $previousValue
49-
: 'Please select a valid country.';
50-
},
46+
'invalid_message' => 'Please select a valid country.',
5147
]);
5248

5349
$resolver->setAllowedTypes('choice_translation_locale', ['null', 'string']);

src/Symfony/Component/Form/Extension/Core/Type/CurrencyType.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,7 @@ public function configureOptions(OptionsResolver $resolver)
4141
},
4242
'choice_translation_domain' => false,
4343
'choice_translation_locale' => null,
44-
'invalid_message' => function (Options $options, $previousValue) {
45-
return ($options['legacy_error_messages'] ?? true)
46-
? $previousValue
47-
: 'Please select a valid currency.';
48-
},
44+
'invalid_message' => 'Please select a valid currency.',
4945
]);
5046

5147
$resolver->setAllowedTypes('choice_translation_locale', ['null', 'string']);

src/Symfony/Component/Form/Extension/Core/Type/DateIntervalType.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,7 @@ public function configureOptions(OptionsResolver $resolver)
234234
'compound' => $compound,
235235
'empty_data' => $emptyData,
236236
'labels' => [],
237-
'invalid_message' => function (Options $options, $previousValue) {
238-
return ($options['legacy_error_messages'] ?? true)
239-
? $previousValue
240-
: 'Please choose a valid date interval.';
241-
},
237+
'invalid_message' => 'Please choose a valid date interval.',
242238
]);
243239
$resolver->setNormalizer('placeholder', $placeholderNormalizer);
244240
$resolver->setNormalizer('labels', $labelsNormalizer);

src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,7 @@ public function configureOptions(OptionsResolver $resolver)
273273
return $options['compound'] ? [] : '';
274274
},
275275
'input_format' => 'Y-m-d H:i:s',
276-
'invalid_message' => function (Options $options, $previousValue) {
277-
return ($options['legacy_error_messages'] ?? true)
278-
? $previousValue
279-
: 'Please enter a valid date and time.';
280-
},
276+
'invalid_message' => 'Please enter a valid date and time.',
281277
]);
282278

283279
// Don't add some defaults in order to preserve the defaults

src/Symfony/Component/Form/Extension/Core/Type/DateType.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -299,11 +299,7 @@ public function configureOptions(OptionsResolver $resolver)
299299
},
300300
'choice_translation_domain' => false,
301301
'input_format' => 'Y-m-d',
302-
'invalid_message' => function (Options $options, $previousValue) {
303-
return ($options['legacy_error_messages'] ?? true)
304-
? $previousValue
305-
: 'Please enter a valid date.';
306-
},
302+
'invalid_message' => 'Please enter a valid date.',
307303
]);
308304

309305
$resolver->setNormalizer('placeholder', $placeholderNormalizer);

src/Symfony/Component/Form/Extension/Core/Type/EmailType.php

+1-6
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\Form\Extension\Core\Type;
1313

1414
use Symfony\Component\Form\AbstractType;
15-
use Symfony\Component\OptionsResolver\Options;
1615
use Symfony\Component\OptionsResolver\OptionsResolver;
1716

1817
class EmailType extends AbstractType
@@ -23,11 +22,7 @@ class EmailType extends AbstractType
2322
public function configureOptions(OptionsResolver $resolver)
2423
{
2524
$resolver->setDefaults([
26-
'invalid_message' => function (Options $options, $previousValue) {
27-
return ($options['legacy_error_messages'] ?? true)
28-
? $previousValue
29-
: 'Please enter a valid email address.';
30-
},
25+
'invalid_message' => 'Please enter a valid email address.',
3126
]);
3227
}
3328

src/Symfony/Component/Form/Extension/Core/Type/FileType.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,7 @@ public function configureOptions(OptionsResolver $resolver)
130130
'empty_data' => $emptyData,
131131
'multiple' => false,
132132
'allow_file_upload' => true,
133-
'invalid_message' => function (Options $options, $previousValue) {
134-
return ($options['legacy_error_messages'] ?? true)
135-
? $previousValue
136-
: 'Please select a valid file.';
137-
},
133+
'invalid_message' => 'Please select a valid file.',
138134
]);
139135
}
140136

0 commit comments

Comments
 (0)