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 089377f

Browse filesBrowse files
feature #22860 [Form] remove deprecated features (xabbuh)
This PR was merged into the 4.0-dev branch. Discussion ---------- [Form] remove deprecated features | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Commits ------- 928da1a [Form] remove deprecated features
2 parents d6bdd23 + 928da1a commit 089377f
Copy full SHA for 089377f

File tree

Expand file treeCollapse file tree

12 files changed

+35
-391
lines changed
Filter options
Expand file treeCollapse file tree

12 files changed

+35
-391
lines changed

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

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

4+
4.0.0
5+
-----
6+
7+
* using the `choices` option in `CountryType`, `CurrencyType`, `LanguageType`,
8+
`LocaleType`, and `TimezoneType` when the `choice_loader` option is not `null`
9+
is not supported anymore and the configured choices will be ignored
10+
* callable strings that are passed to the options of the `ChoiceType` are
11+
treated as property paths
12+
* the `choices_as_values` option of the `ChoiceType` has been removed
13+
* removed the support for caching loaded choice lists in `LazyChoiceList`,
14+
cache the choice list in the used `ChoiceLoaderInterface` implementation
15+
instead
16+
417
3.3.0
518
-----
619

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/ChoiceList/Factory/PropertyAccessDecorator.php
+7-21Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,8 @@ public function getDecoratedFactory()
8484
*/
8585
public function createListFromChoices($choices, $value = null)
8686
{
87-
if (is_string($value) && !is_callable($value)) {
87+
if (is_string($value)) {
8888
$value = new PropertyPath($value);
89-
} elseif (is_string($value) && is_callable($value)) {
90-
@trigger_error('Passing callable strings is deprecated since version 3.1 and PropertyAccessDecorator will treat them as property paths in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED);
9189
}
9290

9391
if ($value instanceof PropertyPath) {
@@ -117,10 +115,8 @@ public function createListFromChoices($choices, $value = null)
117115
*/
118116
public function createListFromLoader(ChoiceLoaderInterface $loader, $value = null)
119117
{
120-
if (is_string($value) && !is_callable($value)) {
118+
if (is_string($value)) {
121119
$value = new PropertyPath($value);
122-
} elseif (is_string($value) && is_callable($value)) {
123-
@trigger_error('Passing callable strings is deprecated since version 3.1 and PropertyAccessDecorator will treat them as property paths in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED);
124120
}
125121

126122
if ($value instanceof PropertyPath) {
@@ -155,10 +151,8 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null,
155151
{
156152
$accessor = $this->propertyAccessor;
157153

158-
if (is_string($label) && !is_callable($label)) {
154+
if (is_string($label)) {
159155
$label = new PropertyPath($label);
160-
} elseif (is_string($label) && is_callable($label)) {
161-
@trigger_error('Passing callable strings is deprecated since version 3.1 and PropertyAccessDecorator will treat them as property paths in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED);
162156
}
163157

164158
if ($label instanceof PropertyPath) {
@@ -167,10 +161,8 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null,
167161
};
168162
}
169163

170-
if (is_string($preferredChoices) && !is_callable($preferredChoices)) {
164+
if (is_string($preferredChoices)) {
171165
$preferredChoices = new PropertyPath($preferredChoices);
172-
} elseif (is_string($preferredChoices) && is_callable($preferredChoices)) {
173-
@trigger_error('Passing callable strings is deprecated since version 3.1 and PropertyAccessDecorator will treat them as property paths in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED);
174166
}
175167

176168
if ($preferredChoices instanceof PropertyPath) {
@@ -184,10 +176,8 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null,
184176
};
185177
}
186178

187-
if (is_string($index) && !is_callable($index)) {
179+
if (is_string($index)) {
188180
$index = new PropertyPath($index);
189-
} elseif (is_string($index) && is_callable($index)) {
190-
@trigger_error('Passing callable strings is deprecated since version 3.1 and PropertyAccessDecorator will treat them as property paths in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED);
191181
}
192182

193183
if ($index instanceof PropertyPath) {
@@ -196,10 +186,8 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null,
196186
};
197187
}
198188

199-
if (is_string($groupBy) && !is_callable($groupBy)) {
189+
if (is_string($groupBy)) {
200190
$groupBy = new PropertyPath($groupBy);
201-
} elseif (is_string($groupBy) && is_callable($groupBy)) {
202-
@trigger_error('Passing callable strings is deprecated since version 3.1 and PropertyAccessDecorator will treat them as property paths in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED);
203191
}
204192

205193
if ($groupBy instanceof PropertyPath) {
@@ -212,10 +200,8 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null,
212200
};
213201
}
214202

215-
if (is_string($attr) && !is_callable($attr)) {
203+
if (is_string($attr)) {
216204
$attr = new PropertyPath($attr);
217-
} elseif (is_string($attr) && is_callable($attr)) {
218-
@trigger_error('Passing callable strings is deprecated since version 3.1 and PropertyAccessDecorator will treat them as property paths in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED);
219205
}
220206

221207
if ($attr instanceof PropertyPath) {

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/ChoiceList/LazyChoiceList.php
+4-97Lines changed: 4 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,6 @@ class LazyChoiceList implements ChoiceListInterface
4343
*/
4444
private $value;
4545

46-
/**
47-
* @var ChoiceListInterface|null
48-
*
49-
* @deprecated Since 3.1, to be removed in 4.0. Cache the choice list in the {@link ChoiceLoaderInterface} instead.
50-
*/
51-
private $loadedList;
52-
53-
/**
54-
* @var bool
55-
*
56-
* @deprecated Flag used for BC layer since 3.1. To be removed in 4.0.
57-
*/
58-
private $loaded = false;
59-
6046
/**
6147
* Creates a lazily-loaded list using the given loader.
6248
*
@@ -79,108 +65,38 @@ public function __construct(ChoiceLoaderInterface $loader, callable $value = nul
7965
*/
8066
public function getChoices()
8167
{
82-
if ($this->loaded) {
83-
// We can safely invoke the {@link ChoiceLoaderInterface} assuming it has the list
84-
// in cache when the lazy list is already loaded
85-
if ($this->loadedList !== $this->loader->loadChoiceList($this->value)) {
86-
@trigger_error(sprintf('Caching the choice list in %s is deprecated since 3.1 and will not happen in 4.0. Cache the list in the %s instead.', __CLASS__, ChoiceLoaderInterface::class), E_USER_DEPRECATED);
87-
}
88-
89-
return $this->loadedList->getChoices();
90-
}
91-
92-
// BC
93-
$this->loadedList = $this->loader->loadChoiceList($this->value);
94-
$this->loaded = true;
95-
96-
return $this->loadedList->getChoices();
97-
// In 4.0 keep the following line only:
98-
// return $this->loader->loadChoiceList($this->value)->getChoices()
68+
return $this->loader->loadChoiceList($this->value)->getChoices();
9969
}
10070

10171
/**
10272
* {@inheritdoc}
10373
*/
10474
public function getValues()
10575
{
106-
if ($this->loaded) {
107-
// Check whether the loader has the same cache
108-
if ($this->loadedList !== $this->loader->loadChoiceList($this->value)) {
109-
@trigger_error(sprintf('Caching the choice list in %s is deprecated since 3.1 and will not happen in 4.0. Cache the list in the %s instead.', __CLASS__, ChoiceLoaderInterface::class), E_USER_DEPRECATED);
110-
}
111-
112-
return $this->loadedList->getValues();
113-
}
114-
115-
// BC
116-
$this->loadedList = $this->loader->loadChoiceList($this->value);
117-
$this->loaded = true;
118-
119-
return $this->loadedList->getValues();
120-
// In 4.0 keep the following line only:
121-
// return $this->loader->loadChoiceList($this->value)->getValues()
76+
return $this->loader->loadChoiceList($this->value)->getValues();
12277
}
12378

12479
/**
12580
* {@inheritdoc}
12681
*/
12782
public function getStructuredValues()
12883
{
129-
if ($this->loaded) {
130-
// Check whether the loader has the same cache
131-
if ($this->loadedList !== $this->loader->loadChoiceList($this->value)) {
132-
@trigger_error(sprintf('Caching the choice list in %s is deprecated since 3.1 and will not happen in 4.0. Cache the list in the %s instead.', __CLASS__, ChoiceLoaderInterface::class), E_USER_DEPRECATED);
133-
}
134-
135-
return $this->loadedList->getStructuredValues();
136-
}
137-
138-
// BC
139-
$this->loadedList = $this->loader->loadChoiceList($this->value);
140-
$this->loaded = true;
141-
142-
return $this->loadedList->getStructuredValues();
143-
// In 4.0 keep the following line only:
144-
// return $this->loader->loadChoiceList($this->value)->getStructuredValues();
84+
return $this->loader->loadChoiceList($this->value)->getStructuredValues();
14585
}
14686

14787
/**
14888
* {@inheritdoc}
14989
*/
15090
public function getOriginalKeys()
15191
{
152-
if ($this->loaded) {
153-
// Check whether the loader has the same cache
154-
if ($this->loadedList !== $this->loader->loadChoiceList($this->value)) {
155-
@trigger_error(sprintf('Caching the choice list in %s is deprecated since 3.1 and will not happen in 4.0. Cache the list in the %s instead.', __CLASS__, ChoiceLoaderInterface::class), E_USER_DEPRECATED);
156-
}
157-
158-
return $this->loadedList->getOriginalKeys();
159-
}
160-
161-
// BC
162-
$this->loadedList = $this->loader->loadChoiceList($this->value);
163-
$this->loaded = true;
164-
165-
return $this->loadedList->getOriginalKeys();
166-
// In 4.0 keep the following line only:
167-
// return $this->loader->loadChoiceList($this->value)->getOriginalKeys();
92+
return $this->loader->loadChoiceList($this->value)->getOriginalKeys();
16893
}
16994

17095
/**
17196
* {@inheritdoc}
17297
*/
17398
public function getChoicesForValues(array $values)
17499
{
175-
if ($this->loaded) {
176-
// Check whether the loader has the same cache
177-
if ($this->loadedList !== $this->loader->loadChoiceList($this->value)) {
178-
@trigger_error(sprintf('Caching the choice list in %s is deprecated since 3.1 and will not happen in 4.0. Cache the list in the %s instead.', __CLASS__, ChoiceLoaderInterface::class), E_USER_DEPRECATED);
179-
}
180-
181-
return $this->loadedList->getChoicesForValues($values);
182-
}
183-
184100
return $this->loader->loadChoicesForValues($values, $this->value);
185101
}
186102

@@ -189,15 +105,6 @@ public function getChoicesForValues(array $values)
189105
*/
190106
public function getValuesForChoices(array $choices)
191107
{
192-
if ($this->loaded) {
193-
// Check whether the loader has the same cache
194-
if ($this->loadedList !== $this->loader->loadChoiceList($this->value)) {
195-
@trigger_error(sprintf('Caching the choice list in %s is deprecated since 3.1 and will not happen in 4.0. Cache the list in the %s instead.', __CLASS__, ChoiceLoaderInterface::class), E_USER_DEPRECATED);
196-
}
197-
198-
return $this->loadedList->getValuesForChoices($choices);
199-
}
200-
201108
return $this->loader->loadValuesForChoices($choices, $this->value);
202109
}
203110
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php
-18Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -273,22 +273,6 @@ public function configureOptions(OptionsResolver $resolver)
273273
return $options['required'] ? null : '';
274274
};
275275

276-
$choicesAsValuesNormalizer = function (Options $options, $choicesAsValues) {
277-
// Not set by the user
278-
if (null === $choicesAsValues) {
279-
return true;
280-
}
281-
282-
// Set by the user
283-
if (true !== $choicesAsValues) {
284-
throw new \RuntimeException(sprintf('The "choices_as_values" option of the %s should not be used. Remove it and flip the contents of the "choices" option instead.', get_class($this)));
285-
}
286-
287-
@trigger_error('The "choices_as_values" option is deprecated since version 3.1 and will be removed in 4.0. You should not use it anymore.', E_USER_DEPRECATED);
288-
289-
return true;
290-
};
291-
292276
$placeholderNormalizer = function (Options $options, $placeholder) {
293277
if ($options['multiple']) {
294278
// never use an empty value for this case
@@ -324,7 +308,6 @@ public function configureOptions(OptionsResolver $resolver)
324308
'multiple' => false,
325309
'expanded' => false,
326310
'choices' => array(),
327-
'choices_as_values' => null, // deprecated since 3.1
328311
'choice_loader' => null,
329312
'choice_label' => null,
330313
'choice_name' => null,
@@ -345,7 +328,6 @@ public function configureOptions(OptionsResolver $resolver)
345328

346329
$resolver->setNormalizer('placeholder', $placeholderNormalizer);
347330
$resolver->setNormalizer('choice_translation_domain', $choiceTranslationDomainNormalizer);
348-
$resolver->setNormalizer('choices_as_values', $choicesAsValuesNormalizer);
349331

350332
$resolver->setAllowedTypes('choices', array('null', 'array', '\Traversable'));
351333
$resolver->setAllowedTypes('choice_translation_domain', array('null', 'bool', 'string'));

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Core/Type/CountryType.php
+1-10Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
1616
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
1717
use Symfony\Component\Intl\Intl;
18-
use Symfony\Component\OptionsResolver\Options;
1918
use Symfony\Component\OptionsResolver\OptionsResolver;
2019

2120
class CountryType extends AbstractType implements ChoiceLoaderInterface
@@ -37,15 +36,7 @@ class CountryType extends AbstractType implements ChoiceLoaderInterface
3736
public function configureOptions(OptionsResolver $resolver)
3837
{
3938
$resolver->setDefaults(array(
40-
'choice_loader' => function (Options $options) {
41-
if ($options['choices']) {
42-
@trigger_error(sprintf('Using the "choices" option in %s has been deprecated since version 3.3 and will be ignored in 4.0. Override the "choice_loader" option instead or set it to null.', __CLASS__), E_USER_DEPRECATED);
43-
44-
return null;
45-
}
46-
47-
return $this;
48-
},
39+
'choice_loader' => $this,
4940
'choice_translation_domain' => false,
5041
));
5142
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Core/Type/CurrencyType.php
+1-10Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
1616
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
1717
use Symfony\Component\Intl\Intl;
18-
use Symfony\Component\OptionsResolver\Options;
1918
use Symfony\Component\OptionsResolver\OptionsResolver;
2019

2120
class CurrencyType extends AbstractType implements ChoiceLoaderInterface
@@ -37,15 +36,7 @@ class CurrencyType extends AbstractType implements ChoiceLoaderInterface
3736
public function configureOptions(OptionsResolver $resolver)
3837
{
3938
$resolver->setDefaults(array(
40-
'choice_loader' => function (Options $options) {
41-
if ($options['choices']) {
42-
@trigger_error(sprintf('Using the "choices" option in %s has been deprecated since version 3.3 and will be ignored in 4.0. Override the "choice_loader" option instead or set it to null.', __CLASS__), E_USER_DEPRECATED);
43-
44-
return null;
45-
}
46-
47-
return $this;
48-
},
39+
'choice_loader' => $this,
4940
'choice_translation_domain' => false,
5041
));
5142
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Core/Type/LanguageType.php
+1-10Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
1616
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
1717
use Symfony\Component\Intl\Intl;
18-
use Symfony\Component\OptionsResolver\Options;
1918
use Symfony\Component\OptionsResolver\OptionsResolver;
2019

2120
class LanguageType extends AbstractType implements ChoiceLoaderInterface
@@ -37,15 +36,7 @@ class LanguageType extends AbstractType implements ChoiceLoaderInterface
3736
public function configureOptions(OptionsResolver $resolver)
3837
{
3938
$resolver->setDefaults(array(
40-
'choice_loader' => function (Options $options) {
41-
if ($options['choices']) {
42-
@trigger_error(sprintf('Using the "choices" option in %s has been deprecated since version 3.3 and will be ignored in 4.0. Override the "choice_loader" option instead or set it to null.', __CLASS__), E_USER_DEPRECATED);
43-
44-
return null;
45-
}
46-
47-
return $this;
48-
},
39+
'choice_loader' => $this,
4940
'choice_translation_domain' => false,
5041
));
5142
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Core/Type/LocaleType.php
+1-10Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
1616
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
1717
use Symfony\Component\Intl\Intl;
18-
use Symfony\Component\OptionsResolver\Options;
1918
use Symfony\Component\OptionsResolver\OptionsResolver;
2019

2120
class LocaleType extends AbstractType implements ChoiceLoaderInterface
@@ -37,15 +36,7 @@ class LocaleType extends AbstractType implements ChoiceLoaderInterface
3736
public function configureOptions(OptionsResolver $resolver)
3837
{
3938
$resolver->setDefaults(array(
40-
'choice_loader' => function (Options $options) {
41-
if ($options['choices']) {
42-
@trigger_error(sprintf('Using the "choices" option in %s has been deprecated since version 3.3 and will be ignored in 4.0. Override the "choice_loader" option instead or set it to null.', __CLASS__), E_USER_DEPRECATED);
43-
44-
return null;
45-
}
46-
47-
return $this;
48-
},
39+
'choice_loader' => $this,
4940
'choice_translation_domain' => false,
5041
));
5142
}

0 commit comments

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