Skip to content

Add stubs for SAPIs #5295

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 3 additions & 18 deletions sapi/cgi/cgi_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
#include "fopen_wrappers.h"
#include "http_status_codes.h"
#include "ext/standard/php_standard.h"
#include "ext/standard/dl_arginfo.h"
#include "ext/standard/url.h"

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

#include "fastcgi.h"
#include "cgi_main_arginfo.h"

#if defined(PHP_WIN32) && defined(HAVE_OPENSSL)
# include "openssl/applink.c"
Expand Down Expand Up @@ -1006,12 +1008,6 @@ static sapi_module_struct cgi_sapi_module = {
};
/* }}} */

/* {{{ arginfo ext/standard/dl.c */
ZEND_BEGIN_ARG_INFO(arginfo_dl, 0)
ZEND_ARG_INFO(0, extension_filename)
ZEND_END_ARG_INFO()
/* }}} */

static const zend_function_entry additional_functions[] = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any idea what's up with these two separate function lists in this SAPI?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh, no idea. Although, what I can see is:

  • some other SAPIs also have "additional functions"
  • they all do something like this: cgi_sapi_module.additional_functions = additional_functions;

ZEND_FE(dl, arginfo_dl)
PHP_FE_END
Expand Down Expand Up @@ -1704,21 +1700,10 @@ PHP_FUNCTION(apache_response_headers) /* {{{ */
}
/* }}} */

ZEND_BEGIN_ARG_INFO(arginfo_no_args, 0)
ZEND_END_ARG_INFO()

static const zend_function_entry cgi_functions[] = {
PHP_FE(apache_child_terminate, arginfo_no_args)
PHP_FE(apache_request_headers, arginfo_no_args)
PHP_FE(apache_response_headers, arginfo_no_args)
PHP_FALIAS(getallheaders, apache_request_headers, arginfo_no_args)
PHP_FE_END
};

static zend_module_entry cgi_module_entry = {
STANDARD_MODULE_HEADER,
"cgi-fcgi",
cgi_functions,
ext_functions,
PHP_MINIT(cgi),
PHP_MSHUTDOWN(cgi),
NULL,
Expand Down
12 changes: 12 additions & 0 deletions sapi/cgi/cgi_main.stub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

/** @generate-function-entries */

function apache_child_terminate(): void {}

function apache_request_headers(): array {}

/** @alias apache_request_headers */
function getallheaders(): array {}

function apache_response_headers(): array {}
26 changes: 26 additions & 0 deletions sapi/cgi/cgi_main_arginfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: ccb32ad91944af15fe1fcb44b97c28a79c1aad86 */

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_apache_child_terminate, 0, 0, IS_VOID, 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

#define arginfo_apache_response_headers arginfo_apache_request_headers


ZEND_FUNCTION(apache_child_terminate);
ZEND_FUNCTION(apache_request_headers);
ZEND_FUNCTION(apache_response_headers);


static const zend_function_entry ext_functions[] = {
ZEND_FE(apache_child_terminate, arginfo_apache_child_terminate)
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_END
};
8 changes: 2 additions & 6 deletions sapi/cli/php_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include "php_main.h"
#include "fopen_wrappers.h"
#include "ext/standard/php_standard.h"
#include "ext/standard/dl_arginfo.h"
#include "cli.h"
#ifdef PHP_WIN32
#include <io.h>
Expand All @@ -78,6 +79,7 @@

#include "ps_title.h"
#include "php_cli_process_title.h"
#include "php_cli_process_title_arginfo.h"

#ifndef PHP_WIN32
# define php_select(m, r, w, e, t) select(m, r, w, e, t)
Expand Down Expand Up @@ -457,12 +459,6 @@ static sapi_module_struct cli_sapi_module = {
};
/* }}} */

/* {{{ arginfo ext/standard/dl.c */
ZEND_BEGIN_ARG_INFO(arginfo_dl, 0)
ZEND_ARG_INFO(0, extension_filename)
ZEND_END_ARG_INFO()
/* }}} */

static const zend_function_entry additional_functions[] = {
ZEND_FE(dl, arginfo_dl)
PHP_FE(cli_set_process_title, arginfo_cli_set_process_title)
Expand Down
7 changes: 0 additions & 7 deletions sapi/cli/php_cli_process_title.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@
#ifndef PHP_PS_TITLE_HEADER
#define PHP_PS_TITLE_HEADER

ZEND_BEGIN_ARG_INFO(arginfo_cli_set_process_title, 0)
ZEND_ARG_INFO(0, title)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_cli_get_process_title, 0)
ZEND_END_ARG_INFO()

PHP_FUNCTION(cli_set_process_title);
PHP_FUNCTION(cli_get_process_title);

Expand Down
5 changes: 5 additions & 0 deletions sapi/cli/php_cli_process_title.stub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

function cli_set_process_title(string $title): bool {}

function cli_get_process_title(): ?string {}
9 changes: 9 additions & 0 deletions sapi/cli/php_cli_process_title_arginfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: ee776e0c54fe4b66a98b3a0203af11c5f3082e38 */

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_cli_set_process_title, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, title, IS_STRING, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_cli_get_process_title, 0, 0, IS_STRING, 1)
ZEND_END_ARG_INFO()
15 changes: 7 additions & 8 deletions sapi/cli/php_cli_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@

