Add stubs for some SAPIs

For apache2handler, fpm, litespeed, phpdbg, specifically.
Partially implements GH-5295
This commit is contained in:
Máté Kocsis 2020-05-14 13:31:52 +02:00
parent 161ee110bf
commit 68527a7834
No known key found for this signature in database
GPG key ID: FD055E41728BF310
15 changed files with 195 additions and 91 deletions

View file

@ -38,7 +38,7 @@
#endif
#endif /* defined(HAVE_LIBDL) */
/* {{{ proto int dl(string extension_filename)
/* {{{ proto bool dl(string extension_filename)
Load a PHP extension at runtime */
PHPAPI PHP_FUNCTION(dl)
{

3
ext/standard/dl.stub.php Normal file
View file

@ -0,0 +1,3 @@
<?php
function dl(string $extension_filename): bool {}

View file

@ -0,0 +1,5 @@
/* This is a generated file, edit the .stub.php file instead. */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_dl, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, extension_filename, IS_STRING, 0)
ZEND_END_ARG_INFO()

View file

@ -476,20 +476,6 @@ PHP_MINFO_FUNCTION(apache)
}
}
static const zend_function_entry apache_functions[] = {
PHP_FE(apache_lookup_uri, arginfo_apache_lookup_uri)
PHP_FE(virtual, arginfo_virtual)
PHP_FE(apache_request_headers, arginfo_apache_request_headers)
PHP_FE(apache_response_headers, arginfo_apache_response_headers)
PHP_FE(apache_setenv, arginfo_apache_setenv)
PHP_FE(apache_getenv, arginfo_apache_getenv)
PHP_FE(apache_note, arginfo_apache_note)
PHP_FE(apache_get_version, arginfo_apache_get_version)
PHP_FE(apache_get_modules, arginfo_apache_get_modules)
PHP_FALIAS(getallheaders, apache_request_headers, arginfo_getallheaders)
{NULL, NULL, NULL}
};
PHP_INI_BEGIN()
STD_PHP_INI_ENTRY("xbithack", "0", PHP_INI_ALL, OnUpdateBool, xbithack, php_apache2_info_struct, php_apache2_info)
STD_PHP_INI_ENTRY("engine", "1", PHP_INI_ALL, OnUpdateBool, engine, php_apache2_info_struct, php_apache2_info)
@ -514,7 +500,7 @@ static PHP_MSHUTDOWN_FUNCTION(apache)
zend_module_entry php_apache_module = {
STANDARD_MODULE_HEADER,
"apache2handler",
apache_functions,
ext_functions,
PHP_MINIT(apache),
PHP_MSHUTDOWN(apache),
NULL,

View file

@ -1,11 +1,14 @@
<?php
/** @generate-function-entries */
function apache_lookup_uri(string $filename): object|false {}
function virtual(string $uri): bool {}
function apache_request_headers(): array {}
/** @alias apache_request_headers */
function getallheaders(): array {}
function apache_response_headers(): array {}

View file

@ -35,3 +35,29 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_apache_get_version, 0, 0, MAY_BE
ZEND_END_ARG_INFO()
#define arginfo_apache_get_modules arginfo_apache_request_headers
ZEND_FUNCTION(apache_lookup_uri);
ZEND_FUNCTION(virtual);
ZEND_FUNCTION(apache_request_headers);
ZEND_FUNCTION(apache_response_headers);
ZEND_FUNCTION(apache_note);
ZEND_FUNCTION(apache_setenv);
ZEND_FUNCTION(apache_getenv);
ZEND_FUNCTION(apache_get_version);
ZEND_FUNCTION(apache_get_modules);
static const zend_function_entry ext_functions[] = {
ZEND_FE(apache_lookup_uri, arginfo_apache_lookup_uri)
ZEND_FE(virtual, arginfo_virtual)
ZEND_FE(apache_request_headers, arginfo_apache_request_headers)
ZEND_FALIAS(getallheaders, apache_request_headers, arginfo_getallheaders)
ZEND_FE(apache_response_headers, arginfo_apache_response_headers)
ZEND_FE(apache_note, arginfo_apache_note)
ZEND_FE(apache_setenv, arginfo_apache_setenv)
ZEND_FE(apache_getenv, arginfo_apache_getenv)
ZEND_FE(apache_get_version, arginfo_apache_get_version)
ZEND_FE(apache_get_modules, arginfo_apache_get_modules)
ZEND_FE_END
};

View file

@ -82,6 +82,7 @@ int __riscosify_control = __RISCOSIFY_STRICT_UNIX_SPECS;
#include <php_config.h>
#include "fpm.h"
#include "fpm_main_arginfo.h"
#include "fpm_request.h"
#include "fpm_status.h"
#include "fpm_signals.h"
@ -1457,9 +1458,6 @@ static PHP_MINFO_FUNCTION(cgi)
}
/* }}} */
ZEND_BEGIN_ARG_INFO(cgi_fcgi_sapi_no_arginfo, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(fastcgi_finish_request) /* {{{ */
{
fcgi_request *request = (fcgi_request*) SG(server_context);
@ -1510,18 +1508,10 @@ PHP_FUNCTION(fpm_get_status) /* {{{ */
}
/* }}} */
static const zend_function_entry cgi_fcgi_sapi_functions[] = {
PHP_FE(fastcgi_finish_request, cgi_fcgi_sapi_no_arginfo)
PHP_FE(fpm_get_status, cgi_fcgi_sapi_no_arginfo)
PHP_FE(apache_request_headers, cgi_fcgi_sapi_no_arginfo)
PHP_FALIAS(getallheaders, apache_request_headers, cgi_fcgi_sapi_no_arginfo)
PHP_FE_END
};
static zend_module_entry cgi_module_entry = {
STANDARD_MODULE_HEADER,
"cgi-fcgi",
cgi_fcgi_sapi_functions,
ext_functions,
PHP_MINIT(cgi),
PHP_MSHUTDOWN(cgi),
NULL,

View file

@ -0,0 +1,12 @@
<?php
/** @generate-function-entries */
function fastcgi_finish_request(): bool {}
function apache_request_headers(): array {}
/** @alias apache_request_headers */
function getallheaders(): array {}
function fpm_get_status(): array|false {}

View file

@ -0,0 +1,26 @@
/* This is a generated file, edit the .stub.php file instead. */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_fastcgi_finish_request, 0, 0, _IS_BOOL, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_apache_request_headers, 0, 0, IS_ARRAY, 0)
ZEND_END_ARG_INFO()
#define arginfo_getallheaders arginfo_apache_request_headers
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_fpm_get_status, 0, 0, MAY_BE_ARRAY|MAY_BE_FALSE)
ZEND_END_ARG_INFO()
ZEND_FUNCTION(fastcgi_finish_request);
ZEND_FUNCTION(apache_request_headers);
ZEND_FUNCTION(fpm_get_status);
static const zend_function_entry ext_functions[] = {
ZEND_FE(fastcgi_finish_request, arginfo_fastcgi_finish_request)
ZEND_FE(apache_request_headers, arginfo_apache_request_headers)
ZEND_FALIAS(getallheaders, apache_request_headers, arginfo_getallheaders)
ZEND_FE(fpm_get_status, arginfo_fpm_get_status)
ZEND_FE_END
};

