Skip to content

Commit 4815be4

Browse files
committed
Generate function entries from stubs
Converts ext/pcntl, ext/simplexml, ext/snmp, ext/soap, ext/sqlite3. Closes GH-5421
1 parent 8e9bc90 commit 4815be4

19 files changed

+563
-452
lines changed

ext/pcntl/pcntl.c

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -57,53 +57,10 @@
5757
ZEND_DECLARE_MODULE_GLOBALS(pcntl)
5858
static PHP_GINIT_FUNCTION(pcntl);
5959

60-
static const zend_function_entry pcntl_functions[] = {
61-
PHP_FE(pcntl_fork, arginfo_pcntl_fork)
62-
PHP_FE(pcntl_waitpid, arginfo_pcntl_waitpid)
63-
PHP_FE(pcntl_wait, arginfo_pcntl_wait)
64-
PHP_FE(pcntl_signal, arginfo_pcntl_signal)
65-
PHP_FE(pcntl_signal_get_handler, arginfo_pcntl_signal_get_handler)
66-
PHP_FE(pcntl_signal_dispatch, arginfo_pcntl_signal_dispatch)
67-
PHP_FE(pcntl_wifexited, arginfo_pcntl_wifexited)
68-
PHP_FE(pcntl_wifstopped, arginfo_pcntl_wifstopped)
69-
PHP_FE(pcntl_wifsignaled, arginfo_pcntl_wifsignaled)
70-
PHP_FE(pcntl_wexitstatus, arginfo_pcntl_wifexitstatus)
71-
PHP_FE(pcntl_wtermsig, arginfo_pcntl_wtermsig)
72-
PHP_FE(pcntl_wstopsig, arginfo_pcntl_wstopsig)
73-
PHP_FE(pcntl_exec, arginfo_pcntl_exec)
74-
PHP_FE(pcntl_alarm, arginfo_pcntl_alarm)
75-
PHP_FE(pcntl_get_last_error, arginfo_pcntl_get_last_error)
76-
PHP_FALIAS(pcntl_errno, pcntl_get_last_error, arginfo_pcntl_errno)
77-
PHP_FE(pcntl_strerror, arginfo_pcntl_strerror)
78-
#ifdef HAVE_GETPRIORITY
79-
PHP_FE(pcntl_getpriority, arginfo_pcntl_getpriority)
80-
#endif
81-
#ifdef HAVE_SETPRIORITY
82-
PHP_FE(pcntl_setpriority, arginfo_pcntl_setpriority)
83-
#endif
84-
#ifdef HAVE_SIGPROCMASK
85-
PHP_FE(pcntl_sigprocmask, arginfo_pcntl_sigprocmask)
86-
#endif
87-
#ifdef HAVE_STRUCT_SIGINFO_T
88-
# if HAVE_SIGWAITINFO && HAVE_SIGTIMEDWAIT
89-
PHP_FE(pcntl_sigwaitinfo, arginfo_pcntl_sigwaitinfo)
90-
PHP_FE(pcntl_sigtimedwait, arginfo_pcntl_sigtimedwait)
91-
# endif
92-
#endif
93-
#ifdef HAVE_WCONTINUED
94-
PHP_FE(pcntl_wifcontinued, arginfo_pcntl_wifcontinued)
95-
#endif
96-
PHP_FE(pcntl_async_signals, arginfo_pcntl_async_signals)
97-
#ifdef HAVE_UNSHARE
98-
PHP_FE(pcntl_unshare, arginfo_pcntl_unshare)
99-
#endif
100-
PHP_FE_END
101-
};
102-
10360
zend_module_entry pcntl_module_entry = {
10461
STANDARD_MODULE_HEADER,
10562
"pcntl",
106-
pcntl_functions,
63+
ext_functions,
10764
PHP_MINIT(pcntl),
10865
PHP_MSHUTDOWN(pcntl),
10966
PHP_RINIT(pcntl),

ext/pcntl/pcntl.stub.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
/** @generate-function-entries */
4+
35
function pcntl_fork(): int {}
46

57
function pcntl_waitpid(int $pid, &$status, int $options = 0, &$rusage = []): int {}
@@ -38,7 +40,7 @@ function pcntl_wifcontinued(int $status): bool {}
3840

3941
function pcntl_wifsignaled(int $status): bool {}
4042

41-
function pcntl_wifexitstatus(int $status): int|false {}
43+
function pcntl_wexitstatus(int $status): int|false {}
4244

4345
function pcntl_wtermsig(int $status): int|false {}
4446

ext/pcntl/pcntl_arginfo.h

Lines changed: 87 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ ZEND_END_ARG_INFO()
6767

6868
#define arginfo_pcntl_wifsignaled arginfo_pcntl_wifexited
6969

70-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_pcntl_wifexitstatus, 0, 1, MAY_BE_LONG|MAY_BE_FALSE)
70+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_pcntl_wexitstatus, 0, 1, MAY_BE_LONG|MAY_BE_FALSE)
7171
ZEND_ARG_TYPE_INFO(0, status, IS_LONG, 0)
7272
ZEND_END_ARG_INFO()
7373

