mirror of
https://github.com/php/php-src.git
synced 2025-01-08 12:04:24 +08:00
32a1ebbd43
These are no longer needed after https://wiki.php.net/rfc/always_enable_json Closes GH-5637
49 lines
970 B
PHP
49 lines
970 B
PHP
--TEST--
|
|
JSON_THROW_ON_ERROR: global error flag untouched
|
|
--FILE--
|
|
<?php
|
|
|
|
var_dump(json_last_error());
|
|
|
|
// here we cause a different kind of error to the following errors, so that
|
|
// we can be sure the global error state looking unchanged isn't coincidence
|
|
json_decode("\xFF");
|
|
|
|
var_dump(json_last_error());
|
|
|
|
try {
|
|
json_decode("", false, 512, JSON_THROW_ON_ERROR);
|
|
} catch (JsonException $e) {
|
|
echo "Caught JSON exception: ", $e->getCode(), PHP_EOL;
|
|
}
|
|
|
|
var_dump(json_last_error());
|
|
|
|
try {
|
|
json_decode("{", false, 512, JSON_THROW_ON_ERROR);
|
|
} catch (JsonException $e) {
|
|
echo "Caught JSON exception: ", $e->getCode(), PHP_EOL;
|
|
}
|
|
|
|
var_dump(json_last_error());
|
|
|
|
|
|
try {
|
|
json_encode(NAN, JSON_THROW_ON_ERROR);
|
|
} catch (JsonException $e) {
|
|
echo "Caught JSON exception: ", $e->getCode(), PHP_EOL;
|
|
}
|
|
|
|
var_dump(json_last_error());
|
|
|
|
?>
|
|
--EXPECT--
|
|
int(0)
|
|
int(5)
|
|
Caught JSON exception: 4
|
|
int(5)
|
|
Caught JSON exception: 4
|
|
int(5)
|
|
Caught JSON exception: 7
|
|
int(5)
|