diff --git a/src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php b/src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php index b1e6b3bf06b5c..e979455ef3799 100644 --- a/src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php +++ b/src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php @@ -141,7 +141,7 @@ public function getChoicesForValues(array $values) $choices = array(); foreach ($values as $i => $givenValue) { - if (isset($this->choices[$givenValue])) { + if (array_key_exists($givenValue, $this->choices)) { $choices[$i] = $this->choices[$givenValue]; } } diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/ArrayChoiceListTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/ArrayChoiceListTest.php index 03cb7fce5705a..9ea5f631a1585 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/ArrayChoiceListTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/ArrayChoiceListTest.php @@ -130,4 +130,11 @@ public function testCompareChoicesByIdentityByDefault() $this->assertSame(array(2 => 'value2'), $choiceList->getValuesForChoices(array(2 => $obj2))); $this->assertSame(array(2 => 'value2'), $choiceList->getValuesForChoices(array(2 => (object) array('value' => 'value2')))); } + + public function testGetChoicesForValuesWithContainingNull() + { + $choiceList = new ArrayChoiceList(array('Null' => null)); + + $this->assertSame(array(0 => null), $choiceList->getChoicesForValues(array('0'))); + } } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy