Skip to content

Commit 93a2730

Browse files
committed
Add stubs for SAPIs
1 parent add8c15 commit 93a2730

21 files changed

+163
-75
lines changed

ext/standard/dl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#endif
3939
#endif /* defined(HAVE_LIBDL) */
4040

41-
/* {{{ proto int dl(string extension_filename)
41+
/* {{{ proto bool dl(string extension_filename)
4242
Load a PHP extension at runtime */
4343
PHPAPI PHP_FUNCTION(dl)
4444
{

ext/standard/dl.stub.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
function dl(string $extension_filename): bool {}

ext/standard/dl_arginfo.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/* This is a generated file, edit the .stub.php file instead. */
2+
3+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_dl, 0, 1, _IS_BOOL, 0)
4+
ZEND_ARG_TYPE_INFO(0, extension_filename, IS_STRING, 0)
5+
ZEND_END_ARG_INFO()

sapi/cgi/cgi_main.c

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
#include "fopen_wrappers.h"
6464
#include "http_status_codes.h"
6565
#include "ext/standard/php_standard.h"
66+
#include "ext/standard/dl_arginfo.h"
6667
#include "ext/standard/url.h"
6768

6869
#ifdef PHP_WIN32
@@ -83,6 +84,7 @@ int __riscosify_control = __RISCOSIFY_STRICT_UNIX_SPECS;
8384
#include "php_getopt.h"
8485

8586
#include "fastcgi.h"
87+
#include "cgi_main_arginfo.h"
8688

8789
#if defined(PHP_WIN32) && defined(HAVE_OPENSSL)
8890
# include "openssl/applink.c"
@@ -1004,12 +1006,6 @@ static sapi_module_struct cgi_sapi_module = {
10041006
};
10051007
/* }}} */
10061008

1007-
/* {{{ arginfo ext/standard/dl.c */
1008-
ZEND_BEGIN_ARG_INFO(arginfo_dl, 0)
1009-
ZEND_ARG_INFO(0, extension_filename)
1010-
ZEND_END_ARG_INFO()
1011-
/* }}} */
1012-
10131009
static const zend_function_entry additional_functions[] = {
10141010
ZEND_FE(dl, arginfo_dl)
10151011
PHP_FE_END
@@ -1707,14 +1703,11 @@ PHP_FUNCTION(apache_response_headers) /* {{{ */
17071703
}
17081704
/* }}} */
17091705

1710-
ZEND_BEGIN_ARG_INFO(arginfo_no_args, 0)
1711-
ZEND_END_ARG_INFO()
1712-
17131706
static const zend_function_entry cgi_functions[] = {
1714-
PHP_FE(apache_child_terminate, arginfo_no_args)
1715-
PHP_FE(apache_request_headers, arginfo_no_args)
1716-
PHP_FE(apache_response_headers, arginfo_no_args)
1717-
PHP_FALIAS(getallheaders, apache_request_headers, arginfo_no_args)
1707+
PHP_FE(apache_child_terminate, arginfo_apache_child_terminate)
1708+
PHP_FE(apache_request_headers, arginfo_apache_request_headers)
1709+
PHP_FE(apache_response_headers, arginfo_apache_response_headers)
1710+
PHP_FALIAS(getallheaders, apache_request_headers, arginfo_getallheaders)
17181711
PHP_FE_END
17191712
};
17201713

sapi/cgi/cgi_main.stub.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
function apache_child_terminate(): void {}
4+
5+
function apache_request_headers(): array {}
6+
7+
function getallheaders(): array {}
8+
9+
function apache_response_headers(): array {}

sapi/cgi/cgi_main_arginfo.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* This is a generated file, edit the .stub.php file instead. */
2+
3+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_apache_child_terminate, 0, 0, IS_VOID, 0)
4+
ZEND_END_ARG_INFO()
5+
6+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_apache_request_headers, 0, 0, IS_ARRAY, 0)
7+
ZEND_END_ARG_INFO()
8+
9+
#define arginfo_getallheaders arginfo_apache_request_headers
10+
11+
#define arginfo_apache_response_headers arginfo_apache_request_headers
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/* This is a generated file, edit the .stub.php file instead. */
2+
3+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_cli_set_process_title, 0, 1, _IS_BOOL, 0)
4+
ZEND_ARG_TYPE_INFO(0, title, IS_STRING, 0)
5+
ZEND_END_ARG_INFO()
6+
7+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_cli_get_process_title, 0, 0, IS_STRING, 1)
8+
ZEND_END_ARG_INFO()

sapi/cli/php_cli.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
#include "php_main.h"
5555
#include "fopen_wrappers.h"
5656
#include "ext/standard/php_standard.h"
57+
#include "ext/standard/dl_arginfo.h"
5758
#include "cli.h"
5859
#ifdef PHP_WIN32
5960
#include <io.h>
@@ -78,6 +79,7 @@
7879

7980
#include "ps_title.h"
8081
#include "php_cli_process_title.h"
82+
#include "php_cli_process_title_arginfo.h"
8183

8284
#ifndef PHP_WIN32
8385
# define php_select(m, r, w, e, t) select(m, r, w, e, t)
@@ -455,12 +457,6 @@ static sapi_module_struct cli_sapi_module = {
455457
};
456458
/* }}} */
457459

458-
/* {{{ arginfo ext/standard/dl.c */
459-
ZEND_BEGIN_ARG_INFO(arginfo_dl, 0)
460-
ZEND_ARG_INFO(0, extension_filename)
461-
ZEND_END_ARG_INFO()
462-
/* }}} */
463-
464460
static const zend_function_entry additional_functions[] = {
465461
ZEND_FE(dl, arginfo_dl)
466462
PHP_FE(cli_set_process_title, arginfo_cli_set_process_title)

sapi/cli/php_cli_process_title.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,6 @@
1717
#ifndef PHP_PS_TITLE_HEADER
1818
#define PHP_PS_TITLE_HEADER
1919

20-
ZEND_BEGIN_ARG_INFO(arginfo_cli_set_process_title, 0)
21-
ZEND_ARG_INFO(0, title)
22-
ZEND_END_ARG_INFO()
23-
24-
ZEND_BEGIN_ARG_INFO(arginfo_cli_get_process_title, 0)
25-
ZEND_END_ARG_INFO()
26-
2720
PHP_FUNCTION(cli_set_process_title);
2821
PHP_FUNCTION(cli_get_process_title);
2922

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
function cli_set_process_title(string $title): bool {}
4+
5+
function cli_get_process_title(): ?string {}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/* This is a generated file, edit the .stub.php file instead. */
2+
3+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_cli_set_process_title, 0, 1, _IS_BOOL, 0)
4+
ZEND_ARG_TYPE_INFO(0, title, IS_STRING, 0)
5+
ZEND_END_ARG_INFO()
6+
7+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_cli_get_process_title, 0, 0, IS_STRING, 1)
8+
ZEND_END_ARG_INFO()

sapi/cli/php_cli_server.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,11 @@
9191

9292
#include "php_http_parser.h"
9393
#include "php_cli_server.h"
94+
#include "php_cli_server_arginfo.h"
9495
#include "mime_type_map.h"
9596

9697
#include "php_cli_process_title.h"
98+
#include "php_cli_process_title_arginfo.h"
9799

98100
#define OUTPUT_NOT_CHECKED -1
99101
#define OUTPUT_IS_TTY 1
@@ -480,15 +482,12 @@ zend_module_entry cli_server_module_entry = {
480482
};
481483
/* }}} */
482484

483-
ZEND_BEGIN_ARG_INFO(arginfo_no_args, 0)
484-
ZEND_END_ARG_INFO()
485-
486485
const zend_function_entry server_additional_functions[] = {
487-
PHP_FE(cli_set_process_title, arginfo_cli_set_process_title)
488-
PHP_FE(cli_get_process_title, arginfo_cli_get_process_title)
489-
PHP_FE(apache_request_headers, arginfo_no_args)
490-
PHP_FE(apache_response_headers, arginfo_no_args)
491-
PHP_FALIAS(getallheaders, apache_request_headers, arginfo_no_args)
486+
PHP_FE(cli_set_process_title, arginfo_cli_set_process_title)
487+
PHP_FE(cli_get_process_title, arginfo_cli_get_process_title)
488+
PHP_FE(apache_request_headers, arginfo_apache_request_headers)
489+
PHP_FE(apache_response_headers, arginfo_apache_response_headers)
490+
PHP_FALIAS(getallheaders, apache_request_headers, arginfo_getallheaders)
492491
PHP_FE_END
493492
};
494493

sapi/cli/php_cli_server.stub.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
function apache_request_headers(): array {}
4+
5+
function apache_response_headers(): array {}
6+
7+
function getallheaders(): array {}

sapi/cli/php_cli_server_arginfo.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/* This is a generated file, edit the .stub.php file instead. */
2+
3+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_apache_request_headers, 0, 0, IS_ARRAY, 0)
4+
ZEND_END_ARG_INFO()
5+
6+
#define arginfo_apache_response_headers arginfo_apache_request_headers
7+
8+
#define arginfo_getallheaders arginfo_apache_request_headers

sapi/embed/php_embed.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include "php_embed.h"
1818
#include "ext/standard/php_standard.h"
19+
#include "ext/standard/dl_arginfo.h"
1920

2021
#ifdef PHP_WIN32
2122
#include <io.h>
@@ -142,12 +143,6 @@ EMBED_SAPI_API sapi_module_struct php_embed_module = {
142143
};
143144
/* }}} */
144145

145-
/* {{{ arginfo ext/standard/dl.c */
146-
ZEND_BEGIN_ARG_INFO(arginfo_dl, 0)
147-
ZEND_ARG_INFO(0, extension_filename)
148-
ZEND_END_ARG_INFO()
149-
/* }}} */
150-
151146
static const zend_function_entry additional_functions[] = {
152147
ZEND_FE(dl, arginfo_dl)
153148
{NULL, NULL, NULL}

sapi/fpm/fpm/fpm_main.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ int __riscosify_control = __RISCOSIFY_STRICT_UNIX_SPECS;
8282

8383
#include <php_config.h>
8484
#include "fpm.h"
85+
#include "fpm_main_arginfo.h"
8586
#include "fpm_request.h"
8687
#include "fpm_status.h"
8788
#include "fpm_signals.h"
@@ -1457,9 +1458,6 @@ static PHP_MINFO_FUNCTION(cgi)
14571458
}
14581459
/* }}} */
14591460

1460-
ZEND_BEGIN_ARG_INFO(cgi_fcgi_sapi_no_arginfo, 0)
1461-
ZEND_END_ARG_INFO()
1462-
14631461
PHP_FUNCTION(fastcgi_finish_request) /* {{{ */
14641462
{
14651463
fcgi_request *request = (fcgi_request*) SG(server_context);
@@ -1511,10 +1509,10 @@ PHP_FUNCTION(fpm_get_status) /* {{{ */
15111509
/* }}} */
15121510

15131511
static const zend_function_entry cgi_fcgi_sapi_functions[] = {
1514-
PHP_FE(fastcgi_finish_request, cgi_fcgi_sapi_no_arginfo)
1515-
PHP_FE(fpm_get_status, cgi_fcgi_sapi_no_arginfo)
1516-
PHP_FE(apache_request_headers, cgi_fcgi_sapi_no_arginfo)
1517-
PHP_FALIAS(getallheaders, apache_request_headers, cgi_fcgi_sapi_no_arginfo)
1512+
PHP_FE(fastcgi_finish_request, arginfo_fastcgi_finish_request)
1513+
PHP_FE(fpm_get_status, arginfo_fpm_get_status)
1514+
PHP_FE(apache_request_headers, arginfo_apache_request_headers)
1515+
PHP_FALIAS(getallheaders, apache_request_headers, arginfo_getallheaders)
15181516
PHP_FE_END
15191517
};
15201518

sapi/fpm/fpm/fpm_main.stub.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
function fastcgi_finish_request(): bool {}
4+
5+
function apache_request_headers(): array {}
6+
7+
function getallheaders(): array {}
8+
9+
function fpm_get_status(): array|false {}

sapi/fpm/fpm/fpm_main_arginfo.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* This is a generated file, edit the .stub.php file instead. */
2+
3+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_fastcgi_finish_request, 0, 0, _IS_BOOL, 0)
4+
ZEND_END_ARG_INFO()
5+
6+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_apache_request_headers, 0, 0, IS_ARRAY, 0)
7+
ZEND_END_ARG_INFO()
8+
9+
#define arginfo_getallheaders arginfo_apache_request_headers
10+
11+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_fpm_get_status, 0, 0, MAY_BE_ARRAY|MAY_BE_FALSE)
12+
ZEND_END_ARG_INFO()

sapi/litespeed/lsapi_main.c

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "ext/standard/basic_functions.h"
2525
#include "ext/standard/info.h"
2626
#include "lsapilib.h"
27+
#include "lsapi_main_arginfo.h"
2728

2829
#include <stdio.h>
2930
#include <stdlib.h>
@@ -1615,11 +1616,6 @@ int main( int argc, char * argv[] )
16151616

16161617
/* LiteSpeed PHP module starts here */
16171618

