]> granicus.if.org Git - php/commitdiff
Generate arginfo from PHP stub files
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 18 Jun 2019 09:33:07 +0000 (11:33 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 9 Aug 2019 12:51:25 +0000 (14:51 +0200)
Signature stubs for internal functions are specified in xyz.stub.php,
from which we generate actual arginfo structures in xyz_arginfo.h.
This file then needs to be included in the implementation appropriately.

Arginfo from stubs can be regenerated using scripts/dev/gen_stub.php.
However, this should also automatically happen when the stub file is
modified.

12 files changed:
.gitignore
Zend/zend_builtin_functions.c
Zend/zend_builtin_functions.stub.php [new file with mode: 0644]
Zend/zend_builtin_functions_arginfo.h [new file with mode: 0644]
build/Makefile.global
ext/date/php_date.c
ext/date/php_date.stub.php [new file with mode: 0644]
ext/date/php_date_arginfo.h [new file with mode: 0644]
ext/standard/basic_functions.c
ext/standard/basic_functions.stub.php [new file with mode: 0644]
ext/standard/basic_functions_arginfo.h [new file with mode: 0644]
scripts/dev/gen_stub.php [new file with mode: 0755]

index 58cc8ecbb6a4d06a00993e8ca537fd0c9c6136fc..fbe8c113b205668dedb2af08d91393e5348728e1 100644 (file)
@@ -80,6 +80,9 @@ include/
 libs/
 modules/
 
+# Used by scripts/dev/gen_stub.php
+scripts/dev/PHP-Parser-*
+
 # ------------------------------------------------------------------------------
 # Configuration headers generated by the PHP build system
 # ------------------------------------------------------------------------------
index ce939f6489b82c048097f48fc42f6db369e3b28e..be566ae681e95f44701c5f5216b72a43a7560124 100644 (file)
@@ -85,154 +85,15 @@ static ZEND_FUNCTION(gc_enable);
 static ZEND_FUNCTION(gc_disable);
 static ZEND_FUNCTION(gc_status);
 
-/* {{{ arginfo */
-ZEND_BEGIN_ARG_INFO(arginfo_zend__void, 0)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_func_get_arg, 0, 0, 1)
-       ZEND_ARG_TYPE_INFO(0, arg_num, IS_LONG, 0)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_strlen, 0, 1, IS_LONG, 0)
-       ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_strcmp, 0, 2, IS_LONG, 0)
-       ZEND_ARG_TYPE_INFO(0, str1, IS_STRING, 0)
-       ZEND_ARG_TYPE_INFO(0, str2, IS_STRING, 0)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_strncmp, 0, 0, 3)
-       ZEND_ARG_TYPE_INFO(0, str1, IS_STRING, 0)
-       ZEND_ARG_TYPE_INFO(0, str2, IS_STRING, 0)
-       ZEND_ARG_TYPE_INFO(0, len, IS_LONG, 0)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_error_reporting, 0, 0, 0)
-       ZEND_ARG_INFO(0, new_error_level)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_define, 0, 0, 2)
-       ZEND_ARG_INFO(0, constant_name)
-       ZEND_ARG_INFO(0, value)
-       ZEND_ARG_INFO(0, case_insensitive)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_defined, 0, 0, 1)
-       ZEND_ARG_INFO(0, constant_name)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_get_class, 0, 0, 0)
-       ZEND_ARG_INFO(0, object)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_is_subclass_of, 0, 0, 2)
-       ZEND_ARG_INFO(0, object)
-       ZEND_ARG_INFO(0, class_name)
-       ZEND_ARG_INFO(0, allow_string)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_get_class_vars, 0, 0, 1)
-       ZEND_ARG_INFO(0, class_name)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_get_object_vars, 0, 1, IS_ARRAY, 0)
-       ZEND_ARG_INFO(0, obj)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_get_mangled_object_vars, 0, 0, 1)
-       ZEND_ARG_INFO(0, obj)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_get_class_methods, 0, 0, 1)
-       ZEND_ARG_INFO(0, class)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_method_exists, 0, 0, 2)
-       ZEND_ARG_INFO(0, object)
-       ZEND_ARG_INFO(0, method)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_property_exists, 0, 0, 2)
-       ZEND_ARG_INFO(0, object_or_class)
-       ZEND_ARG_INFO(0, property_name)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_class_exists, 0, 0, 1)
-       ZEND_ARG_INFO(0, classname)
-       ZEND_ARG_INFO(0, autoload)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_trait_exists, 0, 0, 1)
-       ZEND_ARG_INFO(0, traitname)
-       ZEND_ARG_INFO(0, autoload)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_function_exists, 0, 0, 1)
-       ZEND_ARG_INFO(0, function_name)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_class_alias, 0, 0, 2)
-       ZEND_ARG_INFO(0, user_class_name)
-       ZEND_ARG_INFO(0, alias_name)
-       ZEND_ARG_INFO(0, autoload)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_trigger_error, 0, 0, 1)
-       ZEND_ARG_INFO(0, message)
-       ZEND_ARG_INFO(0, error_type)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_set_error_handler, 0, 0, 1)
-       ZEND_ARG_INFO(0, error_handler)
-       ZEND_ARG_INFO(0, error_types)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_set_exception_handler, 0, 0, 1)
-       ZEND_ARG_INFO(0, exception_handler)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_get_defined_functions, 0, 0, 0)
-       ZEND_ARG_INFO(0, exclude_disabled)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_get_resource_type, 0, 0, 1)
-       ZEND_ARG_INFO(0, res)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_get_resources, 0, 0, 0)
-       ZEND_ARG_INFO(0, type)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_get_loaded_extensions, 0, 0, 0)
-       ZEND_ARG_INFO(0, zend_extensions)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_get_defined_constants, 0, 0, 0)
-       ZEND_ARG_INFO(0, categorize)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_debug_backtrace, 0, 0, 0)
-       ZEND_ARG_INFO(0, options)
-       ZEND_ARG_INFO(0, limit)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_debug_print_backtrace, 0, 0, 0)
-       ZEND_ARG_INFO(0, options)
-       ZEND_ARG_INFO(0, limit)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_extension_loaded, 0, 0, 1)
-       ZEND_ARG_INFO(0, extension_name)
-ZEND_END_ARG_INFO()
+#include "zend_builtin_functions_arginfo.h"
 
 /* }}} */
 
 static const zend_function_entry builtin_functions[] = { /* {{{ */
-       ZEND_FE(zend_version,           arginfo_zend__void)
-       ZEND_FE(func_num_args,          arginfo_zend__void)
+       ZEND_FE(zend_version,           arginfo_zend_version)
+       ZEND_FE(func_num_args,          arginfo_func_num_args)
        ZEND_FE(func_get_arg,           arginfo_func_get_arg)
-       ZEND_FE(func_get_args,          arginfo_zend__void)
+       ZEND_FE(func_get_args,          arginfo_func_get_args)
        ZEND_FE(strlen,                 arginfo_strlen)
        ZEND_FE(strcmp,                 arginfo_strcmp)
        ZEND_FE(strncmp,                arginfo_strncmp)
@@ -242,51 +103,51 @@ static const zend_function_entry builtin_functions[] = { /* {{{ */
        ZEND_FE(define,                 arginfo_define)
        ZEND_FE(defined,                arginfo_defined)
        ZEND_FE(get_class,              arginfo_get_class)
-       ZEND_FE(get_called_class,       arginfo_zend__void)
-       ZEND_FE(get_parent_class,       arginfo_get_class)
+       ZEND_FE(get_called_class,       arginfo_get_called_class)
+       ZEND_FE(get_parent_class,       arginfo_get_parent_class)
        ZEND_FE(method_exists,          arginfo_method_exists)
        ZEND_FE(property_exists,        arginfo_property_exists)
        ZEND_FE(class_exists,           arginfo_class_exists)
-       ZEND_FE(interface_exists,       arginfo_class_exists)
+       ZEND_FE(interface_exists,       arginfo_interface_exists)
        ZEND_FE(trait_exists,           arginfo_trait_exists)
        ZEND_FE(function_exists,        arginfo_function_exists)
        ZEND_FE(class_alias,            arginfo_class_alias)
-       ZEND_FE(get_included_files,     arginfo_zend__void)
-       ZEND_FALIAS(get_required_files, get_included_files,             arginfo_zend__void)
+       ZEND_FE(get_included_files,     arginfo_get_included_files)
+       ZEND_FALIAS(get_required_files, get_included_files,             arginfo_get_required_files)
        ZEND_FE(is_subclass_of,         arginfo_is_subclass_of)
-       ZEND_FE(is_a,                   arginfo_is_subclass_of)
+       ZEND_FE(is_a,                   arginfo_is_a)
        ZEND_FE(get_class_vars,         arginfo_get_class_vars)
        ZEND_FE(get_object_vars,        arginfo_get_object_vars)
        ZEND_FE(get_mangled_object_vars,        arginfo_get_mangled_object_vars)
        ZEND_FE(get_class_methods,      arginfo_get_class_methods)
        ZEND_FE(trigger_error,          arginfo_trigger_error)
-       ZEND_FALIAS(user_error,         trigger_error,          arginfo_trigger_error)
+       ZEND_FALIAS(user_error,         trigger_error,          arginfo_user_error)
        ZEND_FE(set_error_handler,              arginfo_set_error_handler)
-       ZEND_FE(restore_error_handler,          arginfo_zend__void)
+       ZEND_FE(restore_error_handler,          arginfo_restore_error_handler)
        ZEND_FE(set_exception_handler,          arginfo_set_exception_handler)
-       ZEND_FE(restore_exception_handler,      arginfo_zend__void)
-       ZEND_FE(get_declared_classes,           arginfo_zend__void)
-       ZEND_FE(get_declared_traits,            arginfo_zend__void)
-       ZEND_FE(get_declared_interfaces,        arginfo_zend__void)
+       ZEND_FE(restore_exception_handler,      arginfo_restore_exception_handler)
+       ZEND_FE(get_declared_classes,           arginfo_get_declared_classes)
+       ZEND_FE(get_declared_traits,            arginfo_get_declared_traits)
+       ZEND_FE(get_declared_interfaces,        arginfo_get_declared_interfaces)
        ZEND_FE(get_defined_functions,          arginfo_get_defined_functions)
-       ZEND_FE(get_defined_vars,               arginfo_zend__void)
+       ZEND_FE(get_defined_vars,               arginfo_get_defined_vars)
        ZEND_FE(get_resource_type,              arginfo_get_resource_type)
        ZEND_FE(get_resources,                  arginfo_get_resources)
        ZEND_FE(get_loaded_extensions,          arginfo_get_loaded_extensions)
        ZEND_FE(extension_loaded,               arginfo_extension_loaded)
-       ZEND_FE(get_extension_funcs,            arginfo_extension_loaded)
+       ZEND_FE(get_extension_funcs,            arginfo_get_extension_funcs)
        ZEND_FE(get_defined_constants,          arginfo_get_defined_constants)
        ZEND_FE(debug_backtrace,                arginfo_debug_backtrace)
        ZEND_FE(debug_print_backtrace,          arginfo_debug_print_backtrace)
 #if ZEND_DEBUG && defined(ZTS)
-       ZEND_FE(zend_thread_id,         NULL)
+       ZEND_FE(zend_thread_id,         arginfo_zend_thread_id)
 #endif
-       ZEND_FE(gc_mem_caches,      arginfo_zend__void)
-       ZEND_FE(gc_collect_cycles,      arginfo_zend__void)
-       ZEND_FE(gc_enabled,             arginfo_zend__void)
-       ZEND_FE(gc_enable,              arginfo_zend__void)
-       ZEND_FE(gc_disable,             arginfo_zend__void)
-       ZEND_FE(gc_status,              arginfo_zend__void)
+       ZEND_FE(gc_mem_caches,      arginfo_gc_mem_caches)
+       ZEND_FE(gc_collect_cycles,      arginfo_gc_collect_cycles)
+       ZEND_FE(gc_enabled,             arginfo_gc_enabled)
+       ZEND_FE(gc_enable,              arginfo_gc_enable)
+       ZEND_FE(gc_disable,             arginfo_gc_disable)
+       ZEND_FE(gc_status,              arginfo_gc_status)
        ZEND_FE_END
 };
 /* }}} */
diff --git a/Zend/zend_builtin_functions.stub.php b/Zend/zend_builtin_functions.stub.php
new file mode 100644 (file)
index 0000000..deb9ac9
--- /dev/null
@@ -0,0 +1,123 @@
+<?php
+
+function zend_version(): string {}
+
+function func_num_args(): int {}
+
+/** @return mixed */
+function func_get_arg(int $arg_num) {}
+
+/** @return array|false */
+function func_get_args() {}
+
+function strlen(string $str): int {}
+
+function strcmp(string $str1, string $str2): int {}
+
+/** @return int|false */
+function strncmp(string $str1, string $str2, int $len) {}
+
+function error_reporting($new_error_level = UNKNOWN): int {}
+
+function define(string $constant_name, $value, bool $case_insensitive = false): bool {}
+
+function defined(string $constant_name): bool {}
+
+/** @return string|false */
+function get_class(object $object = UNKNOWN) {}
+
+/** @return string|false */
+function get_called_class() {}
+
+/** @return string|false */
+function get_parent_class($object) {}
+
+function is_subclass_of($object, string $class_name, bool $allow_string = true): bool {}
+
+function is_a($object, string $class_name, bool $allow_string = false): bool {}
+
+/** @return array|false */
+function get_class_vars(string $class_name) {}
+
+function get_object_vars(object $obj): array {}
+
+function get_mangled_object_vars(object $obj): array {}
+
+function get_class_methods($class): ?array {}
+
+function method_exists($object_or_class, string $method): bool {}
+
+function property_exists($object_or_class, string $property_name): ?bool {}
+
+function class_exists(string $classname, bool $autoload = true): bool {}
+
+function interface_exists(string $classname, bool $autoload = true): bool {}
+
+function trait_exists(string $traitname, bool $autoload = true): bool {}
+
+function function_exists(string $function_name): bool {}
+
+function class_alias(string $user_class_name, string $alias_name, bool $autoload = true): bool {}
+
+function get_included_files(): array {}
+
+/** @alias get_included_files */
+function get_required_files(): array {}
+
+function trigger_error(string $message, int $error_type = E_USER_NOTICE): bool {}
+
+/** @alias trigger_error */
+function user_error(string $message, int $error_type = E_USER_NOTICE): bool {}
+
+/** @return mixed */
+function set_error_handler($error_handler, int $error_types = E_ALL) {}
+
+function restore_error_handler(): bool {}
+
+/** @return mixed */
+function set_exception_handler($exception_handler) {}
+
+function restore_exception_handler(): bool {}
+
+function get_declared_classes(): array {}
+
+function get_declared_traits(): array {}
+
+function get_declared_interfaces(): array {}
+
+function get_defined_functions(bool $exclude_disabled = false): array {}
+
+function get_defined_vars(): ?array {}
+
+function get_resource_type($res): string {}
+
+function get_resources(string $type = UNKNOWN): array {}
+
+function get_loaded_extensions(bool $zend_extensions = false): array {}
+
+function get_defined_constants(bool $categorize = false): array {}
+
+function debug_backtrace(int $options = DEBUG_BACKTRACE_PROVIDE_OBJECT, int $limit = 0): array {}
+
+function debug_print_backtrace(int $options = 0, int $limit = 0): void {}
+
+function extension_loaded(string $extension_name): bool {}
+
+/** @return array|false */
+function get_extension_funcs(string $extension_name) {}
+
+#if ZEND_DEBUG && defined(ZTS)
+function zend_thread_id(): int {}
+#endif
+
+function gc_mem_caches(): int {}
+
+function gc_collect_cycles(): int {}
+
+function gc_enabled(): bool {}
+
+function gc_enable(): void {}
+
+function gc_disable(): void {}
+
+function gc_status(): array {}
diff --git a/Zend/zend_builtin_functions_arginfo.h b/Zend/zend_builtin_functions_arginfo.h
new file mode 100644 (file)
index 0000000..005d148
--- /dev/null
@@ -0,0 +1,198 @@
+/* This is a generated file, edit the .stub.php file instead. */
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_version, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_func_num_args, 0, 0, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_func_get_arg, 0, 0, 1)
+       ZEND_ARG_TYPE_INFO(0, arg_num, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_func_get_args, 0, 0, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_strlen, 0, 1, IS_LONG, 0)
+       ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_strcmp, 0, 2, IS_LONG, 0)
+       ZEND_ARG_TYPE_INFO(0, str1, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO(0, str2, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_strncmp, 0, 0, 3)
+       ZEND_ARG_TYPE_INFO(0, str1, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO(0, str2, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO(0, len, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_error_reporting, 0, 0, IS_LONG, 0)
+       ZEND_ARG_INFO(0, new_error_level)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_define, 0, 2, _IS_BOOL, 0)
+       ZEND_ARG_TYPE_INFO(0, constant_name, IS_STRING, 0)
+       ZEND_ARG_INFO(0, value)
+       ZEND_ARG_TYPE_INFO(0, case_insensitive, _IS_BOOL, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_defined, 0, 1, _IS_BOOL, 0)
+       ZEND_ARG_TYPE_INFO(0, constant_name, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_get_class, 0, 0, 0)
+       ZEND_ARG_TYPE_INFO(0, object, IS_OBJECT, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_get_called_class arginfo_func_get_args
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_get_parent_class, 0, 0, 1)
+       ZEND_ARG_INFO(0, object)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_is_subclass_of, 0, 2, _IS_BOOL, 0)
+       ZEND_ARG_INFO(0, object)
+       ZEND_ARG_TYPE_INFO(0, class_name, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO(0, allow_string, _IS_BOOL, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_is_a arginfo_is_subclass_of
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_get_class_vars, 0, 0, 1)
+       ZEND_ARG_TYPE_INFO(0, class_name, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_get_object_vars, 0, 1, IS_ARRAY, 0)
+       ZEND_ARG_TYPE_INFO(0, obj, IS_OBJECT, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_get_mangled_object_vars arginfo_get_object_vars
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_get_class_methods, 0, 1, IS_ARRAY, 1)
+       ZEND_ARG_INFO(0, class)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_method_exists, 0, 2, _IS_BOOL, 0)
+       ZEND_ARG_INFO(0, object_or_class)
+       ZEND_ARG_TYPE_INFO(0, method, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_property_exists, 0, 2, _IS_BOOL, 1)
+       ZEND_ARG_INFO(0, object_or_class)
+       ZEND_ARG_TYPE_INFO(0, property_name, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_exists, 0, 1, _IS_BOOL, 0)
+       ZEND_ARG_TYPE_INFO(0, classname, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO(0, autoload, _IS_BOOL, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_interface_exists arginfo_class_exists
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_trait_exists, 0, 1, _IS_BOOL, 0)
+       ZEND_ARG_TYPE_INFO(0, traitname, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO(0, autoload, _IS_BOOL, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_function_exists, 0, 1, _IS_BOOL, 0)
+       ZEND_ARG_TYPE_INFO(0, function_name, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_alias, 0, 2, _IS_BOOL, 0)
+       ZEND_ARG_TYPE_INFO(0, user_class_name, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO(0, alias_name, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO(0, autoload, _IS_BOOL, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_get_included_files, 0, 0, IS_ARRAY, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_get_required_files arginfo_get_included_files
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_trigger_error, 0, 1, _IS_BOOL, 0)
+       ZEND_ARG_TYPE_INFO(0, message, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO(0, error_type, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_user_error arginfo_trigger_error
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_set_error_handler, 0, 0, 1)
+       ZEND_ARG_INFO(0, error_handler)
+       ZEND_ARG_TYPE_INFO(0, error_types, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_restore_error_handler, 0, 0, _IS_BOOL, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_set_exception_handler, 0, 0, 1)
+       ZEND_ARG_INFO(0, exception_handler)
+ZEND_END_ARG_INFO()
+
+#define arginfo_restore_exception_handler arginfo_restore_error_handler
+
+#define arginfo_get_declared_classes arginfo_get_included_files
+
+#define arginfo_get_declared_traits arginfo_get_included_files
+
+#define arginfo_get_declared_interfaces arginfo_get_included_files
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_get_defined_functions, 0, 0, IS_ARRAY, 0)
+       ZEND_ARG_TYPE_INFO(0, exclude_disabled, _IS_BOOL, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_get_defined_vars, 0, 0, IS_ARRAY, 1)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_get_resource_type, 0, 1, IS_STRING, 0)
+       ZEND_ARG_INFO(0, res)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_get_resources, 0, 0, IS_ARRAY, 0)
+       ZEND_ARG_TYPE_INFO(0, type, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_get_loaded_extensions, 0, 0, IS_ARRAY, 0)
+       ZEND_ARG_TYPE_INFO(0, zend_extensions, _IS_BOOL, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_get_defined_constants, 0, 0, IS_ARRAY, 0)
+       ZEND_ARG_TYPE_INFO(0, categorize, _IS_BOOL, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_debug_backtrace, 0, 0, IS_ARRAY, 0)
+       ZEND_ARG_TYPE_INFO(0, options, IS_LONG, 0)
+       ZEND_ARG_TYPE_INFO(0, limit, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_debug_print_backtrace, 0, 0, IS_VOID, 0)
+       ZEND_ARG_TYPE_INFO(0, options, IS_LONG, 0)
+       ZEND_ARG_TYPE_INFO(0, limit, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_extension_loaded, 0, 1, _IS_BOOL, 0)
+       ZEND_ARG_TYPE_INFO(0, extension_name, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_get_extension_funcs, 0, 0, 1)
+       ZEND_ARG_TYPE_INFO(0, extension_name, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
+#if ZEND_DEBUG && defined(ZTS)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_thread_id, 0, 0, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+#endif
+
+#define arginfo_gc_mem_caches arginfo_func_num_args
+
+#define arginfo_gc_collect_cycles arginfo_func_num_args
+
+#define arginfo_gc_enabled arginfo_restore_error_handler
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gc_enable, 0, 0, IS_VOID, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_gc_disable arginfo_gc_enable
+
+#define arginfo_gc_status arginfo_get_included_files
index 82e0d69f35e30a71103a8a5aa74057e755396de0..7ae398e314ac059271c4f5d27e5f52a620c87f6d 100644 (file)
@@ -142,6 +142,12 @@ prof-clean:
 prof-use:
        CCACHE_DISABLE=1 $(MAKE) PROF_FLAGS=-fprofile-use all
 
+%_arginfo.h: %.stub.php
+       if type php >/dev/null 2>/dev/null; then php scripts/dev/gen_stub.php $<; fi
+
+# As we don't track includes, this is just a heuristic
+%.c: %_arginfo.h
+       touch $@
 
 .PHONY: all clean install distclean test prof-gen prof-clean prof-use
 .NOEXPORT:
index 1335ce68583f08fffb9aff5e0614f91194c94c5d..aa457065d404c69fe7c37e44111e84802e765df4 100644 (file)
@@ -76,345 +76,7 @@ PHPAPI time_t php_time()
 #endif
 }
 
-/* {{{ arginfo */
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date, 0, 0, 1)
-       ZEND_ARG_INFO(0, format)
-       ZEND_ARG_INFO(0, timestamp)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_gmdate, 0, 0, 1)
-       ZEND_ARG_INFO(0, format)
-       ZEND_ARG_INFO(0, timestamp)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_idate, 0, 0, 1)
-       ZEND_ARG_INFO(0, format)
-       ZEND_ARG_INFO(0, timestamp)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_strtotime, 0, 0, 1)
-       ZEND_ARG_INFO(0, time)
-       ZEND_ARG_INFO(0, now)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_mktime, 0, 0, 1)
-       ZEND_ARG_INFO(0, hour)
-       ZEND_ARG_INFO(0, min)
-       ZEND_ARG_INFO(0, sec)
-       ZEND_ARG_INFO(0, mon)
-       ZEND_ARG_INFO(0, day)
-       ZEND_ARG_INFO(0, year)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_gmmktime, 0, 0, 1)
-       ZEND_ARG_INFO(0, hour)
-       ZEND_ARG_INFO(0, min)
-       ZEND_ARG_INFO(0, sec)
-       ZEND_ARG_INFO(0, mon)
-       ZEND_ARG_INFO(0, day)
-       ZEND_ARG_INFO(0, year)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_checkdate, 0)
-       ZEND_ARG_INFO(0, month)
-       ZEND_ARG_INFO(0, day)
-       ZEND_ARG_INFO(0, year)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_strftime, 0, 0, 1)
-       ZEND_ARG_INFO(0, format)
-       ZEND_ARG_INFO(0, timestamp)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_gmstrftime, 0, 0, 1)
-       ZEND_ARG_INFO(0, format)
-       ZEND_ARG_INFO(0, timestamp)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_time, 0)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_localtime, 0, 0, 0)
-       ZEND_ARG_INFO(0, timestamp)
-       ZEND_ARG_INFO(0, associative_array)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_getdate, 0, 0, 0)
-       ZEND_ARG_INFO(0, timestamp)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_date_default_timezone_set, 0)
-       ZEND_ARG_INFO(0, timezone_identifier)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_date_default_timezone_get, 0)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_sunrise, 0, 0, 1)
-       ZEND_ARG_INFO(0, time)
-       ZEND_ARG_INFO(0, format)
-       ZEND_ARG_INFO(0, latitude)
-       ZEND_ARG_INFO(0, longitude)
-       ZEND_ARG_INFO(0, zenith)
-       ZEND_ARG_INFO(0, gmt_offset)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_sunset, 0, 0, 1)
-       ZEND_ARG_INFO(0, time)
-       ZEND_ARG_INFO(0, format)
-       ZEND_ARG_INFO(0, latitude)
-       ZEND_ARG_INFO(0, longitude)
-       ZEND_ARG_INFO(0, zenith)
-       ZEND_ARG_INFO(0, gmt_offset)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_date_sun_info, 0)
-       ZEND_ARG_INFO(0, time)
-       ZEND_ARG_INFO(0, latitude)
-       ZEND_ARG_INFO(0, longitude)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_create, 0, 0, 0)
-       ZEND_ARG_INFO(0, time)
-       ZEND_ARG_INFO(0, timezone)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_create_from_format, 0, 0, 2)
-       ZEND_ARG_INFO(0, format)
-       ZEND_ARG_INFO(0, time)
-       ZEND_ARG_OBJ_INFO(0, object, DateTimeZone, 1)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_parse, 0, 0, 1)
-       ZEND_ARG_INFO(0, date)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_parse_from_format, 0, 0, 2)
-       ZEND_ARG_INFO(0, format)
-       ZEND_ARG_INFO(0, date)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_date_get_last_errors, 0)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_format, 0, 0, 2)
-       ZEND_ARG_INFO(0, object)
-       ZEND_ARG_INFO(0, format)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_method_format, 0, 0, 1)
-       ZEND_ARG_INFO(0, format)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_modify, 0, 0, 2)
-       ZEND_ARG_INFO(0, object)
-       ZEND_ARG_INFO(0, modify)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_method_modify, 0, 0, 1)
-       ZEND_ARG_INFO(0, modify)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_add, 0, 0, 2)
-       ZEND_ARG_INFO(0, object)
-       ZEND_ARG_INFO(0, interval)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_method_add, 0, 0, 1)
-       ZEND_ARG_INFO(0, interval)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_sub, 0, 0, 2)
-       ZEND_ARG_INFO(0, object)
-       ZEND_ARG_INFO(0, interval)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_method_sub, 0, 0, 1)
-       ZEND_ARG_INFO(0, interval)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_timezone_get, 0, 0, 1)
-       ZEND_ARG_INFO(0, object)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_date_method_timezone_get, 0)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_timezone_set, 0, 0, 2)
-       ZEND_ARG_INFO(0, object)
-       ZEND_ARG_INFO(0, timezone)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_method_timezone_set, 0, 0, 1)
-       ZEND_ARG_INFO(0, timezone)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_offset_get, 0, 0, 1)
-       ZEND_ARG_INFO(0, object)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_date_method_offset_get, 0)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_diff, 0, 0, 2)
-       ZEND_ARG_INFO(0, object)
-       ZEND_ARG_INFO(0, object2)
-       ZEND_ARG_INFO(0, absolute)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_method_diff, 0, 0, 1)
-       ZEND_ARG_INFO(0, object)
-       ZEND_ARG_INFO(0, absolute)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_time_set, 0, 0, 3)
-       ZEND_ARG_INFO(0, object)
-       ZEND_ARG_INFO(0, hour)
-       ZEND_ARG_INFO(0, minute)
-       ZEND_ARG_INFO(0, second)
-       ZEND_ARG_INFO(0, microseconds)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_method_time_set, 0, 0, 2)
-       ZEND_ARG_INFO(0, hour)
-       ZEND_ARG_INFO(0, minute)
-       ZEND_ARG_INFO(0, second)
-       ZEND_ARG_INFO(0, microseconds)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_date_set, 0, 0, 4)
-       ZEND_ARG_INFO(0, object)
-       ZEND_ARG_INFO(0, year)
-       ZEND_ARG_INFO(0, month)
-       ZEND_ARG_INFO(0, day)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_method_date_set, 0, 0, 3)
-       ZEND_ARG_INFO(0, year)
-       ZEND_ARG_INFO(0, month)
-       ZEND_ARG_INFO(0, day)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_isodate_set, 0, 0, 3)
-       ZEND_ARG_INFO(0, object)
-       ZEND_ARG_INFO(0, year)
-       ZEND_ARG_INFO(0, week)
-       ZEND_ARG_INFO(0, day)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_method_isodate_set, 0, 0, 2)
-       ZEND_ARG_INFO(0, year)
-       ZEND_ARG_INFO(0, week)
-       ZEND_ARG_INFO(0, day)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_timestamp_set, 0, 0, 2)
-       ZEND_ARG_INFO(0, object)
-       ZEND_ARG_INFO(0, unixtimestamp)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_method_timestamp_set, 0, 0, 1)
-       ZEND_ARG_INFO(0, unixtimestamp)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_timestamp_get, 0, 0, 1)
-       ZEND_ARG_INFO(0, object)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_date_method_timestamp_get, 0)
-ZEND_END_ARG_INFO()
-
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_method_create_from_immutable, 0, 0, 1)
-       ZEND_ARG_INFO(0, DateTimeImmutable)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_method_create_from_mutable, 0, 0, 1)
-       ZEND_ARG_INFO(0, DateTime)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_open, 0, 0, 1)
-       ZEND_ARG_INFO(0, timezone)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_name_get, 0, 0, 1)
-       ZEND_ARG_INFO(0, object)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_timezone_method_name_get, 0)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_name_from_abbr, 0, 0, 1)
-       ZEND_ARG_INFO(0, abbr)
-       ZEND_ARG_INFO(0, gmtoffset)
-       ZEND_ARG_INFO(0, isdst)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_offset_get, 0, 0, 2)
-       ZEND_ARG_OBJ_INFO(0, object, DateTimeZone, 0)
-       ZEND_ARG_OBJ_INFO(0, datetime, DateTimeInterface, 0)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_method_offset_get, 0, 0, 1)
-       ZEND_ARG_INFO(0, object)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_transitions_get, 0, 0, 1)
-       ZEND_ARG_INFO(0, object)
-       ZEND_ARG_INFO(0, timestamp_begin)
-       ZEND_ARG_INFO(0, timestamp_end)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_method_transitions_get, 0, 0, 0)
-       ZEND_ARG_INFO(0, timestamp_begin)
-       ZEND_ARG_INFO(0, timestamp_end)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_location_get, 0, 0, 1)
-       ZEND_ARG_INFO(0, object)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_timezone_method_location_get, 0)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_identifiers_list, 0, 0, 0)
-       ZEND_ARG_INFO(0, what)
-       ZEND_ARG_INFO(0, country)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_timezone_abbreviations_list, 0)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_timezone_version_get, 0)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_interval_create_from_date_string, 0, 0, 1)
-       ZEND_ARG_INFO(0, time)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_interval_format, 0, 0, 2)
-       ZEND_ARG_INFO(0, object)
-       ZEND_ARG_INFO(0, format)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO(arginfo_date_method_interval_format, 0)
-       ZEND_ARG_INFO(0, format)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_period_construct, 0, 0, 3)
-       ZEND_ARG_INFO(0, start)
-       ZEND_ARG_INFO(0, interval)
-       ZEND_ARG_INFO(0, end)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_set_state, 0, 0, 1)
-       ZEND_ARG_ARRAY_INFO(0, array, 0)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_interval_construct, 0, 0, 1)
-       ZEND_ARG_INFO(0, interval_spec)
-ZEND_END_ARG_INFO()
-/* }}} */
+#include "php_date_arginfo.h"
 
 /* {{{ Function table */
 static const zend_function_entry date_functions[] = {
@@ -479,91 +141,91 @@ static const zend_function_entry date_functions[] = {
 };
 
 static const zend_function_entry date_funcs_interface[] = {
-       PHP_ABSTRACT_ME(DateTimeInterface, format, arginfo_date_method_format)
-       PHP_ABSTRACT_ME(DateTimeInterface, getTimezone, arginfo_date_method_timezone_get)
-       PHP_ABSTRACT_ME(DateTimeInterface, getOffset, arginfo_date_method_offset_get)
-       PHP_ABSTRACT_ME(DateTimeInterface, getTimestamp, arginfo_date_method_timestamp_get)
-       PHP_ABSTRACT_ME(DateTimeInterface, diff, arginfo_date_method_diff)
-       PHP_ABSTRACT_ME(DateTimeInterface, __wakeup, NULL)
+       PHP_ABSTRACT_ME(DateTimeInterface, format, arginfo_DateTimeInterface_format)
+       PHP_ABSTRACT_ME(DateTimeInterface, getTimezone, arginfo_DateTimeInterface_getTimezone)
+       PHP_ABSTRACT_ME(DateTimeInterface, getOffset, arginfo_DateTimeInterface_getOffset)
+       PHP_ABSTRACT_ME(DateTimeInterface, getTimestamp, arginfo_DateTimeInterface_getTimestamp)
+       PHP_ABSTRACT_ME(DateTimeInterface, diff, arginfo_DateTimeInterface_diff)
+       PHP_ABSTRACT_ME(DateTimeInterface, __wakeup, arginfo_DateTimeInterface___wakeup)
        PHP_FE_END
 };
 
 static const zend_function_entry date_funcs_date[] = {
-       PHP_ME(DateTime,                        __construct,            arginfo_date_create, ZEND_ACC_PUBLIC)
-       PHP_ME(DateTime,                        __wakeup,                       NULL, ZEND_ACC_PUBLIC)
-       PHP_ME(DateTime,                        __set_state,            arginfo_date_set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
-       PHP_ME(DateTime,                        createFromImmutable,    arginfo_date_method_create_from_immutable, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
-       PHP_ME_MAPPING(createFromFormat, date_create_from_format,       arginfo_date_create_from_format, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
-       PHP_ME_MAPPING(getLastErrors, date_get_last_errors,     arginfo_date_get_last_errors, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
-       PHP_ME_MAPPING(format,          date_format,            arginfo_date_method_format, 0)
-       PHP_ME_MAPPING(modify,          date_modify,            arginfo_date_method_modify, 0)
-       PHP_ME_MAPPING(add,                     date_add,                       arginfo_date_method_add, 0)
-       PHP_ME_MAPPING(sub,                     date_sub,                       arginfo_date_method_sub, 0)
-       PHP_ME_MAPPING(getTimezone, date_timezone_get,  arginfo_date_method_timezone_get, 0)
-       PHP_ME_MAPPING(setTimezone, date_timezone_set,  arginfo_date_method_timezone_set, 0)
-       PHP_ME_MAPPING(getOffset,       date_offset_get,        arginfo_date_method_offset_get, 0)
-       PHP_ME_MAPPING(setTime,         date_time_set,          arginfo_date_method_time_set, 0)
-       PHP_ME_MAPPING(setDate,         date_date_set,          arginfo_date_method_date_set, 0)
-       PHP_ME_MAPPING(setISODate,      date_isodate_set,       arginfo_date_method_isodate_set, 0)
-       PHP_ME_MAPPING(setTimestamp,    date_timestamp_set, arginfo_date_method_timestamp_set, 0)
-       PHP_ME_MAPPING(getTimestamp,    date_timestamp_get, arginfo_date_method_timestamp_get, 0)
-       PHP_ME_MAPPING(diff,                    date_diff, arginfo_date_method_diff, 0)
+       PHP_ME(DateTime,                        __construct,            arginfo_DateTime___construct, ZEND_ACC_PUBLIC)
+       PHP_ME(DateTime,                        __wakeup,                       arginfo_DateTimeInterface___wakeup, ZEND_ACC_PUBLIC)
+       PHP_ME(DateTime,                        __set_state,            arginfo_DateTime___set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
+       PHP_ME(DateTime,                        createFromImmutable,    arginfo_DateTime_createFromImmutable, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
+       PHP_ME_MAPPING(createFromFormat, date_create_from_format,       arginfo_DateTime_createFromFormat, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
+       PHP_ME_MAPPING(getLastErrors, date_get_last_errors,     arginfo_DateTime_getLastErrors, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
+       PHP_ME_MAPPING(format,          date_format,            arginfo_DateTimeInterface_format, 0)
+       PHP_ME_MAPPING(modify,          date_modify,            arginfo_DateTime_modify, 0)
+       PHP_ME_MAPPING(add,                     date_add,                       arginfo_DateTime_add, 0)
+       PHP_ME_MAPPING(sub,                     date_sub,                       arginfo_DateTime_sub, 0)
+       PHP_ME_MAPPING(getTimezone, date_timezone_get,  arginfo_DateTimeInterface_getTimezone, 0)
+       PHP_ME_MAPPING(setTimezone, date_timezone_set,  arginfo_DateTime_setTimezone, 0)
+       PHP_ME_MAPPING(getOffset,       date_offset_get,        arginfo_DateTimeInterface_getOffset, 0)
+       PHP_ME_MAPPING(setTime,         date_time_set,          arginfo_DateTime_setTime, 0)
+       PHP_ME_MAPPING(setDate,         date_date_set,          arginfo_DateTime_setDate, 0)
+       PHP_ME_MAPPING(setISODate,      date_isodate_set,       arginfo_DateTime_setISODate, 0)
+       PHP_ME_MAPPING(setTimestamp,    date_timestamp_set, arginfo_DateTime_setTimestamp, 0)
+       PHP_ME_MAPPING(getTimestamp,    date_timestamp_get, arginfo_DateTimeInterface_getTimestamp, 0)
+       PHP_ME_MAPPING(diff,                    date_diff, arginfo_DateTimeInterface_diff, 0)
        PHP_FE_END
 };
 
 static const zend_function_entry date_funcs_immutable[] = {
-       PHP_ME(DateTimeImmutable, __construct,   arginfo_date_create, ZEND_ACC_PUBLIC)
-       PHP_ME(DateTime, __wakeup,       NULL, ZEND_ACC_PUBLIC)
-       PHP_ME(DateTimeImmutable, __set_state,   arginfo_date_set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
+       PHP_ME(DateTimeImmutable, __construct,   arginfo_DateTimeImmutable___construct, ZEND_ACC_PUBLIC)
+       PHP_ME(DateTime, __wakeup,       arginfo_DateTimeInterface___wakeup, ZEND_ACC_PUBLIC)
+       PHP_ME(DateTimeImmutable, __set_state,   arginfo_DateTimeImmutable___set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
        PHP_ME_MAPPING(createFromFormat, date_create_immutable_from_format, arginfo_date_create_from_format, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
        PHP_ME_MAPPING(getLastErrors,    date_get_last_errors,    arginfo_date_get_last_errors, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
-       PHP_ME_MAPPING(format,           date_format,             arginfo_date_method_format, 0)
-       PHP_ME_MAPPING(getTimezone, date_timezone_get,  arginfo_date_method_timezone_get, 0)
-       PHP_ME_MAPPING(getOffset,       date_offset_get,        arginfo_date_method_offset_get, 0)
-       PHP_ME_MAPPING(getTimestamp,    date_timestamp_get, arginfo_date_method_timestamp_get, 0)
-       PHP_ME_MAPPING(diff,                    date_diff, arginfo_date_method_diff, 0)
-       PHP_ME(DateTimeImmutable, modify,        arginfo_date_method_modify, 0)
-       PHP_ME(DateTimeImmutable, add,           arginfo_date_method_add, 0)
-       PHP_ME(DateTimeImmutable, sub,           arginfo_date_method_sub, 0)
-       PHP_ME(DateTimeImmutable, setTimezone,   arginfo_date_method_timezone_set, 0)
-       PHP_ME(DateTimeImmutable, setTime,       arginfo_date_method_time_set, 0)
-       PHP_ME(DateTimeImmutable, setDate,       arginfo_date_method_date_set, 0)
-       PHP_ME(DateTimeImmutable, setISODate,    arginfo_date_method_isodate_set, 0)
-       PHP_ME(DateTimeImmutable, setTimestamp,  arginfo_date_method_timestamp_set, 0)
-       PHP_ME(DateTimeImmutable, createFromMutable, arginfo_date_method_create_from_mutable, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
+       PHP_ME_MAPPING(format,           date_format,             arginfo_DateTimeInterface_format, 0)
+       PHP_ME_MAPPING(getTimezone, date_timezone_get,  arginfo_DateTimeInterface_getTimezone, 0)
+       PHP_ME_MAPPING(getOffset,       date_offset_get,        arginfo_DateTimeInterface_getOffset, 0)
+       PHP_ME_MAPPING(getTimestamp,    date_timestamp_get, arginfo_DateTimeInterface_getTimestamp, 0)
+       PHP_ME_MAPPING(diff,                    date_diff, arginfo_DateTimeInterface_diff, 0)
+       PHP_ME(DateTimeImmutable, modify,        arginfo_DateTimeImmutable_modify, 0)
+       PHP_ME(DateTimeImmutable, add,           arginfo_DateTimeImmutable_add, 0)
+       PHP_ME(DateTimeImmutable, sub,           arginfo_DateTimeImmutable_sub, 0)
+       PHP_ME(DateTimeImmutable, setTimezone,   arginfo_DateTimeImmutable_setTimezone, 0)
+       PHP_ME(DateTimeImmutable, setTime,       arginfo_DateTimeImmutable_setTime, 0)
+       PHP_ME(DateTimeImmutable, setDate,       arginfo_DateTimeImmutable_setDate, 0)
+       PHP_ME(DateTimeImmutable, setISODate,    arginfo_DateTimeImmutable_setISODate, 0)
+       PHP_ME(DateTimeImmutable, setTimestamp,  arginfo_DateTimeImmutable_setTimestamp, 0)
+       PHP_ME(DateTimeImmutable, createFromMutable, arginfo_DateTimeImmutable_createFromMutable, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
        PHP_FE_END
 };
 
 static const zend_function_entry date_funcs_timezone[] = {
-       PHP_ME(DateTimeZone,              __construct,                 arginfo_timezone_open, ZEND_ACC_PUBLIC)
-       PHP_ME(DateTimeZone,              __wakeup,                    NULL, ZEND_ACC_PUBLIC)
-       PHP_ME(DateTimeZone,              __set_state,                 arginfo_date_set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
-       PHP_ME_MAPPING(getName,           timezone_name_get,           arginfo_timezone_method_name_get, 0)
-       PHP_ME_MAPPING(getOffset,         timezone_offset_get,         arginfo_timezone_method_offset_get, 0)
-       PHP_ME_MAPPING(getTransitions,    timezone_transitions_get,    arginfo_timezone_method_transitions_get, 0)
-       PHP_ME_MAPPING(getLocation,       timezone_location_get,       arginfo_timezone_method_location_get, 0)
-       PHP_ME_MAPPING(listAbbreviations, timezone_abbreviations_list, arginfo_timezone_abbreviations_list, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
-       PHP_ME_MAPPING(listIdentifiers,   timezone_identifiers_list,   arginfo_timezone_identifiers_list, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
+       PHP_ME(DateTimeZone,              __construct,                 arginfo_DateTimeZone___construct, ZEND_ACC_PUBLIC)
+       PHP_ME(DateTimeZone,              __wakeup,                    arginfo_DateTimeZone___wakeup, ZEND_ACC_PUBLIC)
+       PHP_ME(DateTimeZone,              __set_state,                 arginfo_DateTimeZone___set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
+       PHP_ME_MAPPING(getName,           timezone_name_get,           arginfo_DateTimeZone_getName, 0)
+       PHP_ME_MAPPING(getOffset,         timezone_offset_get,         arginfo_DateTimeZone_getOffset, 0)
+       PHP_ME_MAPPING(getTransitions,    timezone_transitions_get,    arginfo_DateTimeZone_getTransitions, 0)
+       PHP_ME_MAPPING(getLocation,       timezone_location_get,       arginfo_DateTimeZone_getLocation, 0)
+       PHP_ME_MAPPING(listAbbreviations, timezone_abbreviations_list, arginfo_DateTimeZone_listAbbreviations, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
+       PHP_ME_MAPPING(listIdentifiers,   timezone_identifiers_list,   arginfo_DateTimeZone_listIdentifiers, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
        PHP_FE_END
 };
 
 static const zend_function_entry date_funcs_interval[] = {
-       PHP_ME(DateInterval,              __construct,                 arginfo_date_interval_construct, ZEND_ACC_PUBLIC)
-       PHP_ME(DateInterval,              __wakeup,                    NULL, ZEND_ACC_PUBLIC)
-       PHP_ME(DateInterval,              __set_state,                 arginfo_date_set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
-       PHP_ME_MAPPING(format,            date_interval_format,        arginfo_date_method_interval_format, 0)
-       PHP_ME_MAPPING(createFromDateString, date_interval_create_from_date_string,     arginfo_date_interval_create_from_date_string, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
+       PHP_ME(DateInterval,              __construct,                 arginfo_DateInterval___construct, ZEND_ACC_PUBLIC)
+       PHP_ME(DateInterval,              __wakeup,                    arginfo_DateInterval___wakeup, ZEND_ACC_PUBLIC)
+       PHP_ME(DateInterval,              __set_state,                 arginfo_DateInterval___set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
+       PHP_ME_MAPPING(format,            date_interval_format,        arginfo_DateInterval_format, 0)
+       PHP_ME_MAPPING(createFromDateString, date_interval_create_from_date_string,     arginfo_DateInterval_createFromDateString, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
        PHP_FE_END
 };
 
 static const zend_function_entry date_funcs_period[] = {
-       PHP_ME(DatePeriod,                __construct,                 arginfo_date_period_construct, ZEND_ACC_PUBLIC)
-       PHP_ME(DatePeriod,                __wakeup,                    NULL, ZEND_ACC_PUBLIC)
-       PHP_ME(DatePeriod,                __set_state,                 arginfo_date_set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
-       PHP_ME(DatePeriod,                getStartDate,                NULL, ZEND_ACC_PUBLIC)
-       PHP_ME(DatePeriod,                getEndDate,                  NULL, ZEND_ACC_PUBLIC)
-       PHP_ME(DatePeriod,                getDateInterval,             NULL, ZEND_ACC_PUBLIC)
-       PHP_ME(DatePeriod,                getRecurrences,              NULL, ZEND_ACC_PUBLIC)
+       PHP_ME(DatePeriod,                __construct,                 arginfo_DatePeriod___construct, ZEND_ACC_PUBLIC)
+       PHP_ME(DatePeriod,                __wakeup,                    arginfo_DatePeriod___wakeup, ZEND_ACC_PUBLIC)
+       PHP_ME(DatePeriod,                __set_state,                 arginfo_DatePeriod___set_state, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
+       PHP_ME(DatePeriod,                getStartDate,                arginfo_DatePeriod_getStartDate, ZEND_ACC_PUBLIC)
+       PHP_ME(DatePeriod,                getEndDate,                  arginfo_DatePeriod_getEndDate, ZEND_ACC_PUBLIC)
+       PHP_ME(DatePeriod,                getDateInterval,             arginfo_DatePeriod_getDateInterval, ZEND_ACC_PUBLIC)
+       PHP_ME(DatePeriod,                getRecurrences,              arginfo_DatePeriod_getRecurrences, ZEND_ACC_PUBLIC)
        PHP_FE_END
 };
 
@@ -4647,7 +4309,7 @@ PHP_METHOD(DatePeriod, getStartDate)
 
        dpobj = Z_PHPPERIOD_P(ZEND_THIS);
 
-        php_date_instantiate(dpobj->start_ce, return_value);
+       php_date_instantiate(dpobj->start_ce, return_value);
        dateobj = Z_PHPDATE_P(return_value);
        dateobj->time = timelib_time_ctor();
        *dateobj->time = *dpobj->start;
@@ -4699,9 +4361,9 @@ PHP_METHOD(DatePeriod, getDateInterval)
        php_period_obj   *dpobj;
        php_interval_obj *diobj;
 
-        if (zend_parse_parameters_none() == FAILURE) {
-                return;
-        }
+       if (zend_parse_parameters_none() == FAILURE) {
+               return;
+       }
 
        dpobj = Z_PHPPERIOD_P(ZEND_THIS);
 
@@ -4720,13 +4382,13 @@ PHP_METHOD(DatePeriod, getRecurrences)
        php_period_obj   *dpobj;
 
        if (zend_parse_parameters_none() == FAILURE) {
-                       return;
+               return;
        }
 
        dpobj = Z_PHPPERIOD_P(ZEND_THIS);
 
        if (0 == dpobj->recurrences - dpobj->include_start_date) {
-                       return;
+               return;
        }
 
        RETURN_LONG(dpobj->recurrences - dpobj->include_start_date);
@@ -4790,7 +4452,7 @@ PHP_FUNCTION(timezone_identifiers_list)
 }
 /* }}} */
 
-/* {{{ proto array timezone_version_get()
+/* {{{ proto string timezone_version_get()
    Returns the Olson database version number.
 */
 PHP_FUNCTION(timezone_version_get)
diff --git a/ext/date/php_date.stub.php b/ext/date/php_date.stub.php
new file mode 100644 (file)
index 0000000..1d448b9
--- /dev/null
@@ -0,0 +1,310 @@
+<?php
+
+/* TODO: Convert "uninitialized" into an exception. This will remove many
+ * possibilities for false return values in here. */
+
+/** @return int|false */
+function strtotime(string $time, int $now = UNKNOWN) {}
+
+function date(string $format, int $timestamp = UNKNOWN): string {}
+
+/** @return int|false */
+function idate(string $format, int $timestamp = UNKNOWN) {}
+
+function gmdate(string $format, int $timestamp = UNKNOWN): string {}
+
+/** @return int|false */
+function mktime(
+    int $hour, int $min = UNKNOWN, int $sec = UNKNOWN,
+    int $mon = UNKNOWN, int $day = UNKNOWN, int $year = UNKNOWN) {}
+
+/** @return int|false */
+function gmmktime(
+    int $hour, int $min = UNKNOWN, int $sec = UNKNOWN,
+    int $mon = UNKNOWN, int $day = UNKNOWN, int $year = UNKNOWN) {}
+
+function checkdate(int $m, int $d, int $y): bool {}
+
+/** @return string|false */
+function strftime(string $format, int $timestamp = UNKNOWN) {}
+
+/** @return string|false */
+function gmstrftime(string $format, int $timestamp = UNKNOWN) {}
+
+function time(): int {}
+
+function localtime(int $timestamp = UNKNOWN, bool $associative = false): array {}
+
+function getdate(int $timestamp = UNKNOWN): array {}
+
+/** @return DateTime|false */
+function date_create(string $time, ?DateTimeZone $timezone = null) {}
+
+/** @return DateTime|false */
+function date_create_immutable(string $time, ?DateTimeZone $timezone = null) {}
+
+/** @return DateTime|false */
+function date_create_from_format(string $format, string $time, ?DateTimeZone $timezone = null) {}
+
+/** @return DateTimeImmutable|false */
+function date_create_immutable_from_format(
+    string $format, string $time, ?DateTimeZone $timezone = null) {}
+
+function date_parse(string $date): array {}
+
+function date_parse_from_format(string $format, string $date): array {}
+
+/** @return array|false */
+function date_get_last_errors() {}
+
+/** @return string|false */
+function date_format(DateTimeInterface $object, string $format) {}
+
+/** @return DateTime|false */
+function date_modify(DateTime $object, string $modify) {}
+
+/** @return DateTime|false */
+function date_add(DateTime $object, DateInterval $interval) {}
+
+/** @return DateTime|false */
+function date_sub(DateTime $object, DateInterval $interval) {}
+
+/** @return DateTimeZone|false */
+function date_timezone_get(DateTimeInterface $object) {}
+
+/** @return DateTime|false */
+function date_timezone_set(DateTimeInterface $object, DateTimeZone $timezone) {}
+
+/** @return int|false */
+function date_offset_get(DateTimeInterface $object) {}
+
+/** @return DateInterval|false */
+function date_diff(DateTimeInterface $object, DateTimeInterface $object2, bool $absolute = false) {}
+
+/** @return DateTime|false */
+function date_time_set(
+    DateTime $object, int $hour, int $minute, int $second = 0, int $microseconds = 0) {}
+
+/** @return DateTime|false */
+function date_date_set(DateTime $object, int $year, int $month, int $day) {}
+
+/** @return DateTime|false */
+function date_isodate_set(DateTime $object, int $year, int $week, int $day = 1) {}
+
+/** @return DateTime|false */
+function date_timestamp_set(DateTime $object, int $timestamp) {}
+
+/** @return int|false */
+function date_timestamp_get(DateTimeInterface $object) {}
+
+/** @return DateTimeZone|false */
+function timezone_open(string $timezone) {}
+
+/** @return string|false */
+function timezone_name_get(DateTimeZone $object) {}
+
+/** @return string|false */
+function timezone_name_from_abbr(string $abbr, int $gmtoffset = -1, int $isdst = -1) {}
+
+/** @return int|false */
+function timezone_offset_get(DateTimeZone $object, DateTimeInterface $datetime) {}
+
+/** @return array|false */
+function timezone_transitions_get(
+    DateTimeZone $object, int $timestamp_begin = PHP_INT_MIN, int $timestamp_end = PHP_INT_MAX) {}
+
+/** @return array|false */
+function timezone_location_get(DateTimeZone $object) {}
+
+/** @return array|false */
+function timezone_identifiers_list(int $what = DateTimeZone::ALL, ?string $country = null) {}
+
+function timezone_abbreviations_list(): array {}
+
+function timezone_version_get(): string {}
+
+/** @return DateInterval|false */
+function date_interval_create_from_date_string(string $time) {}
+
+/** @return string|false */
+function date_interval_format(DateInterval $object, string $format) {}
+
+function date_default_timezone_set(string $timezone_identifier): bool {}
+
+function date_default_timezone_get(): string {}
+
+/** @return string|int|float|false */
+function date_sunrise(
+    int $time, int $retformat = SUNFUNCS_RET_STRING,
+    float $latitude = UNKNOWN, float $longitude = UNKNOWN, float $zenith = UNKNOWN,
+    float $gmt_offset = 0) {}
+
+/** @return string|int|float|false */
+function date_sunset(
+    int $time, int $retformat = SUNFUNCS_RET_STRING,
+    float $latitude = UNKNOWN, float $longitude = UNKNOWN, float $zenith = UNKNOWN,
+    float $gmt_offset = 0) {}
+
+function date_sun_info(int $time, float $latitude, float $longitude): array {}
+
+// NB: Adding return types to methods is a BC break!
+// For now only using @return annotations here.
+
+interface DateTimeInterface {
+    /** @return string */
+    public function format(string $format);
+
+    /** @return DateTimeZone|false */
+    public function getTimezone();
+
+    /** @return int|false */
+    public function getOffset();
+
+    /** @return int|false */
+    public function getTimestamp();
+
+    /** @return DateInterval|false */
+    public function diff(DateTimeInterface $object, bool $absolute = false);
+
+    public function __wakeup();
+}
+
+class DateTime implements DateTimeInterface {
+    public function __construct(string $time, ?DateTimeZone $timezone = null);
+
+    /** @return DateTime */
+    public static function __set_state(array $array);
+
+    /** @return DateTime */
+    public static function createFromImmutable(DateTimeImmutable $object);
+
+    /** @return DateTime|false */
+    public static function createFromFormat(
+        string $format, string $time, ?DateTimeZone $timezone = null);
+
+    /** @return array|false */
+    public static function getLastErrors();
+
+    /** @return DateTime|false */
+    public function modify(string $modify);
+
+    /** @return DateTime|false */
+    public function add(DateInterval $interval);
+
+    /** @return DateTime|false */
+    public function sub(DateInterval $interval);
+
+    /** @return DateTime|false */
+    public function setTimezone(DateTimeZone $timezone);
+
+    /** @return DateTime|false */
+    public function setTime(int $hour, int $minute, int $second = 0, int $microseconds = 0);
+
+    /** @return DateTime|false */
+    public function setDate(int $year, int $month, int $day);
+
+    /** @return DateTime|false */
+    public function setISODate(int $year, int $week, int $day = 1);
+
+    /** @return DateTime|false */
+    public function setTimestamp(int $timestampt);
+}
+
+class DateTimeImmutable implements DateTimeInterface {
+    public function __construct(string $time, ?DateTimeZone $timezone = null);
+
+    /** @return DateTimeZone */
+    public static function __set_state();
+
+    /** @return DateTimeImmutable */
+    public static function createFromMutable(DateTime $object);
+
+    /** @return DateTimeImmutable|false */
+    public function modify(string $modify);
+
+    /** @return DateTimeImmutable|false */
+    public function add(DateInterval $interval);
+
+    /** @return DateTimeImmutable|false */
+    public function sub(DateInterval $interval);
+
+    /** @return DateTimeImmutable|false */
+    public function setTimezone(DateTimeZone $timezone);
+
+    /** @return DateTimeImmutable|false */
+    public function setTime(int $hour, int $minute, int $second = 0, int $microseconds = 0);
+
+    /** @return DateTimeImmutable|false */
+    public function setDate(int $year, int $month, int $day);
+
+    /** @return DateTimeImmutable|false */
+    public function setISODate(int $year, int $week, int $day = 1);
+
+    /** @return DateTimeImmutable|false */
+    public function setTimestamp(int $timestampt);
+}
+
+class DateTimeZone {
+    public function __construct(string $timezone);
+
+    /** @return string|false */
+    public function getName();
+
+    /** @return int|false */
+    public function getOffset(DateTimeInterface $datetime);
+
+    /** @return array|false */
+    public function getTransitions(
+        int $timestamp_begin = PHP_INT_MIN, int $timestamp_end = PHP_INT_MAX);
+
+    /** @return array|false */
+    public function getLocation();
+
+    /** @return array */
+    public static function listAbbreviations();
+
+    /** @return array|false */
+    public static function listIdentifiers(int $what = DateTimeZone::ALL, ?string $country = null);
+
+    public function __wakeup();
+
+    /** @return DateTimeZone */
+    public static function __set_state();
+}
+
+class DateInterval {
+    public function __construct(string $interval_spec);
+
+    /** @return DateInterval|false */
+    public static function createFromDateString(string $time);
+
+    /** @return string|false */
+    public function format(string $format);
+
+    public function __wakeup();
+
+    /** @return DateInterval */
+    public static function __set_state(array $array);
+}
+
+class DatePeriod implements Traversable {
+    /* Has an overloaded signature */
+    public function __construct($start, $interval = UNKNOWN, $end = UNKNOWN);
+
+    /** @return DateTimeInterface */
+    public function getStartDate();
+
+    /** @return DateTimeInterface|null */
+    public function getEndDate();
+
+    /** @return DateInterval */
+    public function getDateInterval();
+
+    /** @return int|null */
+    public function getRecurrences();
+
+    public function __wakeup();
+
+    /** @return DatePeriod */
+    public static function __set_state(array $array);
+}
diff --git a/ext/date/php_date_arginfo.h b/ext/date/php_date_arginfo.h
new file mode 100644 (file)
index 0000000..7038143
--- /dev/null
@@ -0,0 +1,356 @@
+/* This is a generated file, edit the .stub.php file instead. */
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_strtotime, 0, 0, 1)
+       ZEND_ARG_TYPE_INFO(0, time, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO(0, now, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_date, 0, 1, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO(0, format, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO(0, timestamp, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_idate, 0, 0, 1)
+       ZEND_ARG_TYPE_INFO(0, format, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO(0, timestamp, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_gmdate arginfo_date
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_mktime, 0, 0, 1)
+       ZEND_ARG_TYPE_INFO(0, hour, IS_LONG, 0)
+       ZEND_ARG_TYPE_INFO(0, min, IS_LONG, 0)
+       ZEND_ARG_TYPE_INFO(0, sec, IS_LONG, 0)
+       ZEND_ARG_TYPE_INFO(0, mon, IS_LONG, 0)
+       ZEND_ARG_TYPE_INFO(0, day, IS_LONG, 0)
+       ZEND_ARG_TYPE_INFO(0, year, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_gmmktime arginfo_mktime
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_checkdate, 0, 3, _IS_BOOL, 0)
+       ZEND_ARG_TYPE_INFO(0, m, IS_LONG, 0)
+       ZEND_ARG_TYPE_INFO(0, d, IS_LONG, 0)
+       ZEND_ARG_TYPE_INFO(0, y, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_strftime arginfo_idate
+
+#define arginfo_gmstrftime arginfo_idate
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_time, 0, 0, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_localtime, 0, 0, IS_ARRAY, 0)
+       ZEND_ARG_TYPE_INFO(0, timestamp, IS_LONG, 0)
+       ZEND_ARG_TYPE_INFO(0, associative, _IS_BOOL, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_getdate, 0, 0, IS_ARRAY, 0)
+       ZEND_ARG_TYPE_INFO(0, timestamp, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_date_create, 0, 0, 1)
+       ZEND_ARG_TYPE_INFO(0, time, IS_STRING, 0)
+       ZEND_ARG_OBJ_INFO(0, timezone, DateTimeZone, 1)
+ZEND_END_ARG_INFO()
+
+#define arginfo_date_create_immutable arginfo_date_create
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_date_create_from_format, 0, 0, 2)
+       ZEND_ARG_TYPE_INFO(0, format, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO(0, time, IS_STRING, 0)
+       ZEND_ARG_OBJ_INFO(0, timezone, DateTimeZone, 1)
+ZEND_END_ARG_INFO()
+
+#define arginfo_date_create_immutable_from_format arginfo_date_create_from_format
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_date_parse, 0, 1, IS_ARRAY, 0)
+       ZEND_ARG_TYPE_INFO(0, date, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_date_parse_from_format, 0, 2, IS_ARRAY, 0)
+       ZEND_ARG_TYPE_INFO(0, format, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO(0, date, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_date_get_last_errors, 0, 0, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_date_format, 0, 0, 2)
+       ZEND_ARG_OBJ_INFO(0, object, DateTimeInterface, 0)
+       ZEND_ARG_TYPE_INFO(0, format, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_date_modify, 0, 0, 2)
+       ZEND_ARG_OBJ_INFO(0, object, DateTime, 0)
+       ZEND_ARG_TYPE_INFO(0, modify, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_date_add, 0, 0, 2)
+       ZEND_ARG_OBJ_INFO(0, object, DateTime, 0)
+       ZEND_ARG_OBJ_INFO(0, interval, DateInterval, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_date_sub arginfo_date_add
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_date_timezone_get, 0, 0, 1)
+       ZEND_ARG_OBJ_INFO(0, object, DateTimeInterface, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_date_timezone_set, 0, 0, 2)
+       ZEND_ARG_OBJ_INFO(0, object, DateTimeInterface, 0)
+       ZEND_ARG_OBJ_INFO(0, timezone, DateTimeZone, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_date_offset_get arginfo_date_timezone_get
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_date_diff, 0, 0, 2)
+       ZEND_ARG_OBJ_INFO(0, object, DateTimeInterface, 0)
+       ZEND_ARG_OBJ_INFO(0, object2, DateTimeInterface, 0)
+       ZEND_ARG_TYPE_INFO(0, absolute, _IS_BOOL, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_date_time_set, 0, 0, 3)
+       ZEND_ARG_OBJ_INFO(0, object, DateTime, 0)
+       ZEND_ARG_TYPE_INFO(0, hour, IS_LONG, 0)
+       ZEND_ARG_TYPE_INFO(0, minute, IS_LONG, 0)
+       ZEND_ARG_TYPE_INFO(0, second, IS_LONG, 0)
+       ZEND_ARG_TYPE_INFO(0, microseconds, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_date_date_set, 0, 0, 4)
+       ZEND_ARG_OBJ_INFO(0, object, DateTime, 0)
+       ZEND_ARG_TYPE_INFO(0, year, IS_LONG, 0)
+       ZEND_ARG_TYPE_INFO(0, month, IS_LONG, 0)
+       ZEND_ARG_TYPE_INFO(0, day, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_date_isodate_set, 0, 0, 3)
+       ZEND_ARG_OBJ_INFO(0, object, DateTime, 0)
+       ZEND_ARG_TYPE_INFO(0, year, IS_LONG, 0)
+       ZEND_ARG_TYPE_INFO(0, week, IS_LONG, 0)
+       ZEND_ARG_TYPE_INFO(0, day, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_date_timestamp_set, 0, 0, 2)
+       ZEND_ARG_OBJ_INFO(0, object, DateTime, 0)
+       ZEND_ARG_TYPE_INFO(0, timestamp, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_date_timestamp_get arginfo_date_timezone_get
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_open, 0, 0, 1)
+       ZEND_ARG_TYPE_INFO(0, timezone, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_name_get, 0, 0, 1)
+       ZEND_ARG_OBJ_INFO(0, object, DateTimeZone, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_name_from_abbr, 0, 0, 1)
+       ZEND_ARG_TYPE_INFO(0, abbr, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO(0, gmtoffset, IS_LONG, 0)
+       ZEND_ARG_TYPE_INFO(0, isdst, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_offset_get, 0, 0, 2)
+       ZEND_ARG_OBJ_INFO(0, object, DateTimeZone, 0)
+       ZEND_ARG_OBJ_INFO(0, datetime, DateTimeInterface, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_transitions_get, 0, 0, 1)
+       ZEND_ARG_OBJ_INFO(0, object, DateTimeZone, 0)
+       ZEND_ARG_TYPE_INFO(0, timestamp_begin, IS_LONG, 0)
+       ZEND_ARG_TYPE_INFO(0, timestamp_end, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_timezone_location_get arginfo_timezone_name_get
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_identifiers_list, 0, 0, 0)
+       ZEND_ARG_TYPE_INFO(0, what, IS_LONG, 0)
+       ZEND_ARG_TYPE_INFO(0, country, IS_STRING, 1)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_timezone_abbreviations_list, 0, 0, IS_ARRAY, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_timezone_version_get, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_date_interval_create_from_date_string, 0, 0, 1)
+       ZEND_ARG_TYPE_INFO(0, time, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_date_interval_format, 0, 0, 2)
+       ZEND_ARG_OBJ_INFO(0, object, DateInterval, 0)
+       ZEND_ARG_TYPE_INFO(0, format, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_date_default_timezone_set, 0, 1, _IS_BOOL, 0)
+       ZEND_ARG_TYPE_INFO(0, timezone_identifier, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_date_default_timezone_get arginfo_timezone_version_get
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_date_sunrise, 0, 0, 1)
+       ZEND_ARG_TYPE_INFO(0, time, IS_LONG, 0)
+       ZEND_ARG_TYPE_INFO(0, retformat, IS_LONG, 0)
+       ZEND_ARG_TYPE_INFO(0, latitude, IS_DOUBLE, 0)
+       ZEND_ARG_TYPE_INFO(0, longitude, IS_DOUBLE, 0)
+       ZEND_ARG_TYPE_INFO(0, zenith, IS_DOUBLE, 0)
+       ZEND_ARG_TYPE_INFO(0, gmt_offset, IS_DOUBLE, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_date_sunset arginfo_date_sunrise
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_date_sun_info, 0, 3, IS_ARRAY, 0)
+       ZEND_ARG_TYPE_INFO(0, time, IS_LONG, 0)
+       ZEND_ARG_TYPE_INFO(0, latitude, IS_DOUBLE, 0)
+       ZEND_ARG_TYPE_INFO(0, longitude, IS_DOUBLE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_DateTimeInterface_format, 0, 0, 1)
+       ZEND_ARG_TYPE_INFO(0, format, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_DateTimeInterface_getTimezone arginfo_date_get_last_errors
+
+#define arginfo_DateTimeInterface_getOffset arginfo_date_get_last_errors
+
+#define arginfo_DateTimeInterface_getTimestamp arginfo_date_get_last_errors
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_DateTimeInterface_diff, 0, 0, 1)
+       ZEND_ARG_OBJ_INFO(0, object, DateTimeInterface, 0)
+       ZEND_ARG_TYPE_INFO(0, absolute, _IS_BOOL, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_DateTimeInterface___wakeup arginfo_date_get_last_errors
+
+#define arginfo_DateTime___construct arginfo_date_create
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_DateTime___set_state, 0, 0, 1)
+       ZEND_ARG_TYPE_INFO(0, array, IS_ARRAY, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_DateTime_createFromImmutable, 0, 0, 1)
+       ZEND_ARG_OBJ_INFO(0, object, DateTimeImmutable, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_DateTime_createFromFormat arginfo_date_create_from_format
+
+#define arginfo_DateTime_getLastErrors arginfo_date_get_last_errors
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_DateTime_modify, 0, 0, 1)
+       ZEND_ARG_TYPE_INFO(0, modify, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_DateTime_add, 0, 0, 1)
+       ZEND_ARG_OBJ_INFO(0, interval, DateInterval, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_DateTime_sub arginfo_DateTime_add
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_DateTime_setTimezone, 0, 0, 1)
+       ZEND_ARG_OBJ_INFO(0, timezone, DateTimeZone, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_DateTime_setTime, 0, 0, 2)
+       ZEND_ARG_TYPE_INFO(0, hour, IS_LONG, 0)
+       ZEND_ARG_TYPE_INFO(0, minute, IS_LONG, 0)
+       ZEND_ARG_TYPE_INFO(0, second, IS_LONG, 0)
+       ZEND_ARG_TYPE_INFO(0, microseconds, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_DateTime_setDate, 0, 0, 3)
+       ZEND_ARG_TYPE_INFO(0, year, IS_LONG, 0)
+       ZEND_ARG_TYPE_INFO(0, month, IS_LONG, 0)
+       ZEND_ARG_TYPE_INFO(0, day, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_DateTime_setISODate, 0, 0, 2)
+       ZEND_ARG_TYPE_INFO(0, year, IS_LONG, 0)
+       ZEND_ARG_TYPE_INFO(0, week, IS_LONG, 0)
+       ZEND_ARG_TYPE_INFO(0, day, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_DateTime_setTimestamp, 0, 0, 1)
+       ZEND_ARG_TYPE_INFO(0, timestampt, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_DateTimeImmutable___construct arginfo_date_create
+
+#define arginfo_DateTimeImmutable___set_state arginfo_date_get_last_errors
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_DateTimeImmutable_createFromMutable, 0, 0, 1)
+       ZEND_ARG_OBJ_INFO(0, object, DateTime, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_DateTimeImmutable_modify arginfo_DateTime_modify
+
+#define arginfo_DateTimeImmutable_add arginfo_DateTime_add
+
+#define arginfo_DateTimeImmutable_sub arginfo_DateTime_add
+
+#define arginfo_DateTimeImmutable_setTimezone arginfo_DateTime_setTimezone
+
+#define arginfo_DateTimeImmutable_setTime arginfo_DateTime_setTime
+
+#define arginfo_DateTimeImmutable_setDate arginfo_DateTime_setDate
+
+#define arginfo_DateTimeImmutable_setISODate arginfo_DateTime_setISODate
+
+#define arginfo_DateTimeImmutable_setTimestamp arginfo_DateTime_setTimestamp
+
+#define arginfo_DateTimeZone___construct arginfo_timezone_open
+
+#define arginfo_DateTimeZone_getName arginfo_date_get_last_errors
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_DateTimeZone_getOffset, 0, 0, 1)
+       ZEND_ARG_OBJ_INFO(0, datetime, DateTimeInterface, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_DateTimeZone_getTransitions, 0, 0, 0)
+       ZEND_ARG_TYPE_INFO(0, timestamp_begin, IS_LONG, 0)
+       ZEND_ARG_TYPE_INFO(0, timestamp_end, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_DateTimeZone_getLocation arginfo_date_get_last_errors
+
+#define arginfo_DateTimeZone_listAbbreviations arginfo_date_get_last_errors
+
+#define arginfo_DateTimeZone_listIdentifiers arginfo_timezone_identifiers_list
+
+#define arginfo_DateTimeZone___wakeup arginfo_date_get_last_errors
+
+#define arginfo_DateTimeZone___set_state arginfo_date_get_last_errors
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_DateInterval___construct, 0, 0, 1)
+       ZEND_ARG_TYPE_INFO(0, interval_spec, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_DateInterval_createFromDateString arginfo_date_interval_create_from_date_string
+
+#define arginfo_DateInterval_format arginfo_DateTimeInterface_format
+
+#define arginfo_DateInterval___wakeup arginfo_date_get_last_errors
+
+#define arginfo_DateInterval___set_state arginfo_DateTime___set_state
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_DatePeriod___construct, 0, 0, 1)
+       ZEND_ARG_INFO(0, start)
+       ZEND_ARG_INFO(0, interval)
+       ZEND_ARG_INFO(0, end)
+ZEND_END_ARG_INFO()
+
+#define arginfo_DatePeriod_getStartDate arginfo_date_get_last_errors
+
+#define arginfo_DatePeriod_getEndDate arginfo_date_get_last_errors
+
+#define arginfo_DatePeriod_getDateInterval arginfo_date_get_last_errors
+
+#define arginfo_DatePeriod_getRecurrences arginfo_date_get_last_errors
+
+#define arginfo_DatePeriod___wakeup arginfo_date_get_last_errors
+
+#define arginfo_DatePeriod___set_state arginfo_DateTime___set_state
index ae1ca7d9ba7c8f94e2196a424b75147cebeb8a77..0e48c7304d4c56a3d6c81a03439adc9abc1f5570 100644 (file)
@@ -347,11 +347,6 @@ ZEND_BEGIN_ARG_INFO(arginfo_shuffle, 0)
        ZEND_ARG_INFO(1, arg) /* ARRAY_INFO(1, arg, 0) */
 ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_array_push, 0, 0, 1)
-       ZEND_ARG_INFO(1, stack) /* ARRAY_INFO(1, stack, 0) */
-       ZEND_ARG_VARIADIC_INFO(0, vars)
-ZEND_END_ARG_INFO()
-
 ZEND_BEGIN_ARG_INFO(arginfo_array_pop, 0)
        ZEND_ARG_INFO(1, stack) /* ARRAY_INFO(1, stack, 0) */
 ZEND_END_ARG_INFO()
@@ -2721,6 +2716,8 @@ ZEND_END_ARG_INFO()
 /* }}} */
 /* }}} */
 
+#include "basic_functions_arginfo.h"
+
 static const zend_function_entry basic_functions[] = { /* {{{ */
        PHP_FE(constant,                                                                                                                arginfo_constant)
        PHP_FE(bin2hex,                                                                                                                 arginfo_bin2hex)
diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php
new file mode 100644 (file)
index 0000000..3e8d6e1
--- /dev/null
@@ -0,0 +1,4 @@
+<?php
+
+/** @return int|false */
+function array_push(array &$stack, ...$args) {}
diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h
new file mode 100644 (file)
index 0000000..70df72b
--- /dev/null
@@ -0,0 +1,6 @@
+/* This is a generated file, edit the .stub.php file instead. */
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_array_push, 0, 0, 1)
+       ZEND_ARG_TYPE_INFO(1, stack, IS_ARRAY, 0)
+       ZEND_ARG_VARIADIC_INFO(0, args)
+ZEND_END_ARG_INFO()
diff --git a/scripts/dev/gen_stub.php b/scripts/dev/gen_stub.php
new file mode 100755 (executable)
index 0000000..9a71e7d
--- /dev/null
@@ -0,0 +1,380 @@
+#!/usr/bin/env php
+<?php declare(strict_types=1);
+
+use PhpParser\Node;
+use PhpParser\Node\Stmt;
+
+error_reporting(E_ALL);
+
+try {
+    initPhpParser();
+} catch (Exception $e) {
+    echo "{$e->getMessage()}\n";
+    exit(1);
+}
+
+if ($argc < 2) {
+    die("Usage: php gen_stub.php foobar.stub.php\n");
+}
+
+$stubFile = $argv[1];
+$arginfoFile = str_replace('.stub.php', '', $stubFile) . '_arginfo.h';
+
+try {
+    $funcInfos = parseStubFile($stubFile);
+    $arginfoCode = generateArgInfoCode($funcInfos);
+    file_put_contents($arginfoFile, $arginfoCode);
+} catch (Exception $e) {
+    echo "Caught {$e->getMessage()} while processing $stubFile\n";
+    exit(1);
+}
+
+class Type {
+    /** @var string */
+    public $name;
+    /** @var bool */
+    public $isBuiltin;
+    /** @var bool */
+    public $isNullable;
+
+    public function __construct(string $name, bool $isBuiltin, bool $isNullable = false) {
+        $this->name = $name;
+        $this->isBuiltin = $isBuiltin;
+        $this->isNullable = $isNullable;
+    }
+
+    public static function fromNode(Node $node) {
+        if ($node instanceof Node\NullableType) {
+            $type = self::fromNode($node->type);
+            return new Type($type->name, $type->isBuiltin, true);
+        }
+        if ($node instanceof Node\Name) {
+            assert($node->isFullyQualified());
+            return new Type($node->toString(), false);
+        }
+        if ($node instanceof Node\Identifier) {
+            return new Type($node->toString(), true);
+        }
+        throw new Exception("Unexpected node type");
+    }
+
+    public function toTypeCode() {
+        assert($this->isBuiltin);
+        switch (strtolower($this->name)) {
+        case "bool":
+            return "_IS_BOOL";
+        case "int":
+            return "IS_LONG";
+        case "float":
+            return "IS_DOUBLE";
+        case "string":
+            return "IS_STRING";
+        case "array":
+            return "IS_ARRAY";
+        case "object":
+            return "IS_OBJECT";
+        case "void":
+            return "IS_VOID";
+        default:
+            throw new Exception("Not implemented: $this->name");
+        }
+    }
+
+    public static function equals(?Type $a, ?Type $b): bool {
+        if ($a === null || $b === null) {
+            return $a === $b;
+        }
+
+        return $a->name === $b->name
+            && $a->isBuiltin === $b->isBuiltin
+            && $a->isNullable === $b->isNullable;
+    }
+}
+
+class ArgInfo {
+    /** @var string */
+    public $name;
+    /** @var bool */
+    public $byRef;
+    /** @var bool */
+    public $isVariadic;
+    /** @var Type|null */
+    public $type;
+
+    public function __construct(string $name, bool $byRef, bool $isVariadic, ?Type $type) {
+        $this->name = $name;
+        $this->byRef = $byRef;
+        $this->isVariadic = $isVariadic;
+        $this->type = $type;
+    }
+
+    public function equals(ArgInfo $other): bool {
+        return $this->name === $other->name
+            && $this->byRef === $other->byRef
+            && $this->isVariadic === $other->isVariadic
+            && Type::equals($this->type, $other->type);
+    }
+}
+
+class ReturnInfo {
+    /** @var bool */
+    public $byRef;
+    /** @var Type|null */
+    public $type;
+
+    public function __construct(bool $byRef, ?Type $type) {
+        $this->byRef = $byRef;
+        $this->type = $type;
+    }
+
+    public function equals(ReturnInfo $other): bool {
+        return $this->byRef === $other->byRef
+            && Type::equals($this->type, $other->type);
+    }
+}
+
+class FuncInfo {
+    /** @var string */
+    public $name;
+    /** @var ArgInfo[] */
+    public $args;
+    /** @var ReturnInfo */
+    public $return;
+    /** @var int */
+    public $numRequiredArgs;
+    /** @var string|null */
+    public $cond;
+
+    public function __construct(
+        string $name, array $args, ReturnInfo $return, int $numRequiredArgs, ?string $cond
+    ) {
+        $this->name = $name;
+        $this->args = $args;
+        $this->return = $return;
+        $this->numRequiredArgs = $numRequiredArgs;
+        $this->cond = $cond;
+    }
+
+    public function equalsApartFromName(FuncInfo $other): bool {
+        if (count($this->args) !== count($other->args)) {
+            return false;
+        }
+
+        for ($i = 0; $i < count($this->args); $i++) {
+            if (!$this->args[$i]->equals($other->args[$i])) {
+                return false;
+            }
+        }
+
+        return $this->return->equals($other->return)
+            && $this->numRequiredArgs === $other->numRequiredArgs
+            && $this->cond === $other->cond;
+    }
+}
+
+function parseFunctionLike(string $name, Node\FunctionLike $func, ?string $cond): FuncInfo {
+    $args = [];
+    $numRequiredArgs = 0;
+    foreach ($func->getParams() as $i => $param) {
+        $args[] = new ArgInfo(
+            $param->var->name,
+            $param->byRef,
+            $param->variadic,
+            $param->type ? Type::fromNode($param->type) : null
+        );
+        if (!$param->default && !$param->variadic) {
+            $numRequiredArgs = $i + 1;
+        }
+    }
+
+    $returnType = $func->getReturnType();
+    $return = new ReturnInfo(
+        $func->returnsByRef(),
+        $returnType ? Type::fromNode($returnType) : null);
+    return new FuncInfo($name, $args, $return, $numRequiredArgs, $cond);
+}
+
+function parseClass(Stmt\Class_ $class): ClassInfo {
+    $funcs = [];
+    $className = $class->name->toString();
+    foreach ($class as $stmt) {
+        if (!$stmt instanceof Stmt\ClassMethod) {
+            throw new Exception("Not implemented");
+        }
+
+        $funcs[] = parseFunctionLike($className . '_' . $stmt->name->toString(), $stmt);
+    }
+    return new ClassInfo($className, $funcs);
+}
+
+/** @return FuncInfo[] */
+function parseStubFile(string $fileName) {
+    if (!file_exists($fileName)) {
+        throw new Exception("File $fileName does not exist");
+    }
+
+    $code = file_get_contents($fileName);
+
+    $lexer = new PhpParser\Lexer();
+    $parser = new PhpParser\Parser\Php7($lexer);
+    $nodeTraverser = new PhpParser\NodeTraverser;
+    $nodeTraverser->addVisitor(new PhpParser\NodeVisitor\NameResolver);
+
+    $stmts = $parser->parse($code);
+    $nodeTraverser->traverse($stmts);
+
+    $funcInfos = [];
+    $cond = null;
+    foreach ($stmts as $stmt) {
+        foreach ($stmt->getComments() as $comment) {
+            $text = trim($comment->getText());
+            if (preg_match('/^#if\s+(.+)$/', $text, $matches)) {
+                if ($cond !== null) {
+                    throw new Exception("Not implemented");
+                }
+                $cond = $matches[1];
+            } else if ($text === '#endif') {
+                $cond = null;
+            }
+        }
+
+        if ($stmt instanceof Stmt\Nop) {
+            continue;
+        }
+
+        if ($stmt instanceof Stmt\Function_) {
+            $funcInfos[] = parseFunctionLike($stmt->name->toString(), $stmt, $cond);
+            continue;
+        }
+
+        if ($stmt instanceof Stmt\ClassLike) {
+            $className = $stmt->name->toString();
+            foreach ($stmt->stmts as $classStmt) {
+                if ($classStmt instanceof Stmt\Nop) {
+                    continue;
+                }
+
+                if (!$classStmt instanceof Stmt\ClassMethod) {
+                    throw new Exception("Not implemented {$classStmt->getType()}");
+                }
+
+                $funcInfos[] = parseFunctionLike(
+                    $className . '_' . $classStmt->name->toString(), $classStmt, $cond);
+            }
+            continue;
+        }
+
+        throw new Exception("Unexpected node {$stmt->getType()}");
+    }
+
+    return $funcInfos;
+}
+
+function funcInfoToCode(FuncInfo $funcInfo): string {
+    $code = '';
+    if ($funcInfo->cond) {
+        $code .= "#if {$funcInfo->cond}\n";
+    }
+    if ($funcInfo->return->type) {
+        $returnType = $funcInfo->return->type;
+        if ($returnType->isBuiltin) {
+            $code .= sprintf(
+                "ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_%s, %d, %d, %s, %d)\n",
+                $funcInfo->name, $funcInfo->return->byRef, $funcInfo->numRequiredArgs,
+                $returnType->toTypeCode(), $returnType->isNullable
+            );
+        } else {
+            throw new Exception("Not implemented");
+        }
+    } else {
+        $code .= sprintf(
+            "ZEND_BEGIN_ARG_INFO_EX(arginfo_%s, 0, %d, %d)\n",
+            $funcInfo->name, $funcInfo->return->byRef, $funcInfo->numRequiredArgs
+        );
+    }
+
+    foreach ($funcInfo->args as $argInfo) {
+        if ($argInfo->isVariadic) {
+            if ($argInfo->type) {
+                throw new Exception("Not implemented");
+            }
+            $code .= sprintf(
+                "\tZEND_ARG_VARIADIC_INFO(%d, %s)\n",
+                $argInfo->byRef, $argInfo->name
+            );
+        } else if ($argInfo->type) {
+            if ($argInfo->type->isBuiltin) {
+                $code .= sprintf(
+                    "\tZEND_ARG_TYPE_INFO(%d, %s, %s, %d)\n",
+                    $argInfo->byRef, $argInfo->name,
+                    $argInfo->type->toTypeCode(), $argInfo->type->isNullable
+                );
+            } else {
+                $code .= sprintf(
+                    "\tZEND_ARG_OBJ_INFO(%d, %s, %s, %d)\n",
+                    $argInfo->byRef, $argInfo->name,
+                    $argInfo->type->name, $argInfo->type->isNullable
+                );
+            }
+        } else {
+            $code .= sprintf("\tZEND_ARG_INFO(%d, %s)\n", $argInfo->byRef, $argInfo->name);
+        }
+    }
+
+    $code .= "ZEND_END_ARG_INFO()";
+    if ($funcInfo->cond) {
+        $code .= "\n#endif";
+    }
+    return $code;
+}
+
+/** @param FuncInfo[] $funcInfos */
+function generateArginfoCode(array $funcInfos): string {
+    $code = "/* This is a generated file, edit the .stub.php file instead. */";
+    $generatedFuncInfos = [];
+    foreach ($funcInfos as $funcInfo) {
+        /* If there already is an equivalent arginfo structure, only emit a #define */
+        foreach ($generatedFuncInfos as $generatedFuncInfo) {
+            if ($generatedFuncInfo->equalsApartFromName($funcInfo)) {
+                $code .= sprintf(
+                    "\n\n#define arginfo_%s arginfo_%s",
+                    $funcInfo->name, $generatedFuncInfo->name
+                );
+                continue 2;
+            }
+        }
+
+        $code .= "\n\n" . funcInfoToCode($funcInfo);
+        $generatedFuncInfos[] = $funcInfo;
+    }
+    return $code . "\n";
+}
+
+function initPhpParser() {
+    $version = "4.2.2";
+    $phpParserDir = __DIR__ . "/PHP-Parser-$version";
+    if (!is_dir($phpParserDir)) {
+        $cwd = getcwd();
+        chdir(__DIR__);
+        passthru("wget https://github.com/nikic/PHP-Parser/archive/v$version.tar.gz", $exit);
+        if ($exit !== 0) {
+            throw new Exception("Failed to download PHP-Parser tarball");
+        }
+        if (!mkdir($phpParserDir)) {
+            throw new Exception("Failed to create directory $phpParserDir");
+        }
+        passthru("tar xvzf v$version.tar.gz -C PHP-Parser-$version --strip-components 1", $exit);
+        if ($exit !== 0) {
+            throw new Exception("Failed to extract PHP-Parser tarball");
+        }
+        unlink(__DIR__ . "/v$version.tar.gz");
+        chdir($cwd);
+    }
+
+    spl_autoload_register(function(string $class) use($phpParserDir) {
+        if (strpos($class, "PhpParser\\") === 0) {
+            $fileName = $phpParserDir . "/lib/" . str_replace("\\", "/", $class) . ".php";
+            require $fileName;
+        }
+    });
+}