8000 [Form] ChoiceType: Fix cast to string from null choice by yceruto · Pull Request #21160 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Form] ChoiceType: Fix cast to string from null choice #21160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix cast null choice to string
  • Loading branch information
yceruto committed Jan 4, 2017
commit f6cca42adff6d3377e4868fc4435a23d6787e4f7
2 changes: 1 addition & 1 deletion src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ private function castableToString(array $choices, array &$cache = array())
}

continue;
} elseif (!is_scalar($choice)) {
} elseif (null !== $choice && !is_scalar($choice)) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,14 @@ public function testGetChoicesForValuesWithContainingNull()
{
$choiceList = new ArrayChoiceList(array('Null' => null));

$this->assertSame(array(0 => null), $choiceList->getChoicesForValues(array('0')));
$this->assertSame(array(0 => null), $choiceList->getChoicesForValues(array('')));
}

public function testGetChoicesForValuesWithContainingFalseAndNull()
{
$choiceList = new ArrayChoiceList(array('False' => false, 'Null' => null));

$this->assertSame(array(0 => null), $choiceList->getChoicesForValues(array('1')));
$this->assertSame(array(0 => null), $choiceList->getChoicesForValues(array('')));
$this->assertSame(array(0 => false), $choiceList->getChoicesForValues(array('0')));
}

Expand Down
0