8000 fixup: reverted LazyChoiceList changes · symfony/symfony@07252a4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 07252a4

Browse files
committed
fixup: reverted LazyChoiceList changes
1 parent 80ecbcb commit 07252a4

File tree

2 files changed

+8
-37
lines changed

2 files changed

+8
-37
lines changed

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

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ class LazyChoiceList implements ChoiceListInterface
3838
*/
3939
private $value;
4040

41-
/**
42-
* @var ChoiceListInterface|null
43-
*/
44-
private $loadedList;
45-
4641
/**
4742
* Creates a lazily-loaded list using the given loader.
4843
*
@@ -63,58 +58,38 @@ public function __construct(ChoiceLoaderInterface $loader, callable $value = nul
6358
*/
6459
public function getChoices()
6560
{
66-
if ($this->loadedList) {
67-
return $this->loadedList->getChoices();
68-
}
69-
70-
return ($this->loadedList = $this->loader->loadChoiceList($this->value))->getChoices();
61+
return $this->loader->loadChoiceList($this->value)->getChoices();
7162
}
7263

7364
/**
7465
* {@inheritdoc}
7566
*/
7667
public function getValues()
7768
{
78-
if ($this->loadedList) {
79-
return $this->loadedList->getValues();
80-
}
81-
82-
return ($this->loadedList = $this->loader->loadChoiceList($this->value))->getValues();
69+
return $this->loader->loadChoiceList($this->value)->getValues();
8370
}
8471

8572
/**
8673
* {@inheritdoc}
8774
*/
8875
public function getStructuredValues()
8976
{
90-
if ($this->loadedList) {
91-
return $this->loadedList->getStructuredValues();
92-
}
93-
94-
return ($this->loadedList = $this->loader->loadChoiceList($this->value))->getStructuredValues();
77+
return $this->loader->loadChoiceList($this->value)->getStructuredValues();
9578
}
9679

9780
/**
9881
* {@inheritdoc}
9982
*/
10083
public function getOriginalKeys()
10184
{
102-
if ($this->loadedList) {
103-
return $this->loadedList->getOriginalKeys();
104-
}
105-
106-
return ($this->loadedList = $this->loader->loadChoiceList($this->value))->getOriginalKeys();
85+
return $this->loader->loadChoiceList($this->value)->getOriginalKeys();
10786
}
10887

10988
/**
11089
* {@inheritdoc}
11190
*/
11291
public function getChoicesForValues(array $values)
11392
{
114-
if ($this->loadedList) {
115-
return $this->loadedList->getChoicesForValues($values);
116-
}
117-
11893
return $this->loader->loadChoicesForValues($values, $this->value);
11994
}
12095

@@ -123,10 +98,6 @@ public function getChoicesForValues(array $values)
12398
*/
12499
public function getValuesForChoices(array $choices)
125100
{
126-
if ($this->loadedList) {
127-
return $this->loadedList->getValuesForChoices($choices);
128-
}
129-
130101
return $this->loader->loadValuesForChoices($choices, $this->value);
131102
}
132103
}

src/Symfony/Component/Form/Tests/ChoiceList/LazyChoiceListTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function testGetChoiceLoadersLoadsLoadedListOnFirstCall()
3232

3333
$this->assertSame(['RESULT'], $list->getChoices());
3434
$this->assertSame(['RESULT'], $list->getChoices());
35-
$this->assertSame(1, $calls);
35+
$this->assertSame(2, $calls);
3636
}
3737

3838
public function testGetValuesLoadsLoadedListOnFirstCall()
@@ -46,7 +46,7 @@ public function testGetValuesLoadsLoadedListOnFirstCall()
4646

4747
$this->assertSame(['RESULT'], $list->getValues());
4848
$this->assertSame(['RESULT'], $list->getValues());
49-
$this->assertSame(1, $calls);
49+
$this->assertSame(2, $calls);
5050
}
5151

5252
public function testGetStructuredValuesLoadsLoadedListOnFirstCall()
@@ -60,7 +60,7 @@ public function testGetStructuredValuesLoadsLoadedListOnFirstCall()
6060

6161
$this->assertSame(['RESULT'], $list->getStructuredValues());
6262
$this->assertSame(['RESULT'], $list->getStructuredValues());
63-
$this->assertSame(1, $calls);
63+
$this->assertSame(2, $calls);
6464
}
6565

6666
public function testGetOriginalKeysLoadsLoadedListOnFirstCall()
@@ -79,7 +79,7 @@ public function testGetOriginalKeysLoadsLoadedListOnFirstCall()
7979

8080
$this->assertSame(['foo' => 'a', 'bar' => 'b', 'baz' => 'c'], $list->getOriginalKeys());
8181
$this->assertSame(['foo' => 'a', 'bar' => 'b', 'baz' => 'c'], $list->getOriginalKeys());
82-
$this->assertSame(3, $calls);
82+
$this->assertSame(6, $calls);
8383
}
8484

8585
public function testGetChoicesForValuesForwardsCallIfListNotLoaded()

0 commit comments

Comments
 (0)
0