php-src/ext/json/tests/json_validate_003.phpt
Juan Morales 2e8699f6f2
RFC - json_validate() (#9399)
* Add `json_validate(string $json, int $depth = 512, int $flags = 0): bool` from https://wiki.php.net/rfc/json_validate
* In json_validate, use a different set of C no-op functions for creating/updating
   arrays/objects when validating while reusing the unmodified parser/scanner code
* Forbid unsupported flags in json_validate()
* Remove test of passing NULL as parameter (normal behavior of https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg for internal functions)

Co-authored-by: jcm <juan.carlos.morales@tradebyte.com>
2022-10-08 09:21:59 -04:00

19 lines
444 B
PHP

--TEST--
json_validate() - Error handling for max depth
--SKIPIF--
<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); ?>
--FILE--
<?php
try {
var_dump(json_validate("-", PHP_INT_MAX));
} catch (ValueError $error) {
echo $error->getMessage() . PHP_EOL;
var_dump(json_last_error(), json_last_error_msg());
}
?>
--EXPECTF--
json_validate(): Argument #2 ($depth) must be less than %d
int(0)
string(8) "No error"