Skip to content

Commit 33886f7

Browse files
committed
Generate arginfo from PHP stub files
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.
1 parent 9b97355 commit 33886f7

12 files changed

+1484
-578
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ include/
8080
libs/
8181
modules/
8282

83+
# Used by scripts/dev/gen_stub.php
84+
scripts/dev/PHP-Parser-*
85+
8386
# ------------------------------------------------------------------------------
8487
# Configuration headers generated by the PHP build system
8588
# ------------------------------------------------------------------------------

Zend/zend_builtin_functions.c

Lines changed: 25 additions & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -85,154 +85,15 @@ static ZEND_FUNCTION(gc_enable);
8585
static ZEND_FUNCTION(gc_disable);
8686
static ZEND_FUNCTION(gc_status);
8787

88-
/* {{{ arginfo */
89-
ZEND_BEGIN_ARG_INFO(arginfo_zend__void, 0)
90-
ZEND_END_ARG_INFO()
91-
92-
ZEND_BEGIN_ARG_INFO_EX(arginfo_func_get_arg, 0, 0, 1)
93-
ZEND_ARG_TYPE_INFO(0, arg_num, IS_LONG, 0)
94-
ZEND_END_ARG_INFO()
95-
96-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_strlen, 0, 1, IS_LONG, 0)
97-
ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0)
98-
ZEND_END_ARG_INFO()
99-
100-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_strcmp, 0, 2, IS_LONG, 0)
101-
ZEND_ARG_TYPE_INFO(0, str1, IS_STRING, 0)
102-
ZEND_ARG_TYPE_INFO(0, str2, IS_STRING, 0)
103-
ZEND_END_ARG_INFO()
104-
105-
ZEND_BEGIN_ARG_INFO_EX(arginfo_strncmp, 0, 0, 3)
106-
ZEND_ARG_TYPE_INFO(0, str1, IS_STRING, 0)
107-
ZEND_ARG_TYPE_INFO(0, str2, IS_STRING, 0)
108-
ZEND_ARG_TYPE_INFO(0, len, IS_LONG, 0)
109-
ZEND_END_ARG_INFO()
110-
111-
ZEND_BEGIN_ARG_INFO_EX(arginfo_error_reporting, 0, 0, 0)
112-
ZEND_ARG_INFO(0, new_error_level)
113-
ZEND_END_ARG_INFO()
114-
115-
ZEND_BEGIN_ARG_INFO_EX(arginfo_define, 0, 0, 2)
116-
ZEND_ARG_INFO(0, constant_name)
117-
ZEND_ARG_INFO(0, value)
118-
ZEND_ARG_INFO(0, case_insensitive)
119-
ZEND_END_ARG_INFO()
120-
121-
ZEND_BEGIN_ARG_INFO_EX(arginfo_defined, 0, 0, 1)
122-
ZEND_ARG_INFO(0, constant_name)
123-
ZEND_END_ARG_INFO()
124-
125-
ZEND_BEGIN_ARG_INFO_EX(arginfo_get_class, 0, 0, 0)
126-
ZEND_ARG_INFO(0, object)
127-
ZEND_END_ARG_INFO()
128-
129-
ZEND_BEGIN_ARG_INFO_EX(arginfo_is_subclass_of, 0, 0, 2)
130-
ZEND_ARG_INFO(0, object)
131-
ZEND_ARG_INFO(0, class_name)
132-
ZEND_ARG_INFO(0, allow_string)
133-
ZEND_END_ARG_INFO()
134-
135-
ZEND_BEGIN_ARG_INFO_EX(arginfo_get_class_vars, 0, 0, 1)
136-
ZEND_ARG_INFO(0, class_name)
137-
ZEND_END_ARG_INFO()
138-
139-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_get_object_vars, 0, 1, IS_ARRAY, 0)
140-
ZEND_ARG_INFO(0, obj)
141-
ZEND_END_ARG_INFO()
142-
143-
ZEND_BEGIN_ARG_INFO_EX(arginfo_get_mangled_object_vars, 0, 0, 1)
144-
ZEND_ARG_INFO(0, obj)
145-
ZEND_END_ARG_INFO()
146-
147-
ZEND_BEGIN_ARG_INFO_EX(arginfo_get_class_methods, 0, 0, 1)
148-
ZEND_ARG_INFO(0, class)
149-
ZEND_END_ARG_INFO()
150-
151-
ZEND_BEGIN_ARG_INFO_EX(arginfo_method_exists, 0, 0, 2)
152-
ZEND_ARG_INFO(0, object)
153-
ZEND_ARG_INFO(0, method)
154-
ZEND_END_ARG_INFO()
155-
156-
ZEND_BEGIN_ARG_INFO_EX(arginfo_property_exists, 0, 0, 2)
157-
ZEND_ARG_INFO(0, object_or_class)
158-
ZEND_ARG_INFO(0, property_name)
159-
ZEND_END_ARG_INFO()
160-
161-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_exists, 0, 0, 1)
162-
ZEND_ARG_INFO(0, classname)
163-
ZEND_ARG_INFO(0, autoload)
164-
ZEND_END_ARG_INFO()
165-
166-
ZEND_BEGIN_ARG_INFO_EX(arginfo_trait_exists, 0, 0, 1)
167-
ZEND_ARG_INFO(0, traitname)
168-
ZEND_ARG_INFO(0, autoload)
169-
ZEND_END_ARG_INFO()
170-
171-
ZEND_BEGIN_ARG_INFO_EX(arginfo_function_exists, 0, 0, 1)
172-
ZEND_ARG_INFO(0, function_name)
173-
ZEND_END_ARG_INFO()
174-
175-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_alias, 0, 0, 2)
176-
ZEND_ARG_INFO(0, user_class_name)
177-
ZEND_ARG_INFO(0, alias_name)
178-
ZEND_ARG_INFO(0, autoload)
179-
ZEND_END_ARG_INFO()
180-
181-
ZEND_BEGIN_ARG_INFO_EX(arginfo_trigger_error, 0, 0, 1)
182-
ZEND_ARG_INFO(0, message)
183-
ZEND_ARG_INFO(0, error_type)
184-
ZEND_END_ARG_INFO()
185-
186-
ZEND_BEGIN_ARG_INFO_EX(arginfo_set_error_handler, 0, 0, 1)
187-
ZEND_ARG_INFO(0, error_handler)
188-
ZEND_ARG_INFO(0, error_types)
189-
ZEND_END_ARG_INFO()
190-
191-
ZEND_BEGIN_ARG_INFO_EX(arginfo_set_exception_handler, 0, 0, 1)
192-
ZEND_ARG_INFO(0, exception_handler)
193-
ZEND_END_ARG_INFO()
194-
195-
ZEND_BEGIN_ARG_INFO_EX(arginfo_get_defined_functions, 0, 0, 0)
196-
ZEND_ARG_INFO(0, exclude_disabled)
197-
ZEND_END_ARG_INFO()
198-
199-
ZEND_BEGIN_ARG_INFO_EX(arginfo_get_resource_type, 0, 0, 1)
200-
ZEND_ARG_INFO(0, res)
201-
ZEND_END_ARG_INFO()
202-
203-
ZEND_BEGIN_ARG_INFO_EX(arginfo_get_resources, 0, 0, 0)
204-
ZEND_ARG_INFO(0, type)
205-
ZEND_END_ARG_INFO()
206-
207-
ZEND_BEGIN_ARG_INFO_EX(arginfo_get_loaded_extensions, 0, 0, 0)
208-
ZEND_ARG_INFO(0, zend_extensions)
209-
ZEND_END_ARG_INFO()
210-
211-
ZEND_BEGIN_ARG_INFO_EX(arginfo_get_defined_constants, 0, 0, 0)
212-
ZEND_ARG_INFO(0, categorize)
213-
ZEND_END_ARG_INFO()
214-
215-
ZEND_BEGIN_ARG_INFO_EX(arginfo_debug_backtrace, 0, 0, 0)
216-
ZEND_ARG_INFO(0, options)
217-
ZEND_ARG_INFO(0, limit)
218-
ZEND_END_ARG_INFO()
219-
220-
ZEND_BEGIN_ARG_INFO_EX(arginfo_debug_print_backtrace, 0, 0, 0)
221-
ZEND_ARG_INFO(0, options)
222-
ZEND_ARG_INFO(0, limit)
223-
ZEND_END_ARG_INFO()
224-
225-
ZEND_BEGIN_ARG_INFO_EX(arginfo_extension_loaded, 0, 0, 1)
226-
ZEND_ARG_INFO(0, extension_name)
227-
ZEND_END_ARG_INFO()
88+
#include "zend_builtin_functions_arginfo.h"
22889

