summaryrefslogtreecommitdiff
path: root/ext/json/tests
diff options
context:
space:
mode:
authorKevin Israel <pleasestand@live.com>2013-11-02 15:47:24 -0400
committerKevin Israel <pleasestand@live.com>2013-11-02 15:59:11 -0400
commit82a4f1a1a287d9dbf01156bc14ceb13ccbf16d7a (patch)
tree452203e4d5cebe6377e504dda70954042884d0d9 /ext/json/tests
parentd3fd163d2734a3b615eb76ca593b79590b3fd4ae (diff)
downloadphp-git-82a4f1a1a287d9dbf01156bc14ceb13ccbf16d7a.tar.gz
Fix #66021 (Blank line inside empty array/object)
Changed json_encode() so that when the JSON_PRETTY_PRINT option is specified, the pair of linefeeds immediately after an opening bracket and before the corresponding closing bracket is omitted when the array or object contains no elements or accessible properties (and hence would have a blank line between the brackets).
Diffstat (limited to 'ext/json/tests')
-rw-r--r--ext/json/tests/bug66021.phpt20
1 files changed, 20 insertions, 0 deletions
diff --git a/ext/json/tests/bug66021.phpt b/ext/json/tests/bug66021.phpt
new file mode 100644
index 0000000000..cf52e0c6df
--- /dev/null
+++ b/ext/json/tests/bug66021.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Bug #66021 (Blank line inside empty array/object when JSON_PRETTY_PRINT is set)
+--SKIPIF--
+<?php if (!extension_loaded("json")) print "skip"; ?>
+--FILE--
+<?php
+
+class Foo {
+ private $bar = 'baz';
+}
+
+echo json_encode([[], (object)[], new Foo], JSON_PRETTY_PRINT), "\n";
+
+?>
+--EXPECT--
+[
+ [],
+ {},
+ {}
+]