summaryrefslogtreecommitdiff
path: root/ext/json/json.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/json/json.c')
-rw-r--r--ext/json/json.c44
1 files changed, 9 insertions, 35 deletions
diff --git a/ext/json/json.c b/ext/json/json.c
index 8474642266..06e485bfe4 100644
--- a/ext/json/json.c
+++ b/ext/json/json.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -29,6 +27,7 @@
#include "php_json.h"
#include "php_json_encoder.h"
#include "php_json_parser.h"
+#include "json_arginfo.h"
#include <zend_exceptions.h>
static PHP_MINFO_FUNCTION(json);
@@ -42,27 +41,6 @@ PHP_JSON_API zend_class_entry *php_json_exception_ce;
PHP_JSON_API ZEND_DECLARE_MODULE_GLOBALS(json)
-/* {{{ arginfo */
-ZEND_BEGIN_ARG_INFO_EX(arginfo_json_encode, 0, 0, 1)
- ZEND_ARG_INFO(0, value)
- ZEND_ARG_INFO(0, options)
- ZEND_ARG_INFO(0, depth)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_json_decode, 0, 0, 1)
- ZEND_ARG_INFO(0, json)
- ZEND_ARG_INFO(0, assoc)
- ZEND_ARG_INFO(0, depth)
- ZEND_ARG_INFO(0, options)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_json_last_error, 0)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_json_last_error_msg, 0)
-ZEND_END_ARG_INFO()
-/* }}} */
-
/* {{{ json_functions[] */
static const zend_function_entry json_functions[] = {
PHP_FE(json_encode, arginfo_json_encode)
@@ -74,12 +52,8 @@ static const zend_function_entry json_functions[] = {
/* }}} */
/* {{{ JsonSerializable methods */
-ZEND_BEGIN_ARG_INFO(json_serialize_arginfo, 0)
- /* No arguments */
-ZEND_END_ARG_INFO();
-
static const zend_function_entry json_serializable_interface[] = {
- PHP_ABSTRACT_ME(JsonSerializable, jsonSerialize, json_serialize_arginfo)
+ PHP_ABSTRACT_ME(JsonSerializable, jsonSerialize, arginfo_class_JsonSerializable_jsonSerialize)
PHP_FE_END
};
/* }}} */
@@ -294,7 +268,7 @@ static PHP_FUNCTION(json_encode)
if (encoder.error_code != PHP_JSON_ERROR_NONE) {
smart_str_free(&buf);
zend_throw_exception(php_json_exception_ce, php_json_get_error_msg(encoder.error_code), encoder.error_code);
- RETURN_FALSE;
+ RETURN_THROWS();
}
}
@@ -339,13 +313,13 @@ static PHP_FUNCTION(json_decode)
}
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_THROWS();
}
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_THROWS();
}
/* For BC reasons, the bool $assoc overrides the long $options bit for PHP_JSON_OBJECT_AS_ARRAY */
@@ -366,7 +340,7 @@ static PHP_FUNCTION(json_decode)
static PHP_FUNCTION(json_last_error)
{
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
RETURN_LONG(JSON_G(error_code));
@@ -378,7 +352,7 @@ static PHP_FUNCTION(json_last_error)
static PHP_FUNCTION(json_last_error_msg)
{
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
RETURN_STRING(php_json_get_error_msg(JSON_G(error_code)));