}
if (depth <= 0) {
- php_error_docref(NULL, E_WARNING, "Depth must be greater than zero");
- RETURN_NULL();
+ zend_value_error("Depth must be greater than zero");
+ return;
}
if (depth > INT_MAX) {
- php_error_docref(NULL, E_WARNING, "Depth must be lower than %d", INT_MAX);
- RETURN_NULL();
+ zend_value_error("Depth must be lower than %d", INT_MAX);
+ return;
}
/* For BC reasons, the bool $assoc overrides the long $options bit for PHP_JSON_OBJECT_AS_ARRAY */
--FILE--
<?php
-var_dump(json_decode('[]', false, 0x100000000));
+try {
+ var_dump(json_decode('[]', false, 0x100000000));
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
?>
--EXPECTF--
-Warning: json_decode(): Depth must be lower than %d in %s on line %d
-NULL
+Depth must be lower than %d
echo "*** Testing json_decode() : error conditions ***\n";
echo "\n-- Testing json_decode() function with depth below 0 --\n";
-var_dump(json_decode('"abc"', true, -1));
+
+try {
+ var_dump(json_decode('"abc"', true, -1));
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
?>
---EXPECTF--
+--EXPECT--
*** Testing json_decode() : error conditions ***
-- Testing json_decode() function with depth below 0 --
-
-Warning: json_decode(): Depth must be greater than zero in %s on line %d
-NULL
+Depth must be greater than zero