Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
[zendframework/zendframework#5569] Handle null values properly
Browse files Browse the repository at this point in the history
- Previous fix led to:
  ```php
  'null' => ,
  ```
- Fix properly echoes the null value:
  ```php
  'null' => null,
  ```
  • Loading branch information
weierophinney committed Dec 7, 2013
1 parent 5371e74 commit b079428
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Writer/PhpArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ protected function processIndented(array $config, array $arraySyntax, &$indentLe
$arrayString .= ($value ? 'true' : 'false') . ",\n";
} elseif (is_string($value)) {
$arrayString .= "'" . addslashes($value) . "',\n";
} elseif ($value === null) {
$arrayString .= "null,\n";
} else {
$arrayString .= $value . ",\n";
}
Expand Down
2 changes: 2 additions & 0 deletions test/Writer/PhpArrayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function testRender()
'object' => (object) array('foo' => 'bar'),
'integer' => 123,
'boolean' => false,
'null' => null,
));

$configString = $this->writer->toString($config);
Expand All @@ -56,6 +57,7 @@ public function testRender()
$expected .= ")),\n";
$expected .= " 'integer' => 123,\n";
$expected .= " 'boolean' => false,\n";
$expected .= " 'null' => null,\n";
$expected .= ");\n";

$this->assertEquals($expected, $configString);
Expand Down

0 comments on commit b079428

Please sign in to comment.