74-
#define arginfo_pcntl_wtermsig arginfo_pcntl_wifexitstatus
74+
#define arginfo_pcntl_wtermsig arginfo_pcntl_wexitstatus
7575

76-
#define arginfo_pcntl_wstopsig arginfo_pcntl_wifexitstatus
76+
#define arginfo_pcntl_wstopsig arginfo_pcntl_wexitstatus
7777

7878
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pcntl_exec, 0, 1, _IS_BOOL, 0)
7979
ZEND_ARG_TYPE_INFO(0, path, IS_STRING, 0)
@@ -117,3 +117,87 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pcntl_unshare, 0, 1, _IS_BOOL, 0
117117
ZEND_ARG_TYPE_INFO(0, flags, IS_LONG, 0)
118118
ZEND_END_ARG_INFO()
119119
#endif
120+
121+
122+
ZEND_FUNCTION(pcntl_fork);
123+
ZEND_FUNCTION(pcntl_waitpid);
124+
ZEND_FUNCTION(pcntl_wait);
125+
ZEND_FUNCTION(pcntl_signal);
126+
ZEND_FUNCTION(pcntl_signal_get_handler);
127+
ZEND_FUNCTION(pcntl_signal_dispatch);
128+
#if defined(HAVE_SIGPROCMASK)
129+
ZEND_FUNCTION(pcntl_sigprocmask);
130+
#endif
131+
#if defined(HAVE_STRUCT_SIGINFO_T) && HAVE_SIGWAITINFO && HAVE_SIGTIMEDWAIT
132+
ZEND_FUNCTION(pcntl_sigwaitinfo);
133+
#endif
134+
#if defined(HAVE_STRUCT_SIGINFO_T) && HAVE_SIGWAITINFO && HAVE_SIGTIMEDWAIT
135+
ZEND_FUNCTION(pcntl_sigtimedwait);
136+
#endif
137+
ZEND_FUNCTION(pcntl_wifexited);
138+
ZEND_FUNCTION(pcntl_wifstopped);
139+
#if defined(HAVE_WCONTINUED)
140+
ZEND_FUNCTION(pcntl_wifcontinued);
141+
#endif
142+
ZEND_FUNCTION(pcntl_wifsignaled);
143+
ZEND_FUNCTION(pcntl_wexitstatus);
144+
ZEND_FUNCTION(pcntl_wtermsig);
145+
ZEND_FUNCTION(pcntl_wstopsig);
146+
ZEND_FUNCTION(pcntl_exec);
147+
ZEND_FUNCTION(pcntl_alarm);
148+
ZEND_FUNCTION(pcntl_get_last_error);
149+
#if defined(HAVE_GETPRIORITY)
150+
ZEND_FUNCTION(pcntl_getpriority);
151+
#endif
152+
#if defined(HAVE_SETPRIORITY)
153+
ZEND_FUNCTION(pcntl_setpriority);
154+
#endif
155+
ZEND_FUNCTION(pcntl_strerror);
156+
ZEND_FUNCTION(pcntl_async_signals);
157+
#if defined(HAVE_UNSHARE)
158+
ZEND_FUNCTION(pcntl_unshare);
159+
#endif
160+
161+
162+
static const zend_function_entry ext_functions[] = {
163+
ZEND_FE(pcntl_fork, arginfo_pcntl_fork)
164+
ZEND_FE(pcntl_waitpid, arginfo_pcntl_waitpid)
165+
ZEND_FE(pcntl_wait, arginfo_pcntl_wait)
166+
ZEND_FE(pcntl_signal, arginfo_pcntl_signal)
167+
ZEND_FE(pcntl_signal_get_handler, arginfo_pcntl_signal_get_handler)
168+
ZEND_FE(pcntl_signal_dispatch, arginfo_pcntl_signal_dispatch)
169+
#if defined(HAVE_SIGPROCMASK)
170+
ZEND_FE(pcntl_sigprocmask, arginfo_pcntl_sigprocmask)
171+
#endif
172+
#if defined(HAVE_STRUCT_SIGINFO_T) && HAVE_SIGWAITINFO && HAVE_SIGTIMEDWAIT
173+
ZEND_FE(pcntl_sigwaitinfo, arginfo_pcntl_sigwaitinfo)
174+
#endif
175+
#if defined(HAVE_STRUCT_SIGINFO_T) && HAVE_SIGWAITINFO && HAVE_SIGTIMEDWAIT
176+
ZEND_FE(pcntl_sigtimedwait, arginfo_pcntl_sigtimedwait)
177+
#endif
178+
ZEND_FE(pcntl_wifexited, arginfo_pcntl_wifexited)
179+
ZEND_FE(pcntl_wifstopped, arginfo_pcntl_wifstopped)
180+
#if defined(HAVE_WCONTINUED)
181+
ZEND_FE(pcntl_wifcontinued, arginfo_pcntl_wifcontinued)
182+
#endif
183+
ZEND_FE(pcntl_wifsignaled, arginfo_pcntl_wifsignaled)
184+
ZEND_FE(pcntl_wexitstatus, arginfo_pcntl_wexitstatus)
185+
ZEND_FE(pcntl_wtermsig, arginfo_pcntl_wtermsig)
186+
ZEND_FE(pcntl_wstopsig, arginfo_pcntl_wstopsig)
187+
ZEND_FE(pcntl_exec, arginfo_pcntl_exec)
188+
ZEND_FE(pcntl_alarm, arginfo_pcntl_alarm)
189+
ZEND_FE(pcntl_get_last_error, arginfo_pcntl_get_last_error)
190+
ZEND_FALIAS(pcntl_errno, pcntl_get_last_error, arginfo_pcntl_errno)
191+
#if defined(HAVE_GETPRIORITY)
192+
ZEND_FE(pcntl_getpriority, arginfo_pcntl_getpriority)
193+
#endif
194+
#if defined(HAVE_SETPRIORITY)
195+
ZEND_FE(pcntl_setpriority, arginfo_pcntl_setpriority)
196+
#endif
197+
ZEND_FE(pcntl_strerror, arginfo_pcntl_strerror)
198+
ZEND_FE(pcntl_async_signals, arginfo_pcntl_async_signals)
199+
#if defined(HAVE_UNSHARE)
200+
ZEND_FE(pcntl_unshare, arginfo_pcntl_unshare)
201+
#endif
202+
ZEND_FE_END
203+
};