1618-
/* {{{ arginfo */
1619-
ZEND_BEGIN_ARG_INFO(arginfo_litespeed__void, 0)
1620-
ZEND_END_ARG_INFO()
1621-
/* }}} */
1622-
16231619
PHP_FUNCTION(litespeed_request_headers);
16241620
PHP_FUNCTION(litespeed_response_headers);
16251621
PHP_FUNCTION(apache_get_modules);
@@ -1628,13 +1624,13 @@ PHP_FUNCTION(litespeed_finish_request);
16281624
PHP_MINFO_FUNCTION(litespeed);
16291625

16301626
static const zend_function_entry litespeed_functions[] = {
1631-
PHP_FE(litespeed_request_headers, arginfo_litespeed__void)
1632-
PHP_FE(litespeed_response_headers, arginfo_litespeed__void)
1633-
PHP_FE(apache_get_modules, arginfo_litespeed__void)
1634-
PHP_FE(litespeed_finish_request, arginfo_litespeed__void)
1635-
PHP_FALIAS(getallheaders, litespeed_request_headers, arginfo_litespeed__void)
1636-
PHP_FALIAS(apache_request_headers, litespeed_request_headers, arginfo_litespeed__void)
1637-
PHP_FALIAS(apache_response_headers, litespeed_response_headers, arginfo_litespeed__void)
1627+
PHP_FE(litespeed_request_headers, arginfo_litespeed_request_headers)
1628+
PHP_FE(litespeed_response_headers, arginfo_litespeed_response_headers)
1629+
PHP_FE(apache_get_modules, arginfo_apache_get_modules)
1630+
PHP_FE(litespeed_finish_request, arginfo_litespeed_finish_request)
1631+
PHP_FALIAS(getallheaders, litespeed_request_headers, arginfo_getallheaders)
1632+
PHP_FALIAS(apache_request_headers, litespeed_request_headers, arginfo_apache_request_headers)
1633+
PHP_FALIAS(apache_response_headers, litespeed_response_headers, arginfo_apache_response_headers)
16381634
{NULL, NULL, NULL}
16391635
};
16401636

@@ -1697,14 +1693,13 @@ static int add_associate_array( const char * pKey, int keyLen, const char * pVal
16971693
Fetch all HTTP request headers */
16981694
PHP_FUNCTION(litespeed_request_headers)
16991695
{
1700-
/* TODO: */
1701-
if (ZEND_NUM_ARGS() > 0) {
1702-
WRONG_PARAM_COUNT;
1696+
if (zend_parse_parameters_none() == FAILURE) {
1697+
RETURN_THROWS();
17031698
}
1699+
17041700
array_init(return_value);
17051701

17061702
LSAPI_ForeachOrgHeader( add_associate_array, return_value );
1707-
17081703
}
17091704
/* }}} */
17101705

@@ -1720,9 +1715,9 @@ PHP_FUNCTION(litespeed_response_headers)
17201715
int len;
17211716
char headerBuf[SAPI_LSAPI_MAX_HEADER_LENGTH];
17221717

1723-
if (ZEND_NUM_ARGS() > 0) {
1724-
WRONG_PARAM_COUNT;
1725-
}
1718+
if (zend_parse_parameters_none() == FAILURE) {
1719+
RETURN_THROWS();
1720+
}
17261721

17271722
if (!&SG(sapi_headers).headers) {
17281723
RETURN_FALSE;
@@ -1762,10 +1757,11 @@ PHP_FUNCTION(apache_get_modules)
17621757
"mod_rewrite", "mod_mime", "mod_headers", "mod_expires", "mod_auth_basic", NULL
17631758
};
17641759
const char **name = mod_names;
1765-
/* TODO: */
1766-
if (ZEND_NUM_ARGS() > 0) {
1767-
WRONG_PARAM_COUNT;
1768-
}
1760+
1761+
if (zend_parse_parameters_none() == FAILURE) {
1762+
RETURN_THROWS();
1763+
}
1764+
17691765
array_init(return_value);
17701766
while( *name )
17711767
{
@@ -1776,13 +1772,13 @@ PHP_FUNCTION(apache_get_modules)
17761772
/* }}} */
17771773

17781774

1779-
/* {{{ proto array litespeed_finish_request(void)
1775+
/* {{{ proto bool litespeed_finish_request(void)
17801776
Flushes all response data to the client */
17811777
PHP_FUNCTION(litespeed_finish_request)
17821778
{
1783-
if (ZEND_NUM_ARGS() > 0) {
1784-
WRONG_PARAM_COUNT;
1785-
}
1779+
if (zend_parse_parameters_none() == FAILURE) {
1780+
RETURN_THROWS();
1781+
}
17861782

17871783
php_output_end_all();
17881784
php_header();

0 commit comments

Comments
 (0)