8000 [Serializer] Remove null check · symfony/symfony@58a7f46 · GitHub
[go: up one dir, main page]

Skip to content

Commit 58a7f46

Browse files
committed
[Serializer] Remove null check
1 parent 805dd49 commit 58a7f46

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

src/Symfony/Component/Serializer/Encoder/CsvEncoder.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -196,24 +196,18 @@ private function flatten(array $array, array &$result, $keySeparator, $parentKey
196196

197197
/**
198198
* Ensures an actual value is used instead of a blank value when dealing
199-
* with true, false and null (like a nullable bool in a database).
199+
* with true and false.
200200
*
201201
* @param string $value
202202
*
203-
* @return string|int
203+
* @return int
204204
*/
205205
private function cleanValueByType($value)
206206
{
207207
if (false === $value) {
208208
return 0;
209209
}
210210

211-
if (null === $value) {
212-
// fputcsv will enclose a space
213-
// https://github.com/php/php-src/blob/master/ext/standard/file.c
214-
return ' ';
215-
}
216-
217211
if (true === $value) {
218212
return 1;
219213
}

src/Symfony/Component/Serializer/Tests/Encoder/CsvEncoderTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,19 @@ protected function setUp()
2929
$this->encoder = new CsvEncoder();
3030
}
3131

32-
public function testTrueFalseNullValues()
32+
public function testTrueFalseValues()
3333
{
3434
$data = [
3535
'string' => 'foo',
3636
'int' => 2,
3737
'false' => false,
3838
'true' => true,
39-
'null' => null,
4039
];
4140

42-
// Check that true, false and null are appropriately handled
41+
// Check that true and false are appropriately handled
4342
$this->assertEquals(<<<'CSV'
44-
string,int,false,true,null
45-
foo,2,0,1," "
43+
string,int,false,true
44+
foo,2,0,1
4645

4746
CSV
4847
, $this->encoder->encode($data, 'csv'));

0 commit comments

Comments
 (0)
0