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 fcda646

Browse filesBrowse files
committed
Deprecate passing false as $label to ChoiceListFactoryInterface
1 parent 8ef8363 commit fcda646
Copy full SHA for fcda646

File tree

Expand file treeCollapse file tree

6 files changed

+25
-1
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+25
-1
lines changed

‎UPGRADE-5.0.md

Copy file name to clipboardExpand all lines: UPGRADE-5.0.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ Form
215215

216216
* The `regions` option was removed from the `TimezoneType`.
217217
* Added support for PHPUnit 8. A `void` return-type was added to the `FormIntegrationTestCase::setUp()`, `TypeTestCase::setUp()` and `TypeTestCase::tearDown()` methods.
218+
* Passing `false` as `$label` to `ChoiceListFactoryInterface::createView` now throws a `TypeError`, pass a callable that returns false instead.
218219

219220
FrameworkBundle
220221
---------------

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ CHANGELOG
1010
* deprecated using `int` or `float` as data for the `NumberType` when the `input` option is set to `string`
1111
* The type guesser guesses the HTML accept attribute when a mime type is configured in the File or Image constraint.
1212
* Overriding the methods `FormIntegrationTestCase::setUp()`, `TypeTestCase::setUp()` and `TypeTestCase::tearDown()` without the `void` return-type is deprecated.
13+
* deprecated passing `false` as `$label` to `ChoiceListFactoryInterface::createView`, pass a callable that returns false instead
1314

1415
4.3.0
1516
-----

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/ChoiceList/Factory/CachingFactoryDecorator.php
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ public function createListFromLoader(ChoiceLoaderInterface $loader, $value = nul
118118
*/
119119
public function createView(ChoiceListInterface $list, $preferredChoices = null, $label = null, $index = null, $groupBy = null, $attr = null)
120120
{
121+
if (false === $label) {
122+
@trigger_error(sprintf('Passing false as $label to %s is deprecated in Symfony 4.4 and will trigger a TypeError in 5.0, pass a callable that returns false instead.', __METHOD__), E_USER_DEPRECATED);
123+
124+
$label = static function () { return false; };
125+
}
126+
121127
// The input is not validated on purpose. This way, the decorated
122128
// factory may decide which input to accept and which not.
123129
$hash = self::generateHash([$list, $preferredChoices, $label, $index, $groupBy, $attr]);

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ public function createListFromLoader(ChoiceLoaderInterface $loader, $value = nul
4747
*/
4848
public function createView(ChoiceListInterface $list, $preferredChoices = null, $label = null, $index = null, $groupBy = null, $attr = null)
4949
{
50+
if (false === $label) {
51+
@trigger_error(sprintf('Passing false as $label to %s is deprecated in Symfony 4.4 and will trigger a TypeError in 5.0, pass a callable that returns false instead.', __METHOD__), E_USER_DEPRECATED);
52+
53+
$label = static function () { return false; };
54+
}
55+
5056
$preferredViews = [];
5157
$preferredViewsOrder = [];
5258
$otherViews = [];

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/ChoiceList/Factory/PropertyAccessDecorator.php
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ public function createListFromLoader(ChoiceLoaderInterface $loader, $value = nul
130130
*/
131131
public function createView(ChoiceListInterface $list, $preferredChoices = null, $label = null, $index = null, $groupBy = null, $attr = null)
132132
{
133+
if (false === $label) {
134+
@trigger_error(sprintf('Passing false as $label to %s is deprecated in Symfony 4.4 and will trigger a TypeError in 5.0, pass a callable that returns false instead.', __METHOD__), E_USER_DEPRECATED);
135+
136+
$label = static function () { return false; };
137+
}
138+
133139
$accessor = $this->propertyAccessor;
134140

135141
if (\is_string($label)) {

‎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
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,10 +404,14 @@ private function createChoiceList(array $options)
404404

405405
private function createChoiceListView(ChoiceListInterface $choiceList, array $options)
406406
{
407+
if (false === $label = $options['choice_label']) {
408+
$label = static function () { return false; };
409+
}
410+
407411
return $this->choiceListFactory->createView(
408412
$choiceList,
409413
$options['preferred_choices'],
410-
$options['choice_label'],
414+
$label,
411415
$options['choice_name'],
412416
$options['group_by'],
413417
$options['choice_attr']

0 commit comments

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