]> granicus.if.org Git - php/commitdiff
Convert json functions arginfo to php stubs
authorCraig Duncan <php@duncanc.co.uk>
Sat, 10 Aug 2019 11:39:53 +0000 (12:39 +0100)
committerCraig Duncan <duncan3dc@php.net>
Sat, 10 Aug 2019 15:04:30 +0000 (16:04 +0100)
Closes GH-4500

ext/json/json.c
ext/json/json.stub.php [new file with mode: 0644]
ext/json/json_arginfo.h [new file with mode: 0644]

index 84746422663aa771184b83ffc0b63de26993c10c..a68e6ea3428f71adb7119a5a139749c80868ef24 100644 (file)
@@ -29,6 +29,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 +43,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)
diff --git a/ext/json/json.stub.php b/ext/json/json.stub.php
new file mode 100644 (file)
index 0000000..323cb64
--- /dev/null
@@ -0,0 +1,11 @@
+<?php
+
+/** @return string|false */
+function json_encode($value, int $options = 0, int $depth = 512) {}
+
+/** @return mixed */
+function json_decode(string $json, ?bool $assoc = null, int $depth = 512, int $options = 0) {}
+
+function json_last_error(): int {}
+
+function json_last_error_msg(): string {}
diff --git a/ext/json/json_arginfo.h b/ext/json/json_arginfo.h
new file mode 100644 (file)
index 0000000..fa0dcea
--- /dev/null
@@ -0,0 +1,20 @@
+/* This is a generated file, edit the .stub.php file instead. */
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_json_encode, 0, 0, 1)
+       ZEND_ARG_INFO(0, value)
+       ZEND_ARG_TYPE_INFO(0, options, IS_LONG, 0)
+       ZEND_ARG_TYPE_INFO(0, depth, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_json_decode, 0, 0, 1)
+       ZEND_ARG_TYPE_INFO(0, json, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO(0, assoc, _IS_BOOL, 0)
+       ZEND_ARG_TYPE_INFO(0, depth, IS_LONG, 0)
+       ZEND_ARG_TYPE_INFO(0, options, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_json_last_error, 0, 0, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_json_last_error_msg, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()