8000 Add callable declarations to ChoiceListFactoryInterface · symfony/symfony@b33cd3a · GitHub
[go: up one dir, main page]

Skip to content

Commit b33cd3a

Browse files
committed
Add callable declarations to ChoiceListFactoryInterface
1 parent 00f161d commit b33cd3a

File tree

3 files changed

+9
-19
lines changed

3 files changed

+9
-19
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function getDecoratedFactory()
8181
/**
8282
* {@inheritdoc}
8383
*/
84-
public function createListFromChoices(iterable $choices, $value = null)
84+
public function createListFromChoices(iterable $choices, callable $value = null)
8585
{
8686
if ($choices instanceof \Traversable) {
8787
$choices = iterator_to_array($choices);
@@ -102,7 +102,7 @@ public function createListFromChoices(iterable $choices, $value = null)
102102
/**
103103
* {@inheritdoc}
104104
*/
105-
public function createListFromLoader(ChoiceLoaderInterface $loader, $value = null)
105+
public function createListFromLoader(ChoiceLoaderInterface $loader, callable $value = null)
106106
{
107107
$hash = self::generateHash([$loader, $value], 'fromLoader');
108108

@@ -116,7 +116,7 @@ public function createListFromLoader(ChoiceLoaderInterface $loader, $value = nul
116116
/**
117117
* {@inheritdoc}
118118
*/
119-
public function createView(ChoiceListInterface $list, $preferredChoices = null, $label = null, $index = null, $groupBy = null, $attr = null)
119+
public function createView(ChoiceListInterface $list, $preferredChoices = null, callable $label = null, callable $index = null, callable $groupBy = null, $attr = null)
120120
{
121121
// The input is not validated on purpose. This way, the decorated
122122
// factory may decide which input to accept and which not.

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

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,9 @@ interface ChoiceListFactoryInterface
3131
* The callable receives the choice as only argument.
3232
* Null may be passed when the choice list contains the empty value.
3333
*
34-
* @param callable|null $value The callable generating the choice values
35-
*
3634
* @return ChoiceListInterface The choice list
3735
*/
38-
public function createListFromChoices(iterable $choices, $value = null);
36+
public function createListFromChoices(iterable $choices, callable $value = null);
3937

4038
/**
4139
* Creates a choice list that is loaded with the given loader.
@@ -44,11 +42,9 @@ public function createListFromChoices(iterable $choices, $value = null);
4442
* The callable receives the choice as only argument.
4543
* Null may be passed when the choice list contains the empty value.
4644
*
47-
* @param callable|null $value The callable generating the choice values
48-
*
4945
* @return ChoiceListInterface The choice list
5046
*/
51-
public function createListFromLoader(ChoiceLoaderInterface $loader, $value = null);
47+
public function createListFromLoader(ChoiceLoaderInterface $loader, callable $value = null);
5248

5349
/**
5450
* Creates a view for the given choice list.
@@ -77,16 +73,10 @@ public function createListFromLoader(ChoiceLoaderInterface $loader, $value = nul
7773
* attributes that should be added to the respective choice.
7874
*
7975
* @param array|callable|null $preferredChoices The preferred choices
80-
* @param callable|null $label The callable generating the
81-
* choice labels
82-
* @param callable|null $index The callable generating the
83-
* view indices
84-
* @param callable|null $groupBy The callable generating the
85-
* group names
8676
* @param array|callable|null $attr The callable generating the
8777
* HTML attributes
8878
*
8979
* @return ChoiceListView The choice list view
9080
*/
91-
public function createView(ChoiceListInterface $list, $preferredChoices = null, $label = null, $index = null, $groupBy = null, $attr = null);
81+
public function createView(ChoiceListInterface $list, $preferredChoices = null, callable $label = null, callable $index = null, callable $groupBy = null, $attr = null);
9282
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,23 @@ class DefaultChoiceListFactory implements ChoiceListFactoryInterface
2929
/**
3030
* {@inheritdoc}
3131
*/
32-
public function createListFromChoices(iterable $choices, $value = null)
32+
public function createListFromChoices(iterable $choices, callable $value = null)
3333
{
3434
return new ArrayChoiceList($choices, $value);
3535
}
3636

3737
/**
3838
* {@inheritdoc}
3939
*/
40-
public function createListFromLoader(ChoiceLoaderInterface $loader, $value = null)
40+
public function createListFromLoader(ChoiceLoaderInterface $loader, callable $value = null)
4141
{
4242
return new LazyChoiceList($loader, $value);
4343
}
4444

4545
/**
4646
* {@inheritdoc}
4747
*/
48-
public function createView(ChoiceListInterface $list, $preferredChoices = null, $label = null, $index = null, $groupBy = null, $attr = null)
48+
public function createView(ChoiceListInterface $list, $preferredChoices = null, callable $label = null, callable $index = null, callable $groupBy = null, $attr = null)
4949
{
5050
$preferredViews = [];
5151
$preferredViewsOrder = [];

0 commit comments

Comments
 (0)
0