summaryrefslogtreecommitdiff
path: root/ext/json/tests
diff options
context:
space:
mode:
authorSara Golemon <pollita@php.net>2017-03-17 15:36:24 -0700
committerSara Golemon <pollita@php.net>2017-03-17 15:36:24 -0700
commitaa2282df21b32f9a2a1e86b580cb4fca5ff2c3f5 (patch)
treef7feb067887b4155814d841d9a216321b7e58167 /ext/json/tests
parentea36cf2b89dc7c0ffedc56dfeff865ed14273063 (diff)
downloadphp-git-aa2282df21b32f9a2a1e86b580cb4fca5ff2c3f5.tar.gz
Allow JSON_OBJECT_AS_ARRAY option to actually have meaning
Options can only be passed if $assoc is passed, but passing assoc clobbers any attempt to pass JSON_OBJECT_AS_ARRAY as an option. Allow the option to occur in the options field by handling "null" as default/use-options.
Diffstat (limited to 'ext/json/tests')
-rw-r--r--ext/json/tests/bug73991.phpt28
1 files changed, 28 insertions, 0 deletions
diff --git a/ext/json/tests/bug73991.phpt b/ext/json/tests/bug73991.phpt
new file mode 100644
index 0000000000..06aba555f0
--- /dev/null
+++ b/ext/json/tests/bug73991.phpt
@@ -0,0 +1,28 @@
+--TEST--
+Allow JSON_OBJECT_AS_ARRAY to have an effect
+--FILE--
+<?php
+
+$json = '{"foo":"bar"}';
+
+var_dump(json_decode($json, false));
+var_dump(json_decode($json, true));
+var_dump(json_decode($json, null, 512, 0));
+var_dump(json_decode($json, null, 512, JSON_OBJECT_AS_ARRAY));
+--EXPECTF--
+object(stdClass)#%d (1) {
+ ["foo"]=>
+ string(3) "bar"
+}
+array(1) {
+ ["foo"]=>
+ string(3) "bar"
+}
+object(stdClass)#%d (1) {
+ ["foo"]=>
+ string(3) "bar"
+}
+array(1) {
+ ["foo"]=>
+ string(3) "bar"
+}