View file

@ -24,6 +24,7 @@
#include "ext/standard/basic_functions.h"
#include "ext/standard/info.h"
#include "lsapilib.h"
#include "lsapi_main_arginfo.h"
#include <stdio.h>
#include <stdlib.h>
@ -1615,11 +1616,6 @@ int main( int argc, char * argv[] )
/* LiteSpeed PHP module starts here */
/* {{{ arginfo */
ZEND_BEGIN_ARG_INFO(arginfo_litespeed__void, 0)
ZEND_END_ARG_INFO()
/* }}} */
PHP_FUNCTION(litespeed_request_headers);
PHP_FUNCTION(litespeed_response_headers);
PHP_FUNCTION(apache_get_modules);
@ -1627,17 +1623,6 @@ PHP_FUNCTION(litespeed_finish_request);
PHP_MINFO_FUNCTION(litespeed);
static const zend_function_entry litespeed_functions[] = {
PHP_FE(litespeed_request_headers, arginfo_litespeed__void)
PHP_FE(litespeed_response_headers, arginfo_litespeed__void)
PHP_FE(apache_get_modules, arginfo_litespeed__void)
PHP_FE(litespeed_finish_request, arginfo_litespeed__void)
PHP_FALIAS(getallheaders, litespeed_request_headers, arginfo_litespeed__void)
PHP_FALIAS(apache_request_headers, litespeed_request_headers, arginfo_litespeed__void)
PHP_FALIAS(apache_response_headers, litespeed_response_headers, arginfo_litespeed__void)
{NULL, NULL, NULL}
};
static PHP_MINIT_FUNCTION(litespeed)
{
user_config_cache_init();
@ -1675,7 +1660,7 @@ static PHP_MSHUTDOWN_FUNCTION(litespeed)
zend_module_entry litespeed_module_entry = {
STANDARD_MODULE_HEADER,
"litespeed",
litespeed_functions,
ext_functions,
PHP_MINIT(litespeed),
PHP_MSHUTDOWN(litespeed),
NULL,
@ -1697,14 +1682,13 @@ static int add_associate_array( const char * pKey, int keyLen, const char * pVal
Fetch all HTTP request headers */
PHP_FUNCTION(litespeed_request_headers)
{
/* TODO: */
if (ZEND_NUM_ARGS() > 0) {
WRONG_PARAM_COUNT;
if (zend_parse_parameters_none() == FAILURE) {
RETURN_THROWS();
}
array_init(return_value);
LSAPI_ForeachOrgHeader( add_associate_array, return_value );
}
/* }}} */
@ -1720,9 +1704,9 @@ PHP_FUNCTION(litespeed_response_headers)
int len;
char headerBuf[SAPI_LSAPI_MAX_HEADER_LENGTH];
if (ZEND_NUM_ARGS() > 0) {
WRONG_PARAM_COUNT;
}
if (zend_parse_parameters_none() == FAILURE) {
RETURN_THROWS();
}
if (!&SG(sapi_headers).headers) {
RETURN_FALSE;
@ -1762,10 +1746,11 @@ PHP_FUNCTION(apache_get_modules)
"mod_rewrite", "mod_mime", "mod_headers", "mod_expires", "mod_auth_basic", NULL
};
const char **name = mod_names;
/* TODO: */
if (ZEND_NUM_ARGS() > 0) {
WRONG_PARAM_COUNT;
}
if (zend_parse_parameters_none() == FAILURE) {
RETURN_THROWS();
}
array_init(return_value);
while( *name )
{
@ -1776,13 +1761,13 @@ PHP_FUNCTION(apache_get_modules)
/* }}} */
/* {{{ proto array litespeed_finish_request(void)
/* {{{ proto bool litespeed_finish_request(void)
Flushes all response data to the client */
PHP_FUNCTION(litespeed_finish_request)
{
if (ZEND_NUM_ARGS() > 0) {
WRONG_PARAM_COUNT;
}
if (zend_parse_parameters_none() == FAILURE) {
RETURN_THROWS();
}
php_output_end_all();
php_header();

View file

@ -0,0 +1,20 @@
<?php
/** @generate-function-entries */
function litespeed_request_headers(): array {}
/** @alias litespeed_request_headers */
function getallheaders(): array {}
/** @alias litespeed_request_headers */
function apache_request_headers(): array {}
function litespeed_response_headers(): array|false {}
/** @alias litespeed_response_headers */
function apache_response_headers(): array|false {}
function apache_get_modules(): array {}
function litespeed_finish_request(): bool {}

View file

@ -0,0 +1,36 @@
/* This is a generated file, edit the .stub.php file instead. */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_litespeed_request_headers, 0, 0, IS_ARRAY, 0)
ZEND_END_ARG_INFO()
#define arginfo_getallheaders arginfo_litespeed_request_headers
#define arginfo_apache_request_headers arginfo_litespeed_request_headers
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_litespeed_response_headers, 0, 0, MAY_BE_ARRAY|MAY_BE_FALSE)
ZEND_END_ARG_INFO()
#define arginfo_apache_response_headers arginfo_litespeed_response_headers
#define arginfo_apache_get_modules arginfo_litespeed_request_headers
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_litespeed_finish_request, 0, 0, _IS_BOOL, 0)
ZEND_END_ARG_INFO()
ZEND_FUNCTION(litespeed_request_headers);
ZEND_FUNCTION(litespeed_response_headers);
ZEND_FUNCTION(apache_get_modules);
ZEND_FUNCTION(litespeed_finish_request);
static const zend_function_entry ext_functions[] = {
ZEND_FE(litespeed_request_headers, arginfo_litespeed_request_headers)
ZEND_FALIAS(getallheaders, litespeed_request_headers, arginfo_getallheaders)
ZEND_FALIAS(apache_request_headers, litespeed_request_headers, arginfo_apache_request_headers)
ZEND_FE(litespeed_response_headers, arginfo_litespeed_response_headers)
ZEND_FALIAS(apache_response_headers, litespeed_response_headers, arginfo_apache_response_headers)
ZEND_FE(apache_get_modules, arginfo_apache_get_modules)
ZEND_FE(litespeed_finish_request, arginfo_litespeed_finish_request)
ZEND_FE_END
};

View file

@ -291,7 +291,7 @@ static PHP_RSHUTDOWN_FUNCTION(phpdbg) /* {{{ */
If the execution context was set previously it is returned
If the execution context was not set previously boolean true is returned
If the request to set the context fails, boolean false is returned, and an E_WARNING raised */
static PHP_FUNCTION(phpdbg_exec)
PHP_FUNCTION(phpdbg_exec)
{
zend_string *exec;
@ -331,7 +331,7 @@ static PHP_FUNCTION(phpdbg_exec)
/* {{{ proto void phpdbg_break()
instructs phpdbg to insert a breakpoint at the next opcode */
static PHP_FUNCTION(phpdbg_break_next)
PHP_FUNCTION(phpdbg_break_next)
{
zend_execute_data *ex;
@ -352,7 +352,7 @@ static PHP_FUNCTION(phpdbg_break_next)
} /* }}} */
/* {{{ proto void phpdbg_break_file(string file, int line) */
static PHP_FUNCTION(phpdbg_break_file)
PHP_FUNCTION(phpdbg_break_file)
{
char *file;
size_t flen;
@ -366,7 +366,7 @@ static PHP_FUNCTION(phpdbg_break_file)
} /* }}} */
/* {{{ proto void phpdbg_break_method(string class, string method) */
static PHP_FUNCTION(phpdbg_break_method)
PHP_FUNCTION(phpdbg_break_method)
{
char *class, *method;
size_t clen, mlen;
@ -379,7 +379,7 @@ static PHP_FUNCTION(phpdbg_break_method)
} /* }}} */
/* {{{ proto void phpdbg_break_function(string function) */
static PHP_FUNCTION(phpdbg_break_function)
PHP_FUNCTION(phpdbg_break_function)
{
char *function;
size_t function_len;
@ -393,7 +393,7 @@ static PHP_FUNCTION(phpdbg_break_function)
/* {{{ proto void phpdbg_clear(void)
instructs phpdbg to clear breakpoints */
static PHP_FUNCTION(phpdbg_clear)
PHP_FUNCTION(phpdbg_clear)
{
if (zend_parse_parameters_none() == FAILURE) {
RETURN_THROWS();
@ -411,7 +411,7 @@ static PHP_FUNCTION(phpdbg_clear)
} /* }}} */
/* {{{ proto void phpdbg_color(int element, string color) */
static PHP_FUNCTION(phpdbg_color)
PHP_FUNCTION(phpdbg_color)
{
zend_long element;
char *color;
@ -434,7 +434,7 @@ static PHP_FUNCTION(phpdbg_color)
} /* }}} */
/* {{{ proto void phpdbg_prompt(string prompt) */
static PHP_FUNCTION(phpdbg_prompt)
PHP_FUNCTION(phpdbg_prompt)
{
char *prompt = NULL;
size_t prompt_len = 0;
@ -447,7 +447,7 @@ static PHP_FUNCTION(phpdbg_prompt)
} /* }}} */
/* {{{ proto void phpdbg_start_oplog() */
static PHP_FUNCTION(phpdbg_start_oplog)
PHP_FUNCTION(phpdbg_start_oplog)
{
phpdbg_oplog_list *prev;
@ -524,7 +524,7 @@ static inline HashTable* phpdbg_add_empty_array(HashTable *ht, zend_string *name
}
/* {{{ proto void phpdbg_get_executable() */
static PHP_FUNCTION(phpdbg_get_executable)
PHP_FUNCTION(phpdbg_get_executable)
{
HashTable *options = NULL;
zval *option_buffer;
@ -622,7 +622,7 @@ static PHP_FUNCTION(phpdbg_get_executable)
}
/* {{{ proto void phpdbg_end_oplog() */
static PHP_FUNCTION(phpdbg_end_oplog)
PHP_FUNCTION(phpdbg_end_oplog)
{
phpdbg_oplog_entry *cur;
phpdbg_oplog_list *prev;
@ -724,29 +724,10 @@ static PHP_FUNCTION(phpdbg_end_oplog)
}
}
static const zend_function_entry phpdbg_user_functions[] = {
PHP_FE(phpdbg_clear, arginfo_phpdbg_clear)
PHP_FE(phpdbg_break_next, arginfo_phpdbg_break_next)
PHP_FE(phpdbg_break_file, arginfo_phpdbg_break_file)
PHP_FE(phpdbg_break_method, arginfo_phpdbg_break_method)
PHP_FE(phpdbg_break_function, arginfo_phpdbg_break_function)
PHP_FE(phpdbg_exec, arginfo_phpdbg_exec)
PHP_FE(phpdbg_color, arginfo_phpdbg_color)
PHP_FE(phpdbg_prompt, arginfo_phpdbg_prompt)
PHP_FE(phpdbg_start_oplog, arginfo_phpdbg_start_oplog)
PHP_FE(phpdbg_end_oplog, arginfo_phpdbg_end_oplog)
PHP_FE(phpdbg_get_executable, arginfo_phpdbg_get_executable)
#ifdef PHP_FE_END
PHP_FE_END
#else
{NULL,NULL,NULL}
#endif
};
static zend_module_entry sapi_phpdbg_module_entry = {
STANDARD_MODULE_HEADER,
PHPDBG_NAME,
phpdbg_user_functions,
ext_functions,
PHP_MINIT(phpdbg),
PHP_MSHUTDOWN(phpdbg),
PHP_RINIT(phpdbg),

View file

@ -1,5 +1,7 @@
<?php
/** @generate-function-entries */
function phpdbg_break_next(): void {}
function phpdbg_break_file(string $file, int $line): void {}

View file

@ -41,3 +41,32 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phpdbg_get_executable, 0, 0, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 0, "[]")
ZEND_END_ARG_INFO()
ZEND_FUNCTION(phpdbg_break_next);
ZEND_FUNCTION(phpdbg_break_file);
ZEND_FUNCTION(phpdbg_break_method);
ZEND_FUNCTION(phpdbg_break_function);
ZEND_FUNCTION(phpdbg_color);
ZEND_FUNCTION(phpdbg_prompt);
ZEND_FUNCTION(phpdbg_exec);
ZEND_FUNCTION(phpdbg_clear);
ZEND_FUNCTION(phpdbg_start_oplog);
ZEND_FUNCTION(phpdbg_end_oplog);
ZEND_FUNCTION(phpdbg_get_executable);
static const zend_function_entry ext_functions[] = {
ZEND_FE(phpdbg_break_next, arginfo_phpdbg_break_next)
ZEND_FE(phpdbg_break_file, arginfo_phpdbg_break_file)
ZEND_FE(phpdbg_break_method, arginfo_phpdbg_break_method)
ZEND_FE(phpdbg_break_function, arginfo_phpdbg_break_function)
ZEND_FE(phpdbg_color, arginfo_phpdbg_color)
ZEND_FE(phpdbg_prompt, arginfo_phpdbg_prompt)
ZEND_FE(phpdbg_exec, arginfo_phpdbg_exec)
ZEND_FE(phpdbg_clear, arginfo_phpdbg_clear)
ZEND_FE(phpdbg_start_oplog, arginfo_phpdbg_start_oplog)
ZEND_FE(phpdbg_end_oplog, arginfo_phpdbg_end_oplog)
ZEND_FE(phpdbg_get_executable, arginfo_phpdbg_get_executable)
ZEND_FE_END
};