summaryrefslogtreecommitdiff
path: root/ext/json
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-02-03 22:52:20 +0100
committerNikita Popov <nikita.ppv@gmail.com>2020-02-03 22:52:20 +0100
commitf8d795820e780a6322e054c26c581570613c14f0 (patch)
tree99d3ae01ce564752807341c5743863b4c92513f8 /ext/json
parentd2cb200e10ada6fa44c54a29292bb4665728fff0 (diff)
downloadphp-git-f8d795820e780a6322e054c26c581570613c14f0.tar.gz
Reindent phpt files
Diffstat (limited to 'ext/json')
-rw-r--r--ext/json/tests/bug40503.phpt2
-rw-r--r--ext/json/tests/bug42090.phpt14
-rw-r--r--ext/json/tests/bug46215.phpt2
-rw-r--r--ext/json/tests/bug46944.phpt8
-rw-r--r--ext/json/tests/bug47644.phpt2
-rw-r--r--ext/json/tests/bug54058.phpt4
-rw-r--r--ext/json/tests/bug61978.phpt32
-rw-r--r--ext/json/tests/bug62369.phpt26
-rw-r--r--ext/json/tests/bug63737.phpt8
-rw-r--r--ext/json/tests/bug64874_part1.phpt6
-rw-r--r--ext/json/tests/bug64874_part2.phpt4
-rw-r--r--ext/json/tests/bug66021.phpt2
-rw-r--r--ext/json/tests/bug66025.phpt4
-rw-r--r--ext/json/tests/bug68992.phpt8
-rw-r--r--ext/json/tests/bug71835.phpt12
-rw-r--r--ext/json/tests/bug72069.phpt8
-rw-r--r--ext/json/tests/bug73113.phpt4
-rw-r--r--ext/json/tests/fail001.phpt58
-rw-r--r--ext/json/tests/json_decode_basic.phpt46
-rw-r--r--ext/json/tests/json_decode_exceptions.phpt4
-rw-r--r--ext/json/tests/json_decode_invalid_utf8.phpt16
-rw-r--r--ext/json/tests/json_encode_basic.phpt102
-rw-r--r--ext/json/tests/json_encode_exceptions.phpt4
-rw-r--r--ext/json/tests/json_encode_invalid_utf8.phpt10
-rw-r--r--ext/json/tests/json_encode_numeric.phpt12
-rw-r--r--ext/json/tests/json_encode_pretty_print.phpt10
-rw-r--r--ext/json/tests/json_exceptions_error_clearing.phpt12
-rw-r--r--ext/json/tests/serialize.phpt56
28 files changed, 238 insertions, 238 deletions
diff --git a/ext/json/tests/bug40503.phpt b/ext/json/tests/bug40503.phpt
index 10896a428e..17c8fbd92a 100644
--- a/ext/json/tests/bug40503.phpt
+++ b/ext/json/tests/bug40503.phpt
@@ -7,7 +7,7 @@ serialize_precision=-1
--FILE--
<?php
function json_test_show_eq($x, $y) {
- echo "$x ". ( $x == $y ? "==" : "!=") ." $y\n";
+ echo "$x ". ( $x == $y ? "==" : "!=") ." $y\n";
}
$value = 0x7FFFFFFF; #2147483647;
diff --git a/ext/json/tests/bug42090.phpt b/ext/json/tests/bug42090.phpt
index 9e5b3317e5..b0c9efc102 100644
--- a/ext/json/tests/bug42090.phpt
+++ b/ext/json/tests/bug42090.phpt
@@ -5,13 +5,13 @@ Bug #42090 (json_decode causes segmentation fault)
--FILE--
<?php
var_dump(
- json_decode('""'),
- json_decode('"..".'),
- json_decode('"'),
- json_decode('""""'),
- json_encode('"'),
- json_decode(json_encode('"')),
- json_decode(json_encode('""'))
+ json_decode('""'),
+ json_decode('"..".'),
+ json_decode('"'),
+ json_decode('""""'),
+ json_encode('"'),
+ json_decode(json_encode('"')),
+ json_decode(json_encode('""'))
);
?>
--EXPECT--
diff --git a/ext/json/tests/bug46215.phpt b/ext/json/tests/bug46215.phpt
index be3a80f860..eaf980d49a 100644
--- a/ext/json/tests/bug46215.phpt
+++ b/ext/json/tests/bug46215.phpt
@@ -6,7 +6,7 @@ Bug #46215 (json_encode mutates its parameter and has some class-specific state)
<?php
class foo {
- protected $a = array();
+ protected $a = array();
}
$a = new foo;
diff --git a/ext/json/tests/bug46944.phpt b/ext/json/tests/bug46944.phpt
index 3d70f3ee11..b5b0d97c34 100644
--- a/ext/json/tests/bug46944.phpt
+++ b/ext/json/tests/bug46944.phpt
@@ -6,10 +6,10 @@ Bug #46944 (json_encode() doesn't handle 3 byte utf8 correctly)
<?php
for ($i = 1; $i <= 16; $i++) {
- $first = 0xf0 | ($i >> 2);
- $second = 0x8f | ($i & 3) << 4;
- $string = sprintf("aa%c%c\xbf\xbdzz", $first, $second);
- echo json_encode($string) . "\n";
+ $first = 0xf0 | ($i >> 2);
+ $second = 0x8f | ($i & 3) << 4;
+ $string = sprintf("aa%c%c\xbf\xbdzz", $first, $second);
+ echo json_encode($string) . "\n";
}
diff --git a/ext/json/tests/bug47644.phpt b/ext/json/tests/bug47644.phpt
index c8650958e8..b5f4880cf9 100644
--- a/ext/json/tests/bug47644.phpt
+++ b/ext/json/tests/bug47644.phpt
@@ -9,7 +9,7 @@ if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
<?php
for ($i = 10000000000000000; $i < 10000000000000006; $i++) {
- var_dump(json_decode("[$i]"));
+ var_dump(json_decode("[$i]"));
}
diff --git a/ext/json/tests/bug54058.phpt b/ext/json/tests/bug54058.phpt
index ccb6389110..3f413b65f6 100644
--- a/ext/json/tests/bug54058.phpt
+++ b/ext/json/tests/bug54058.phpt
@@ -22,8 +22,8 @@ json_encode($b);
var_dump(json_last_error(), json_last_error_msg());
$c = array(
- 'foo' => $bad_utf8,
- 'bar' => 1
+ 'foo' => $bad_utf8,
+ 'bar' => 1
);
json_encode($c);
var_dump(json_last_error(), json_last_error_msg());
diff --git a/ext/json/tests/bug61978.phpt b/ext/json/tests/bug61978.phpt
index 68df624de1..a26341e4cc 100644
--- a/ext/json/tests/bug61978.phpt
+++ b/ext/json/tests/bug61978.phpt
@@ -6,25 +6,25 @@ Bug #61978 (Object recursion not detected for classes that implement JsonSeriali
<?php
class JsonTest1 {
- public $test;
- public $me;
- public function __construct() {
- $this->test = '123';
- $this->me = $this;
- }
+ public $test;
+ public $me;
+ public function __construct() {
+ $this->test = '123';
+ $this->me = $this;
+ }
}
class JsonTest2 implements JsonSerializable {
- public $test;
- public function __construct() {
- $this->test = '123';
- }
- public function jsonSerialize() {
- return array(
- 'test' => $this->test,
- 'me' => $this
- );
- }
+ public $test;
+ public function __construct() {
+ $this->test = '123';
+ }
+ public function jsonSerialize() {
+ return array(
+ 'test' => $this->test,
+ 'me' => $this
+ );
+ }
}
diff --git a/ext/json/tests/bug62369.phpt b/ext/json/tests/bug62369.phpt
index 6d9f58b967..9c0be481e4 100644
--- a/ext/json/tests/bug62369.phpt
+++ b/ext/json/tests/bug62369.phpt
@@ -7,27 +7,27 @@ FR #62369 (Segfault on json_encode(deeply_nested_array)
$array = array();
for ($i=0; $i < 550; $i++) {
- $array = array($array);
+ $array = array($array);
}
json_encode($array, 0, 551);
switch (json_last_error()) {
- case JSON_ERROR_NONE:
- echo 'OK' . PHP_EOL;
- break;
- case JSON_ERROR_DEPTH:
- echo 'ERROR' . PHP_EOL;
- break;
+ case JSON_ERROR_NONE:
+ echo 'OK' . PHP_EOL;
+ break;
+ case JSON_ERROR_DEPTH:
+ echo 'ERROR' . PHP_EOL;
+ break;
}
json_encode($array, 0, 540);
switch (json_last_error()) {
- case JSON_ERROR_NONE:
- echo 'OK' . PHP_EOL;
- break;
- case JSON_ERROR_DEPTH:
- echo 'ERROR' . PHP_EOL;
- break;
+ case JSON_ERROR_NONE:
+ echo 'OK' . PHP_EOL;
+ break;
+ case JSON_ERROR_DEPTH:
+ echo 'ERROR' . PHP_EOL;
+ break;
}
--EXPECT--
OK
diff --git a/ext/json/tests/bug63737.phpt b/ext/json/tests/bug63737.phpt
index 35361d850a..1fb06d485e 100644
--- a/ext/json/tests/bug63737.phpt
+++ b/ext/json/tests/bug63737.phpt
@@ -5,10 +5,10 @@ Bug #63737 (json_decode does not properly decode with options parameter)
--FILE--
<?php
function decode($json) {
- $x = json_decode($json);
- var_dump($x);
- $x = json_decode($json, false, 512, JSON_BIGINT_AS_STRING);
- var_dump($x);
+ $x = json_decode($json);
+ var_dump($x);
+ $x = json_decode($json, false, 512, JSON_BIGINT_AS_STRING);
+ var_dump($x);
}
decode('123456789012345678901234567890');
diff --git a/ext/json/tests/bug64874_part1.phpt b/ext/json/tests/bug64874_part1.phpt
index 9e0cb7e1cf..6b79b8dc04 100644
--- a/ext/json/tests/bug64874_part1.phpt
+++ b/ext/json/tests/bug64874_part1.phpt
@@ -5,9 +5,9 @@ Whitespace part of bug #64874 ("json_decode handles whitespace and case-sensitiv
--FILE--
<?php
function decode($json) {
- var_dump(json_decode($json));
- var_dump(json_last_error() !== 0);
- echo "\n";
+ var_dump(json_decode($json));
+ var_dump(json_last_error() !== 0);
+ echo "\n";
}
// Leading whitespace should be ignored
diff --git a/ext/json/tests/bug64874_part2.phpt b/ext/json/tests/bug64874_part2.phpt
index db784bd8e0..338fc1141a 100644
--- a/ext/json/tests/bug64874_part2.phpt
+++ b/ext/json/tests/bug64874_part2.phpt
@@ -5,8 +5,8 @@ Case-sensitivity part of bug #64874 ("json_decode handles whitespace and case-se
--FILE--
<?php
function decode($json) {
- var_dump(json_decode($json));
- echo ((json_last_error() !== 0) ? 'ERROR' : 'SUCCESS') . PHP_EOL;
+ var_dump(json_decode($json));
+ echo ((json_last_error() !== 0) ? 'ERROR' : 'SUCCESS') . PHP_EOL;
}
// Only lowercase should work
diff --git a/ext/json/tests/bug66021.phpt b/ext/json/tests/bug66021.phpt
index 504d17fc78..19d28eb66b 100644
--- a/ext/json/tests/bug66021.phpt
+++ b/ext/json/tests/bug66021.phpt
@@ -6,7 +6,7 @@ Bug #66021 (Blank line inside empty array/object when JSON_PRETTY_PRINT is set)
<?php
class Foo {
- private $bar = 'baz';
+ private $bar = 'baz';
}
echo json_encode(array(array(), (object) array(), new Foo), JSON_PRETTY_PRINT);
diff --git a/ext/json/tests/bug66025.phpt b/ext/json/tests/bug66025.phpt
index 9322d39b66..13bd6ea90b 100644
--- a/ext/json/tests/bug66025.phpt
+++ b/ext/json/tests/bug66025.phpt
@@ -9,8 +9,8 @@ if (!extension_loaded('json')) die('skip');
class Foo implements JsonSerializable {
public function jsonSerialize() {
- return json_encode([1], JSON_PRETTY_PRINT);
- }
+ return json_encode([1], JSON_PRETTY_PRINT);
+ }
}
echo json_encode([new Foo]), "\n";
diff --git a/ext/json/tests/bug68992.phpt b/ext/json/tests/bug68992.phpt
index 06448bbb38..8e209e0709 100644
--- a/ext/json/tests/bug68992.phpt
+++ b/ext/json/tests/bug68992.phpt
@@ -9,8 +9,8 @@ if (!extension_loaded('json')) die('skip');
class MyClass implements JsonSerializable {
public function jsonSerialize() {
- throw new Exception('Not implemented!');
- }
+ throw new Exception('Not implemented!');
+ }
}
$classes = [];
for($i = 0; $i < 5; $i++) {
@@ -21,8 +21,8 @@ try {
json_encode($classes);
} catch(Exception $e) {
do {
- printf("%s (%d) [%s]\n", $e->getMessage(), $e->getCode(), get_class($e));
- } while ($e = $e->getPrevious());
+ printf("%s (%d) [%s]\n", $e->getMessage(), $e->getCode(), get_class($e));
+ } while ($e = $e->getPrevious());
}
?>
--EXPECT--
diff --git a/ext/json/tests/bug71835.phpt b/ext/json/tests/bug71835.phpt
index dbe313b70c..334c84c595 100644
--- a/ext/json/tests/bug71835.phpt
+++ b/ext/json/tests/bug71835.phpt
@@ -5,18 +5,18 @@ Bug #71835 (json_encode sometimes incorrectly detects recursion with JsonSeriali
--FILE--
<?php
class SomeClass implements JsonSerializable {
- public function jsonSerialize() {
- return [get_object_vars($this)];
- }
+ public function jsonSerialize() {
+ return [get_object_vars($this)];
+ }
}
$class = new SomeClass;
$arr = [$class];
var_dump(json_encode($arr));
class SomeClass2 implements JsonSerializable {
- public function jsonSerialize() {
- return [(array)$this];
- }
+ public function jsonSerialize() {
+ return [(array)$this];
+ }
}
$class = new SomeClass2;
$arr = [$class];
diff --git a/ext/json/tests/bug72069.phpt b/ext/json/tests/bug72069.phpt
index 0ff8c98621..d7c7729013 100644
--- a/ext/json/tests/bug72069.phpt
+++ b/ext/json/tests/bug72069.phpt
@@ -10,10 +10,10 @@ var_dump($result);
class A implements \JsonSerializable
{
- function jsonSerialize()
- {
- return ['end' => json_decode(null, true)];
- }
+ function jsonSerialize()
+ {
+ return ['end' => json_decode(null, true)];
+ }
}
$a = new A();
$toJsonData = $a->jsonSerialize();
diff --git a/ext/json/tests/bug73113.phpt b/ext/json/tests/bug73113.phpt
index d45e51f683..1bb1706331 100644
--- a/ext/json/tests/bug73113.phpt
+++ b/ext/json/tests/bug73113.phpt
@@ -16,9 +16,9 @@ class JsonSerializableObject implements \JsonSerializable
$obj = new JsonSerializableObject();
try {
- echo json_encode($obj);
+ echo json_encode($obj);
} catch (\Exception $e) {
- echo $e->getMessage();
+ echo $e->getMessage();
}
--EXPECT--
This error is expected
diff --git a/ext/json/tests/fail001.phpt b/ext/json/tests/fail001.phpt
index 21dd42f8c3..b03b77f44d 100644
--- a/ext/json/tests/fail001.phpt
+++ b/ext/json/tests/fail001.phpt
@@ -8,38 +8,38 @@ JSON (http://www.crockford.com/JSON/JSON_checker/test/fail*.json)
<?php
$tests = array(
- '"A JSON payload should be an object or array, not a string."',
- '["Unclosed array"',
- '{unquoted_key: "keys must be quoted}',
- '["extra comma",]',
- '["double extra comma",,]',
- '[ , "<-- missing value"]',
- '["Comma after the close"],',
- '["Extra close"]]',
- '{"Extra comma": true,}',
- '{"Extra value after close": true} "misplaced quoted value"',
- '{"Illegal expression": 1 + 2}',
- '{"Illegal invocation": alert()}',
- '{"Numbers cannot have leading zeroes": 013}',
- '{"Numbers cannot be hex": 0x14}',
- '["Illegal backslash escape: \\x15"]',
- '["Illegal backslash escape: \\\'"]',
- '["Illegal backslash escape: \\017"]',
- '[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]',
- '{"Missing colon" null}',
- '{"Double colon":: null}',
- '{"Comma instead of colon", null}',
- '["Colon instead of comma": false]',
- '["Bad value", truth]',
- "['single quote']"
+ '"A JSON payload should be an object or array, not a string."',
+ '["Unclosed array"',
+ '{unquoted_key: "keys must be quoted}',
+ '["extra comma",]',
+ '["double extra comma",,]',
+ '[ , "<-- missing value"]',
+ '["Comma after the close"],',
+ '["Extra close"]]',
+ '{"Extra comma": true,}',
+ '{"Extra value after close": true} "misplaced quoted value"',
+ '{"Illegal expression": 1 + 2}',
+ '{"Illegal invocation": alert()}',
+ '{"Numbers cannot have leading zeroes": 013}',
+ '{"Numbers cannot be hex": 0x14}',
+ '["Illegal backslash escape: \\x15"]',
+ '["Illegal backslash escape: \\\'"]',
+ '["Illegal backslash escape: \\017"]',
+ '[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]',
+ '{"Missing colon" null}',
+ '{"Double colon":: null}',
+ '{"Comma instead of colon", null}',
+ '["Colon instead of comma": false]',
+ '["Bad value", truth]',
+ "['single quote']"
);
foreach ($tests as $test) {
- echo 'Testing: ' . $test . "\n";
- echo "AS OBJECT\n";
- var_dump(json_decode($test));
- echo "AS ARRAY\n";
- var_dump(json_decode($test, true));
+ echo 'Testing: ' . $test . "\n";
+ echo "AS OBJECT\n";
+ var_dump(json_decode($test));
+ echo "AS ARRAY\n";
+ var_dump(json_decode($test, true));
}
?>
diff --git a/ext/json/tests/json_decode_basic.phpt b/ext/json/tests/json_decode_basic.phpt
index d9125ed7ad..81501c1857 100644
--- a/ext/json/tests/json_decode_basic.phpt
+++ b/ext/json/tests/json_decode_basic.phpt
@@ -8,34 +8,34 @@ echo "*** Testing json_decode() : basic functionality ***\n";
// array with different values for $string
$inputs = array (
- '0',
- '123',
- '-123',
- '2147483647',
- '-2147483648',
- '123.456',
- '1230',
- '-1230',
- 'true',
- 'false',
- 'null',
- '"abc"',
- '"Hello World\r\n"',
- '[]',
- '[1,2,3,4,5]',
- '{"myInt":99,"myFloat":123.45,"myNull":null,"myBool":true,"myString":"Hello World"}',
- '{"Jan":31,"Feb":29,"Mar":31,"April":30,"May":31,"June":30}',
- '""',
- '{}'
+ '0',
+ '123',
+ '-123',
+ '2147483647',
+ '-2147483648',
+ '123.456',
+ '1230',
+ '-1230',
+ 'true',
+ 'false',
+ 'null',
+ '"abc"',
+ '"Hello World\r\n"',
+ '[]',
+ '[1,2,3,4,5]',
+ '{"myInt":99,"myFloat":123.45,"myNull":null,"myBool":true,"myString":"Hello World"}',
+ '{"Jan":31,"Feb":29,"Mar":31,"April":30,"May":31,"June":30}',
+ '""',
+ '{}'
);
// loop through with each element of the $inputs array to test json_decode() function
$count = 1;
foreach($inputs as $input) {
- echo "-- Iteration $count --\n";
- var_dump(json_decode($input));
- var_dump(json_decode($input, true));
- $count++;
+ echo "-- Iteration $count --\n";
+ var_dump(json_decode($input));
+ var_dump(json_decode($input, true));
+ $count++;
}
?>
diff --git a/ext/json/tests/json_decode_exceptions.phpt b/ext/json/tests/json_decode_exceptions.phpt
index 14cf59fd02..ba1b57f5be 100644
--- a/ext/json/tests/json_decode_exceptions.phpt
+++ b/ext/json/tests/json_decode_exceptions.phpt
@@ -6,9 +6,9 @@ Test json_decode() function : JSON_THROW_ON_ERROR flag
<?php
try {
- var_dump(json_decode("{", false, 512, JSON_THROW_ON_ERROR));
+ var_dump(json_decode("{", false, 512, JSON_THROW_ON_ERROR));
} catch (JsonException $e) {
- var_dump($e);
+ var_dump($e);
}
?>
diff --git a/ext/json/tests/json_decode_invalid_utf8.phpt b/ext/json/tests/json_decode_invalid_utf8.phpt
index d92f785424..b69400f360 100644
--- a/ext/json/tests/json_decode_invalid_utf8.phpt
+++ b/ext/json/tests/json_decode_invalid_utf8.phpt
@@ -7,14 +7,14 @@ if (!extension_loaded("json")) print "skip";
--FILE--
<?php
function json_decode_invalid_utf8($str) {
- var_dump(json_decode($str));
- var_dump(json_decode($str, true, 512, JSON_INVALID_UTF8_IGNORE));
- $json = json_decode($str, true, 512, JSON_INVALID_UTF8_SUBSTITUTE);
- if (is_array($json)) {
- var_dump(array_map(function($item) { return bin2hex($item); }, $json));
- } else {
- var_dump(bin2hex($json));
- }
+ var_dump(json_decode($str));
+ var_dump(json_decode($str, true, 512, JSON_INVALID_UTF8_IGNORE));
+ $json = json_decode($str, true, 512, JSON_INVALID_UTF8_SUBSTITUTE);
+ if (is_array($json)) {
+ var_dump(array_map(function($item) { return bin2hex($item); }, $json));
+ } else {
+ var_dump(bin2hex($json));
+ }
}
json_decode_invalid_utf8("\"a\xb0b\"");
json_decode_invalid_utf8("\"a\xd0\xf2b\"");
diff --git a/ext/json/tests/json_encode_basic.phpt b/ext/json/tests/json_encode_basic.phpt
index de65600f38..d351765c0a 100644
--- a/ext/json/tests/json_encode_basic.phpt
+++ b/ext/json/tests/json_encode_basic.phpt
@@ -26,63 +26,63 @@ $obj->MyString = "Hello World";
// array with different values for $string
$inputs = array (
- // integers
- 0,
- 123,
- -123,
- 2147483647,
- -2147483648,
-
- // floats
- 123.456,
- 1.23E3,
- -1.23E3,
-
- // boolean
- TRUE,
- true,
- FALSE,
- false,
-
- // NULL
- NULL,
- null,
-
- // strings
- "abc",
- 'abc',
- "Hello\t\tWorld\n",
-
- // arrays
- array(),
- array(1,2,3,4,5),
- array(1 => "Sun", 2 => "Mon", 3 => "Tue", 4 => "Wed", 5 => "Thur", 6 => "Fri", 7 => "Sat"),
- array("Jan" => 31, "Feb" => 29, "Mar" => 31, "April" => 30, "May" => 31, "June" => 30),
-
- // empty data
- "",
- '',
-
- // undefined data
- @$undefined_var,
-
- // unset data
- @$unset_var,
-
- // resource variable
- $fp,
-
- // object variable
- $obj
+ // integers
+ 0,
+ 123,
+ -123,
+ 2147483647,
+ -2147483648,
+
+ // floats
+ 123.456,
+ 1.23E3,
+ -1.23E3,
+
+ // boolean
+ TRUE,
+ true,
+ FALSE,
+ false,
+
+ // NULL
+ NULL,
+ null,
+
+ // strings
+ "abc",
+ 'abc',
+ "Hello\t\tWorld\n",
+
+ // arrays
+ array(),
+ array(1,2,3,4,5),
+ array(1 => "Sun", 2 => "Mon", 3 => "Tue", 4 => "Wed", 5 => "Thur", 6 => "Fri", 7 => "Sat"),
+ array("Jan" => 31, "Feb" => 29, "Mar" => 31, "April" => 30, "May" => 31, "June" => 30),
+
+ // empty data
+ "",
+ '',
+
+ // undefined data
+ @$undefined_var,
+
+ // unset data
+ @$unset_var,
+
+ // resource variable
+ $fp,
+
+ // object variable
+ $obj
);
// loop through with each element of the $inputs array to test json_encode() function
$count = 1;
foreach($inputs as $input) {
- echo "-- Iteration $count --\n";
- var_dump(json_encode($input));
- $count ++;
+ echo "-- Iteration $count --\n";
+ var_dump(json_encode($input));
+ $count ++;
}
?>
diff --git a/ext/json/tests/json_encode_exceptions.phpt b/ext/json/tests/json_encode_exceptions.phpt
index 507f16ede9..a3d1f7ae25 100644
--- a/ext/json/tests/json_encode_exceptions.phpt
+++ b/ext/json/tests/json_encode_exceptions.phpt
@@ -6,9 +6,9 @@ Test json_encode() function : JSON_THROW_ON_ERROR flag
<?php
try {
- var_dump(json_encode("\x80", JSON_THROW_ON_ERROR));
+ var_dump(json_encode("\x80", JSON_THROW_ON_ERROR));
} catch (JsonException $e) {
- var_dump($e);
+ var_dump($e);
}
// JSON_PARTIAL_OUTPUT_ON_ERROR is incompatible with exceptions
diff --git a/ext/json/tests/json_encode_invalid_utf8.phpt b/ext/json/tests/json_encode_invalid_utf8.phpt
index d7ec58a973..7b032b81e6 100644
--- a/ext/json/tests/json_encode_invalid_utf8.phpt
+++ b/ext/json/tests/json_encode_invalid_utf8.phpt
@@ -7,11 +7,11 @@ if (!extension_loaded("json")) print "skip";
--FILE--
<?php
function json_encode_invalid_utf8($str) {
- var_dump(json_encode($str));
- var_dump(json_encode($str, JSON_INVALID_UTF8_IGNORE));
- var_dump(json_encode($str, JSON_INVALID_UTF8_SUBSTITUTE));
- var_dump(json_encode($str, JSON_UNESCAPED_UNICODE));
- var_dump(bin2hex(json_encode($str, JSON_UNESCAPED_UNICODE | JSON_INVALID_UTF8_SUBSTITUTE)));
+ var_dump(json_encode($str));
+ var_dump(json_encode($str, JSON_INVALID_UTF8_IGNORE));
+ var_dump(json_encode($str, JSON_INVALID_UTF8_SUBSTITUTE));
+ var_dump(json_encode($str, JSON_UNESCAPED_UNICODE));
+ var_dump(bin2hex(json_encode($str, JSON_UNESCAPED_UNICODE | JSON_INVALID_UTF8_SUBSTITUTE)));
}
json_encode_invalid_utf8("\x61\xb0\x62");
json_encode_invalid_utf8("\x61\xf0\x80\x80\x41");
diff --git a/ext/json/tests/json_encode_numeric.phpt b/ext/json/tests/json_encode_numeric.phpt
index 9202cd00ed..c3c7edd444 100644
--- a/ext/json/tests/json_encode_numeric.phpt
+++ b/ext/json/tests/json_encode_numeric.phpt
@@ -7,12 +7,12 @@ serialize_precision=-1
--FILE--
<?php
var_dump(
- json_encode("1", JSON_NUMERIC_CHECK),
- json_encode("9.4324", JSON_NUMERIC_CHECK),
- json_encode(array("122321", "3232595.33423"), JSON_NUMERIC_CHECK),
- json_encode("1"),
- json_encode("9.4324"),
- json_encode(array("122321", "3232595.33423"))
+ json_encode("1", JSON_NUMERIC_CHECK),
+ json_encode("9.4324", JSON_NUMERIC_CHECK),
+ json_encode(array("122321", "3232595.33423"), JSON_NUMERIC_CHECK),
+ json_encode("1"),
+ json_encode("9.4324"),
+ json_encode(array("122321", "3232595.33423"))
);
?>
--EXPECT--
diff --git a/ext/json/tests/json_encode_pretty_print.phpt b/ext/json/tests/json_encode_pretty_print.phpt
index 43b93aafe6..0ac4a6d3fb 100644
--- a/ext/json/tests/json_encode_pretty_print.phpt
+++ b/ext/json/tests/json_encode_pretty_print.phpt
@@ -5,11 +5,11 @@ json_encode() with JSON_PRETTY_PRINT
--FILE--
<?php
function encode_decode($json) {
- $struct = json_decode($json);
- $pretty = json_encode($struct, JSON_PRETTY_PRINT);
- echo "$pretty\n";
- $pretty = json_decode($pretty);
- printf("Match: %d\n", $pretty == $struct);
+ $struct = json_decode($json);
+ $pretty = json_encode($struct, JSON_PRETTY_PRINT);
+ echo "$pretty\n";
+ $pretty = json_decode($pretty);
+ printf("Match: %d\n", $pretty == $struct);
}
encode_decode('[1,2,3,[1,2,3]]');
diff --git a/ext/json/tests/json_exceptions_error_clearing.phpt b/ext/json/tests/json_exceptions_error_clearing.phpt
index 6d01dd7c33..70dfca2171 100644
--- a/ext/json/tests/json_exceptions_error_clearing.phpt
+++ b/ext/json/tests/json_exceptions_error_clearing.phpt
@@ -14,26 +14,26 @@ json_decode("\xFF");
var_dump(json_last_error());
try {
- json_decode("", false, 512, JSON_THROW_ON_ERROR);
+ json_decode("", false, 512, JSON_THROW_ON_ERROR);
} catch (JsonException $e) {
- echo "Caught JSON exception: ", $e->getCode(), PHP_EOL;
+ echo "Caught JSON exception: ", $e->getCode(), PHP_EOL;
}
var_dump(json_last_error());
try {
- json_decode("{", false, 512, JSON_THROW_ON_ERROR);
+ json_decode("{", false, 512, JSON_THROW_ON_ERROR);
} catch (JsonException $e) {
- echo "Caught JSON exception: ", $e->getCode(), PHP_EOL;
+ echo "Caught JSON exception: ", $e->getCode(), PHP_EOL;
}
var_dump(json_last_error());
try {
- json_encode(NAN, JSON_THROW_ON_ERROR);
+ json_encode(NAN, JSON_THROW_ON_ERROR);
} catch (JsonException $e) {
- echo "Caught JSON exception: ", $e->getCode(), PHP_EOL;
+ echo "Caught JSON exception: ", $e->getCode(), PHP_EOL;
}
var_dump(json_last_error());
diff --git a/ext/json/tests/serialize.phpt b/ext/json/tests/serialize.phpt
index 1aa90750da..ab2f9c926d 100644
--- a/ext/json/tests/serialize.phpt
+++ b/ext/json/tests/serialize.phpt
@@ -9,46 +9,46 @@ serialize_precision=-1
class NonSerializingTest
{
- public $data;
+ public $data;
- public function __construct($data)
- {
- $this->data = $data;
- }
+ public function __construct($data)
+ {
+ $this->data = $data;
+ }
}
class SerializingTest extends NonSerializingTest implements JsonSerializable
{
- public function jsonSerialize()
- {
- return $this->data;
- }
+ public function jsonSerialize()
+ {
+ return $this->data;
+ }
}
class ValueSerializingTest extends SerializingTest
{
- public function jsonSerialize()
- {
- return array_values(is_array($this->data) ? $this->data : get_object_vars($this->data));
- }
+ public function jsonSerialize()
+ {
+ return array_values(is_array($this->data) ? $this->data : get_object_vars($this->data));
+ }
}
class SelfSerializingTest extends SerializingTest
{
- public function jsonSerialize()
- {
- return $this;
- }
+ public function jsonSerialize()
+ {
+ return $this;
+ }
}
$adata = array(
- 'str' => 'foo',
- 'int' => 1,
- 'float' => 2.3,
- 'bool' => false,
- 'nil' => null,
- 'arr' => array(1,2,3),
- 'obj' => new StdClass,
+ 'str' => 'foo',
+ 'int' => 1,
+ 'float' => 2.3,
+ 'bool' => false,
+ 'nil' => null,
+ 'arr' => array(1,2,3),
+ 'obj' => new StdClass,
);
$ndata = array_values($adata);
@@ -56,10 +56,10 @@ $ndata = array_values($adata);
$odata = (object)$adata;
foreach(array('NonSerializingTest','SerializingTest','ValueSerializingTest','SelfSerializingTest') as $class) {
- echo "==$class==\n";
- echo json_encode(new $class($adata)), "\n";
- echo json_encode(new $class($ndata)), "\n";
- echo json_encode(new $class($odata)), "\n";
+ echo "==$class==\n";
+ echo json_encode(new $class($adata)), "\n";
+ echo json_encode(new $class($ndata)), "\n";
+ echo json_encode(new $class($odata)), "\n";
}
--EXPECT--
==NonSerializingTest==