8000 merged branch bschussek/issue5113 (PR #7940) · symfony/symfony@b37409d · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit b37409d

Browse files
committed
merged branch bschussek/issue5113 (PR #7940)
This PR was merged into the master branch. Discussion ---------- [Form] Fixed expanded choice field to be marked invalid when unknown choices are submitted #7939 must be merged before this PR is merged. | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #5113, #5190 | License | MIT | Doc PR | - TODO: - [x] test EntityChoiceList for stricter rules - [ ] test ModelChoiceList for stricter rules - [x] remove/deprecate the ChoiceList::getIndicesFor*() methods Commits ------- 9efdb8e [Form] Deprecated ChoiceList::getIndicesFor*() methods 67ba131 [DoctrineBridge] Improved test coverage of EntityChoiceList 31e5ce5 [Form] Improved test coverage of ChoiceList classes 6283b0e [Form] Fixed expanded choice field to be marked invalid when unknown choices are submitted 79a214f [Form] Fixed ChoiceList::get*By*() methods to preserve order and array keys 62fbed6 [Form] Removed usage of the ChoiceList::getIndicesFor*() methods where they don't offer any performance benefit
2 parents 95483e5 + 9efdb8e commit b37409d

File tree

7 files changed

+40
-14
lines changed

7 files changed

+40
-14
lines changed

UPGRADE-3.0.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ UPGRADE FROM 2.x to 3.0
133133
```
134134

135135
* The `TypeTestCase` class was moved from the `Symfony\Component\Form\Tests\Extension\Core\Type` namespace to the `Symfony\Component\Form\Test` namespace.
136-
136+
137137
Before:
138138

139139
```
@@ -162,6 +162,12 @@ UPGRADE FROM 2.x to 3.0
162162
`NumberToLocalizedStringTransformer` were renamed to `ROUND_HALF_EVEN`,
163163
`ROUND_HALF_UP` and `ROUND_HALF_DOWN`.
164164

165+
* The methods `ChoiceListInterface::getIndicesForChoices()` and
166+
`ChoiceListInterface::getIndicesForValues()` were removed. No direct
167+
replacement exists, although in most cases
168+
`ChoiceListInterface::getChoicesForValues()` and
169+
`ChoiceListInterface::getValuesForChoices()` should be sufficient.
170+
165171

166172
### FrameworkBundle
167173

@@ -249,7 +255,7 @@ UPGRADE FROM 2.x to 3.0
249255
* The Locale component was removed and replaced by the Intl component.
250256
Instead of the methods in `Symfony\Component\Locale\Locale`, you should use
251257
these equivalent methods in `Symfony\Component\Intl\Intl` now:
252-
258+
253259
* `Locale::getDisplayCountries()` -> `Intl::getRegionBundle()->getCountryNames()`
254260
* `Locale::getCountries()` -> `array_keys(Intl::getRegionBundle()->getCountryNames())`
255261
* `Locale::getDisplayLanguages()` -> `Intl::getLanguageBundle()->getLanguageNames()`

src/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ public function getValuesForChoices(array $entities)
279279
* @return array
280280
*
281281
* @see Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface
282+
*
283+
* @deprecated Deprecated since version 2.4, to be removed in 3.0.
282284
*/
283285
public function getIndicesForChoices(array $entities)
284286
{
@@ -314,6 +316,8 @@ public function getIndicesForChoices(array $entities)
314316
* @return array
315317
*
316318
* @see Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface
319+
*
320+
* @deprecated Deprecated since version 2.4, to be removed in 3.0.
317321
*/
318322
public function getIndicesForValues(array $values)
319323
{

src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ public function getValuesForChoices(array $models)
252252
* @return array
253253
*
254254
* @see Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface
255+
*
256+
* @deprecated Deprecated since version 2.4, to be removed in 3.0.
255257
*/
256258
public function getIndicesForChoices(array $models)
257259
{
@@ -310,6 +312,8 @@ public function getIndicesForChoices(array $models)
310312
* @return array
311313
*
312314
* @see Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface
315+
*
316+
* @deprecated Deprecated since version 2.4, to be removed in 3.0.
313317
*/
314318
public function getIndicesForValues(array $values)
315319
{

src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceList.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ public function getValuesForChoices(array $choices)
198198

199199
/**
200200
* {@inheritdoc}
201+
*
202+
* @deprecated Deprecated since version 2.4, to be removed in 3.0.
201203
*/
202204
public function getIndicesForChoices(array $choices)
203205
{
@@ -222,6 +224,8 @@ public function getIndicesForChoices(array $choices)
222224

223225
/**
224226
* {@inheritdoc}
227+
*
228+
* @deprecated Deprecated since version 2.4, to be removed in 3.0.
225229
*/
226230
public function getIndicesForValues(array $values)
227231
{
@@ -485,24 +489,24 @@ protected function fixIndices(array $indices)
485489
* Extension point. In this implementation, choices are guaranteed to
486490
* always maintain their type and thus can be typesafely compared.
487491
*
488-
* @param mixed $choice The choice.
492+
* @param mixed $choice The choice
489493
*
490-
* @return mixed The fixed choice.
494+
* @return mixed The fixed choice
491495
*/
492496
protected function fixChoice($choice)
493497
{
494498
return $choice;
495499
}
496500

497501
/**
498-
* Fixes the data type of the given choices to avoid comparison problems.
499-
*
500-
* @param array $choices The choices.
501-
*
502-
* @return array The fixed choices.
503-
*
504-
* @see fixChoice
505-
*/
502+
* Fixes the data type of the given choices to avoid comparison problems.
503+
*
504+
* @param array $choices The choices.
505+
*
506+
* @return array The fixed choices.
507+
*
508+
* @see fixChoice
509+
*/
506510
protected function fixChoices(array $choices)
507511
{
508512
return $choices;

src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceListInterface.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ public function getValuesForChoices(array $choices);
138138
* array are ignored
139139
*
140140
* @return array An array of indices with ascending, 0-based numeric keys
141+
*
142+
* @deprecated Deprecated since version 2.4, to be removed in 3.0.
141143
*/
142144
public function getIndicesForChoices(array $choices);
143145

@@ -156,6 +158,8 @@ public function getIndicesForChoices(array $choices);
156158
* this array are ignored
157159
*
158160
* @return array An array of indices with ascending, 0-based numeric keys
161+
*
162+
* @deprecated Deprecated since version 2.4, to be removed in 3.0.
159163
*/
160164
public function getIndicesForValues(array $values);
161165
}

src/Symfony/Component/Form/Extension/Core/ChoiceList/LazyChoiceList.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ public function getValuesForChoices(array $choices)
105105

106106
/**
107107
* {@inheritdoc}
108+
*
109+
* @deprecated Deprecated since version 2.4, to be removed in 3.0.
108110
*/
109111
public function getIndicesForChoices(array $choices)
110112
{
@@ -117,6 +119,8 @@ public function getIndicesForChoices(array $choices)
117119

118120
/**
119121
* {@inheritdoc}
122+
*
123+
* @deprecated Deprecated since version 2.4, to be removed in 3.0.
120124
*/
121125
public function getIndicesForValues(array $values)
122126
{

src/Symfony/Component/Form/Extension/Core/ChoiceList/SimpleChoiceList.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,9 @@ protected function isPreferred($choice, array $preferredChoices)
135135
/**
136136
* Converts the choice to a valid PHP array key.
137137
*
138-
* @param mixed $choice The choice.
138+
* @param mixed $choice The choice
139139
*
140-
* @return string|integer A valid PHP array key.
140+
* @return string|integer A valid PHP array key
141141
*/
142142
protected function fixChoice($choice)
143143
{

0 commit comments

Comments
 (0)
0