22990
/* }}} */
23091

23192
static const zend_function_entry builtin_functions[] = { /* {{{ */
232-
ZEND_FE(zend_version, arginfo_zend__void)
233-
ZEND_FE(func_num_args, arginfo_zend__void)
93+
ZEND_FE(zend_version, arginfo_zend_version)
94+
ZEND_FE(func_num_args, arginfo_func_num_args)
23495
ZEND_FE(func_get_arg, arginfo_func_get_arg)
235-
ZEND_FE(func_get_args, arginfo_zend__void)
96+
ZEND_FE(func_get_args, arginfo_func_get_args)
23697
ZEND_FE(strlen, arginfo_strlen)
23798
ZEND_FE(strcmp, arginfo_strcmp)
23899
ZEND_FE(strncmp, arginfo_strncmp)
@@ -242,51 +103,51 @@ static const zend_function_entry builtin_functions[] = { /* {{{ */
242103
ZEND_FE(define, arginfo_define)
243104
ZEND_FE(defined, arginfo_defined)
244105
ZEND_FE(get_class, arginfo_get_class)
245-
ZEND_FE(get_called_class, arginfo_zend__void)
246-
ZEND_FE(get_parent_class, arginfo_get_class)
106+
ZEND_FE(get_called_class, arginfo_get_called_class)
107+
ZEND_FE(get_parent_class, arginfo_get_parent_class)
247108
ZEND_FE(method_exists, arginfo_method_exists)
248109
ZEND_FE(property_exists, arginfo_property_exists)
249110
ZEND_FE(class_exists, arginfo_class_exists)
250-
ZEND_FE(interface_exists, arginfo_class_exists)
111+
ZEND_FE(interface_exists, arginfo_interface_exists)
251112
ZEND_FE(trait_exists, arginfo_trait_exists)
252113
ZEND_FE(function_exists, arginfo_function_exists)
253114
ZEND_FE(class_alias, arginfo_class_alias)
254-
ZEND_FE(get_included_files, arginfo_zend__void)
255-
ZEND_FALIAS(get_required_files, get_included_files, arginfo_zend__void)
115+
ZEND_FE(get_included_files, arginfo_get_included_files)
116+
ZEND_FALIAS(get_required_files, get_included_files, arginfo_get_required_files)
256117
ZEND_FE(is_subclass_of, arginfo_is_subclass_of)
257-
ZEND_FE(is_a, arginfo_is_subclass_of)
118+
ZEND_FE(is_a, arginfo_is_a)
258119
ZEND_FE(get_class_vars, arginfo_get_class_vars)
259120
ZEND_FE(get_object_vars, arginfo_get_object_vars)
260121
ZEND_FE(get_mangled_object_vars, arginfo_get_mangled_object_vars)
261122
ZEND_FE(get_class_methods, arginfo_get_class_methods)
262123
ZEND_FE(trigger_error, arginfo_trigger_error)
263-
ZEND_FALIAS(user_error, trigger_error, arginfo_trigger_error)
124+
ZEND_FALIAS(user_error, trigger_error, arginfo_user_error)
264125
ZEND_FE(set_error_handler, arginfo_set_error_handler)
265-
ZEND_FE(restore_error_handler, arginfo_zend__void)
126+
ZEND_FE(restore_error_handler, arginfo_restore_error_handler)
266127
ZEND_FE(set_exception_handler, arginfo_set_exception_handler)
267-
ZEND_FE(restore_exception_handler, arginfo_zend__void)
268-
ZEND_FE(get_declared_classes, arginfo_zend__void)
269-
ZEND_FE(get_declared_traits, arginfo_zend__void)
270-
ZEND_FE(get_declared_interfaces, arginfo_zend__void)
128+
ZEND_FE(restore_exception_handler, arginfo_restore_exception_handler)
129+
ZEND_FE(get_declared_classes, arginfo_get_declared_classes)
130+
ZEND_FE(get_declared_traits, arginfo_get_declared_traits)
131+
ZEND_FE(get_declared_interfaces, arginfo_get_declared_interfaces)
271132
ZEND_FE(get_defined_functions, arginfo_get_defined_functions)
272-
ZEND_FE(get_defined_vars, arginfo_zend__void)
133+
ZEND_FE(get_defined_vars, arginfo_get_defined_vars)
273134
ZEND_FE(get_resource_type, arginfo_get_resource_type)
274135
ZEND_FE(get_resources, arginfo_get_resources)
275136
ZEND_FE(get_loaded_extensions, arginfo_get_loaded_extensions)
276137
ZEND_FE(extension_loaded, arginfo_extension_loaded)
277-
ZEND_FE(get_extension_funcs, arginfo_extension_loaded)
138+
ZEND_FE(get_extension_funcs, arginfo_get_extension_funcs)
278139
ZEND_FE(get_defined_constants, arginfo_get_defined_constants)
279140
ZEND_FE(debug_backtrace, arginfo_debug_backtrace)
280141
ZEND_FE(debug_print_backtrace, arginfo_debug_print_backtrace)
281142
#if ZEND_DEBUG && defined(ZTS)
282-
ZEND_FE(zend_thread_id, NULL)
143+
ZEND_FE(zend_thread_id, arginfo_zend_thread_id)
283144
#endif
284-
ZEND_FE(gc_mem_caches, arginfo_zend__void)
285-
ZEND_FE(gc_collect_cycles, arginfo_zend__void)
286-
ZEND_FE(gc_enabled, arginfo_zend__void)
287-
ZEND_FE(gc_enable, arginfo_zend__void)
288-
ZEND_FE(gc_disable, arginfo_zend__void)
289-
ZEND_FE(gc_status, arginfo_zend__void)
145+
ZEND_FE(gc_mem_caches, arginfo_gc_mem_caches)
146+
ZEND_FE(gc_collect_cycles, arginfo_gc_collect_cycles)
147+
ZEND_FE(gc_enabled, arginfo_gc_enabled)
148+
ZEND_FE(gc_enable, arginfo_gc_enable)
149+
ZEND_FE(gc_disable, arginfo_gc_disable)
150+
ZEND_FE(gc_status, arginfo_gc_status)
290151
ZEND_FE_END
291152
};
292153
/* }}} */

Zend/zend_builtin_functions.stub.php

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
<?php
2+
3+
function zend_version(): string {}
4+
5+
function func_num_args(): int {}
6+
7+
/** @return mixed */
8+
function func_get_arg(int $arg_num) {}
9+
10+
/** @return array|false */
11+
function func_get_args() {}
12+
13+
function strlen(string $str): int {}
14+
15+
function strcmp(string $str1, string $str2): int {}
16+
17+
/** @return int|false */
18+
function strncmp(string $str1, string $str2, int $len) {}
19+
20+
function error_reporting($new_error_level = UNKNOWN): int {}
21+
22+
function define(string $constant_name, $value, bool $case_insensitive = false): bool {}
23+
24+
function defined(string $constant_name): bool {}
25+
26+
/** @return string|false */
27+
function get_class(object $object = UNKNOWN) {}
28+
29+
/** @return string|false */
30+
function get_called_class() {}
31+
32+
/** @return string|false */
33+
function get_parent_class($object) {}
34+
35+
function is_subclass_of($object, string $class_name, bool $allow_string = true): bool {}
36+
37+
function is_a($object, string $class_name, bool $allow_string = false): bool {}
38+
39+
/** @return array|false */
40+
function get_class_vars(string $class_name) {}
41+
42+
function get_object_vars(object $obj): array {}
43+
44+
function get_mangled_object_vars(object $obj): array {}
45+
46+
function get_class_methods($class): ?array {}
47+
48+
function method_exists($object_or_class, string $method): bool {}
49+
50+
function property_exists($object_or_class, string $property_name): ?bool {}
51+
52+
function class_exists(string $classname, bool $autoload = true): bool {}
53+
54+
function interface_exists(string $classname, bool $autoload = true): bool {}
55+
56+
function trait_exists(string $traitname, bool $autoload = true): bool {}
57+
58+
function function_exists(string $function_name): bool {}
59+
60+
function class_alias(string $user_class_name, string $alias_name, bool $autoload = true): bool {}
61+
62+
function get_included_files(): array {}
63+
64+
/** @alias get_included_files */
65+
function get_required_files(): array {}
66+
67+
function trigger_error(string $message, int $error_type = E_USER_NOTICE): bool {}
68+
69+
/** @alias trigger_error */
70+
function user_error(string $message, int $error_type = E_USER_NOTICE): bool {}
71+
72+
/** @return mixed */
73+
function set_error_handler($error_handler, int $error_types = E_ALL) {}
74+
75+
function restore_error_handler(): bool {}
76+
77+
/** @return mixed */
78+
function set_exception_handler($exception_handler) {}
79+
80+
function restore_exception_handler(): bool {}
81+
82+
function get_declared_classes(): array {}
83+
84+
function get_declared_traits(): array {}
85+
86+
function get_declared_interfaces(): array {}
87+
88+
function get_defined_functions(bool $exclude_disabled = false): array {}
89+
90+
function get_defined_vars(): ?array {}
91+
92+
function get_resource_type($res): string {}
93+
94+
function get_resources(string $type = UNKNOWN): array {}
95+
96+
function get_loaded_extensions(bool $zend_extensions = false): array {}
97+
98+
function get_defined_constants(bool $categorize = false): array {}
99+
100+
function debug_backtrace(int $options = DEBUG_BACKTRACE_PROVIDE_OBJECT, int $limit = 0): array {}
101+
102+
function debug_print_backtrace(int $options = 0, int $limit = 0): void {}
103+
104+
function extension_loaded(string $extension_name): bool {}
105+
106+
/** @return array|false */
107+
function get_extension_funcs(string $extension_name) {}
108+
109+
#if ZEND_DEBUG && defined(ZTS)
110+
function zend_thread_id(): int {}
111+
#endif
112+
113+
function gc_mem_caches(): int {}
114+
115+
function gc_collect_cycles(): int {}
116+
117+
function gc_enabled(): bool {}
118+
119+
function gc_enable(): void {}
120+
121+
function gc_disable(): void {}
122+
123+
function gc_status(): array {}

0 commit comments

Comments
 (0)