#include "php_http_parser.h"
#include "php_cli_server.h"
#include "php_cli_server_arginfo.h"
#include "mime_type_map.h"

#include "php_cli_process_title.h"
#include "php_cli_process_title_arginfo.h"

#define OUTPUT_NOT_CHECKED -1
#define OUTPUT_IS_TTY 1
Expand Down Expand Up @@ -479,15 +481,12 @@ zend_module_entry cli_server_module_entry = {
};
/* }}} */

ZEND_BEGIN_ARG_INFO(arginfo_no_args, 0)
ZEND_END_ARG_INFO()

const zend_function_entry server_additional_functions[] = {
PHP_FE(cli_set_process_title, arginfo_cli_set_process_title)
PHP_FE(cli_get_process_title, arginfo_cli_get_process_title)
PHP_FE(apache_request_headers, arginfo_no_args)
PHP_FE(apache_response_headers, arginfo_no_args)
PHP_FALIAS(getallheaders, apache_request_headers, arginfo_no_args)
PHP_FE(cli_set_process_title, arginfo_cli_set_process_title)
PHP_FE(cli_get_process_title, arginfo_cli_get_process_title)
PHP_FE(apache_request_headers, arginfo_apache_request_headers)
PHP_FE(apache_response_headers, arginfo_apache_response_headers)
PHP_FALIAS(getallheaders, apache_request_headers, arginfo_getallheaders)
PHP_FE_END
};

Expand Down
7 changes: 7 additions & 0 deletions sapi/cli/php_cli_server.stub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

function apache_request_headers(): array {}

function apache_response_headers(): array {}

function getallheaders(): array {}
9 changes: 9 additions & 0 deletions sapi/cli/php_cli_server_arginfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 60cd531d36a34fe7c51982e9ec40b45d2a2a4ce7 */

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_apache_request_headers, 0, 0, IS_ARRAY, 0)
ZEND_END_ARG_INFO()

#define arginfo_apache_response_headers arginfo_apache_request_headers

#define arginfo_getallheaders arginfo_apache_request_headers
7 changes: 1 addition & 6 deletions sapi/embed/php_embed.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "php_embed.h"
#include "ext/standard/php_standard.h"
#include "ext/standard/dl_arginfo.h"

#ifdef PHP_WIN32
#include <io.h>
Expand Down Expand Up @@ -142,12 +143,6 @@ EMBED_SAPI_API sapi_module_struct php_embed_module = {
};
/* }}} */

/* {{{ arginfo ext/standard/dl.c */
ZEND_BEGIN_ARG_INFO(arginfo_dl, 0)
ZEND_ARG_INFO(0, extension_filename)
ZEND_END_ARG_INFO()
/* }}} */

static const zend_function_entry additional_functions[] = {
ZEND_FE(dl, arginfo_dl)
{NULL, NULL, NULL}
Expand Down