ext/simplexml/simplexml.c

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ PHP_SXE_API zend_class_entry *sxe_get_element_class_entry() /* {{{ */
4444
#define SXE_ME(func, arg_info, flags) PHP_ME(simplexml_element, func, arg_info, flags)
4545
#define SXE_MALIAS(func, alias, arg_info, flags) PHP_MALIAS(simplexml_element, func, alias, arg_info, flags)
4646

47-
#define SXE_METHOD(func) PHP_METHOD(simplexml_element, func)
47+
#define SXE_METHOD(func) PHP_METHOD(SimpleXMLElement, func)
4848

4949
static php_sxe_object* php_sxe_object_new(zend_class_entry *ce, zend_function *fptr_count);
5050
static xmlNodePtr php_sxe_reset_iterator(php_sxe_object *sxe, int use_data);
@@ -2576,14 +2576,6 @@ PHP_FUNCTION(simplexml_import_dom)
25762576
}
25772577
/* }}} */
25782578

2579-
static const zend_function_entry simplexml_functions[] = { /* {{{ */
2580-
PHP_FE(simplexml_load_file, arginfo_simplexml_load_file)
2581-
PHP_FE(simplexml_load_string, arginfo_simplexml_load_string)
2582-
PHP_FE(simplexml_import_dom, arginfo_simplexml_import_dom)
2583-
PHP_FE_END
2584-
};
2585-
/* }}} */
2586-
25872579
static const zend_module_dep simplexml_deps[] = { /* {{{ */
25882580
ZEND_MOD_REQUIRED("libxml")
25892581
ZEND_MOD_REQUIRED("spl")
@@ -2595,7 +2587,7 @@ zend_module_entry simplexml_module_entry = { /* {{{ */
25952587
STANDARD_MODULE_HEADER_EX, NULL,
25962588
simplexml_deps,
25972589
"SimpleXML",
2598-
simplexml_functions,
2590+
ext_functions,
25992591
PHP_MINIT(simplexml),
26002592
PHP_MSHUTDOWN(simplexml),
26012593
NULL,
@@ -2610,34 +2602,13 @@ zend_module_entry simplexml_module_entry = { /* {{{ */
26102602
ZEND_GET_MODULE(simplexml)
26112603
#endif
26122604

2613-
/* the method table */
2614-
/* each method can have its own parameters and visibility */
2615-
static const zend_function_entry sxe_functions[] = { /* {{{ */
2616-
SXE_ME(__construct, arginfo_class_SimpleXMLElement___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL) /* must be called */
2617-
SXE_ME(asXML, arginfo_class_SimpleXMLElement_asXML, ZEND_ACC_PUBLIC)
2618-
SXE_MALIAS(saveXML, asXML, arginfo_class_SimpleXMLElement_saveXML, ZEND_ACC_PUBLIC)
2619-
SXE_ME(xpath, arginfo_class_SimpleXMLElement_xpath, ZEND_ACC_PUBLIC)
2620-
SXE_ME(registerXPathNamespace, arginfo_class_SimpleXMLElement_registerXPathNamespace, ZEND_ACC_PUBLIC)
2621-
SXE_ME(attributes, arginfo_class_SimpleXMLElement_attributes, ZEND_ACC_PUBLIC)
2622-
SXE_ME(children, arginfo_class_SimpleXMLElement_children, ZEND_ACC_PUBLIC)
2623-
SXE_ME(getNamespaces, arginfo_class_SimpleXMLElement_getNamespaces, ZEND_ACC_PUBLIC)
2624-
SXE_ME(getDocNamespaces, arginfo_class_SimpleXMLElement_getDocNamespaces, ZEND_ACC_PUBLIC)
2625-
SXE_ME(getName, arginfo_class_SimpleXMLElement_getName, ZEND_ACC_PUBLIC)
2626-
SXE_ME(addChild, arginfo_class_SimpleXMLElement_addChild, ZEND_ACC_PUBLIC)
2627-
SXE_ME(addAttribute, arginfo_class_SimpleXMLElement_addAttribute, ZEND_ACC_PUBLIC)
2628-
SXE_ME(__toString, arginfo_class_SimpleXMLElement___toString, ZEND_ACC_PUBLIC)
2629-
SXE_ME(count, arginfo_class_SimpleXMLElement_count, ZEND_ACC_PUBLIC)
2630-
PHP_FE_END
2631-
};
2632-
/* }}} */
2633-
26342605
/* {{{ PHP_MINIT_FUNCTION(simplexml)
26352606
*/
26362607
PHP_MINIT_FUNCTION(simplexml)
26372608
{
26382609
zend_class_entry sxe;
26392610

2640-
INIT_CLASS_ENTRY(sxe, "SimpleXMLElement", sxe_functions);
2611+
INIT_CLASS_ENTRY(sxe, "SimpleXMLElement", class_SimpleXMLElement_methods);
26412612
sxe.create_object = sxe_object_new;
26422613
sxe_class_entry = zend_register_internal_class(&sxe);
26432614
sxe_class_entry->get_iterator = php_sxe_get_iterator;

ext/simplexml/simplexml.stub.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
/** @generate-function-entries */
4+
35
function simplexml_load_file(string $filename, ?string $class_name = SimpleXMLElement::class, int $options = 0, string $ns = '', bool $is_prefix = false): SimpleXMLElement|false {}
46

57
function simplexml_load_string(string $data, ?string $class_name = SimpleXMLElement::class, int $options = 0, string $ns = '', bool $is_prefix = false): SimpleXMLElement|false {}
@@ -17,7 +19,10 @@ public function registerXPathNamespace(string $prefix, string $ns) {}
1719
/** @return string|bool */
1820
public function asXML(string $filename = UNKNOWN) {}
1921

20-
/** @return string|bool */
22+
/**
23+
* @return string|bool
24+
* @alias SimpleXMLElement::asXML
25+
*/
2126
public function saveXML(string $filename = UNKNOWN) {}
2227

2328
/** @return array */

ext/simplexml/simplexml_arginfo.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,48 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SimpleXMLElement___toStrin
7575
ZEND_END_ARG_INFO()
7676

7777
#define arginfo_class_SimpleXMLElement_count arginfo_class_SimpleXMLElement_getName
78+
79+
80+
ZEND_FUNCTION(simplexml_load_file);
81+
ZEND_FUNCTION(simplexml_load_string);
82+
ZEND_FUNCTION(simplexml_import_dom);
83+
ZEND_METHOD(SimpleXMLElement, xpath);
84+
ZEND_METHOD(SimpleXMLElement, registerXPathNamespace);
85+
ZEND_METHOD(SimpleXMLElement, asXML);
86+
ZEND_METHOD(SimpleXMLElement, getNamespaces);
87+
ZEND_METHOD(SimpleXMLElement, getDocNamespaces);
88+
ZEND_METHOD(SimpleXMLElement, children);
89+
ZEND_METHOD(SimpleXMLElement, attributes);
90+
ZEND_METHOD(SimpleXMLElement, __construct);
91+
ZEND_METHOD(SimpleXMLElement, addChild);
92+
ZEND_METHOD(SimpleXMLElement, addAttribute);
93+
ZEND_METHOD(SimpleXMLElement, getName);
94+
ZEND_METHOD(SimpleXMLElement, __toString);
95+
ZEND_METHOD(SimpleXMLElement, count);
96+
97+
98+
static const zend_function_entry ext_functions[] = {
99+
ZEND_FE(simplexml_load_file, arginfo_simplexml_load_file)
100+
ZEND_FE(simplexml_load_string, arginfo_simplexml_load_string)
101+
ZEND_FE(simplexml_import_dom, arginfo_simplexml_import_dom)
102+
ZEND_FE_END
103+
};
104+
105+
106+
static const zend_function_entry class_SimpleXMLElement_methods[] = {
107+
ZEND_ME(SimpleXMLElement, xpath, arginfo_class_SimpleXMLElement_xpath, ZEND_ACC_PUBLIC)
108+
ZEND_ME(SimpleXMLElement, registerXPathNamespace, arginfo_class_SimpleXMLElement_registerXPathNamespace, ZEND_ACC_PUBLIC)
109+
ZEND_ME(SimpleXMLElement, asXML, arginfo_class_SimpleXMLElement_asXML, ZEND_ACC_PUBLIC)
110+
ZEND_MALIAS(SimpleXMLElement, saveXML, asXML, arginfo_class_SimpleXMLElement_saveXML, ZEND_ACC_PUBLIC)
111+
ZEND_ME(SimpleXMLElement, getNamespaces, arginfo_class_SimpleXMLElement_getNamespaces, ZEND_ACC_PUBLIC)
112+
ZEND_ME(SimpleXMLElement, getDocNamespaces, arginfo_class_SimpleXMLElement_getDocNamespaces, ZEND_ACC_PUBLIC)
113+
ZEND_ME(SimpleXMLElement, children, arginfo_class_SimpleXMLElement_children, ZEND_ACC_PUBLIC)
114+
ZEND_ME(SimpleXMLElement, attributes, arginfo_class_SimpleXMLElement_attributes, ZEND_ACC_PUBLIC)
115+
ZEND_ME(SimpleXMLElement, __construct, arginfo_class_SimpleXMLElement___construct, ZEND_ACC_PUBLIC)
116+
ZEND_ME(SimpleXMLElement, addChild, arginfo_class_SimpleXMLElement_addChild, ZEND_ACC_PUBLIC)
117+
ZEND_ME(SimpleXMLElement, addAttribute, arginfo_class_SimpleXMLElement_addAttribute, ZEND_ACC_PUBLIC)
118+
ZEND_ME(SimpleXMLElement, getName, arginfo_class_SimpleXMLElement_getName, ZEND_ACC_PUBLIC)
119+
ZEND_ME(SimpleXMLElement, __toString, arginfo_class_SimpleXMLElement___toString, ZEND_ACC_PUBLIC)
120+
ZEND_ME(SimpleXMLElement, count, arginfo_class_SimpleXMLElement_count, ZEND_ACC_PUBLIC)
121+
ZEND_FE_END
122+
};

0 commit comments

Comments
 (0)