Skip to content

Add support for union types in stubs #4895

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
4 changes: 4 additions & 0 deletions Zend/zend_API.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ typedef struct _zend_fcall_info_cache {
#define ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO(name, class_name, allow_null) \
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(name, 0, -1, class_name, allow_null)

#define ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(name, return_reference, required_num_args, type) \
static const zend_internal_arg_info name[] = { \
{ (const char*)(zend_uintptr_t)(required_num_args), ZEND_TYPE_INIT_MASK(type | _ZEND_ARG_INFO_FLAGS(return_reference, 0)) },

#define ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, allow_null) \
static const zend_internal_arg_info name[] = { \
{ (const char*)(zend_uintptr_t)(required_num_args), ZEND_TYPE_INIT_CODE(type, allow_null, _ZEND_ARG_INFO_FLAGS(return_reference, 0)) },
Expand Down
33 changes: 11 additions & 22 deletions ext/standard/basic_functions.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,15 @@ function ob_end_flush(): bool {}

function ob_end_clean(): bool {}

/** @return string|false */
function ob_get_flush() {}
function ob_get_flush(): string|false {}

/** @return string|false */
function ob_get_clean() {}
function ob_get_clean(): string|false {}

/** @return string|false */
function ob_get_contents() {}
function ob_get_contents(): string|false {}

function ob_get_level(): int {}

/** @return int|false */
function ob_get_length() {}
function ob_get_length(): int|false {}

function ob_list_handlers(): array {}

Expand Down Expand Up @@ -649,26 +645,19 @@ function dirname(string $path, int $levels = 1): string {}
/** @return array|string */
function pathinfo(string $path, int $options = UNKNOWN) {}

/** @return string|false */
function stristr(string $haystack, string $needle, bool $before_needle = false) {}
function stristr(string $haystack, string $needle, bool $before_needle = false): string|false {}

/** @return string|false */
function strstr(string $haystack, string $needle, bool $before_needle = false) {}
function strstr(string $haystack, string $needle, bool $before_needle = false): string|false {}

/** @return int|false */
function strpos(string $haystack, string $needle, int $offset = 0) {}
function strpos(string $haystack, string $needle, int $offset = 0): int|false {}

/** @return int|false */
function stripos(string $haystack, string $needle, int $offset = 0) {}
function stripos(string $haystack, string $needle, int $offset = 0): int|false {}

/** @return int|false */
function strrpos(string $haystack, string $needle, int $offset = 0) {}
function strrpos(string $haystack, string $needle, int $offset = 0): int|false {}

/** @return int|false */
function strripos(string $haystack, string $needle, int $offset = 0) {}
function strripos(string $haystack, string $needle, int $offset = 0): int|false {}

/** @return string|false */
function strrchr(string $haystack, string $needle) {}
function strrchr(string $haystack, string $needle): string|false {}

function chunk_split(string $str, int $chunklen = 76, string $ending = "\r\n"): string {}

Expand Down
32 changes: 17 additions & 15 deletions ext/standard/basic_functions_arginfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ZEND_END_ARG_INFO()

#define arginfo_ob_end_clean arginfo_ob_flush

ZEND_BEGIN_ARG_INFO_EX(arginfo_ob_get_flush, 0, 0, 0)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_ob_get_flush, 0, 0, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_END_ARG_INFO()

#define arginfo_ob_get_clean arginfo_ob_get_flush
Expand All @@ -33,7 +33,8 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ob_get_level, 0, 0, IS_LONG, 0)
ZEND_END_ARG_INFO()

#define arginfo_ob_get_length arginfo_ob_get_flush
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_ob_get_length, 0, 0, MAY_BE_LONG|MAY_BE_FALSE)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ob_list_handlers, 0, 0, IS_ARRAY, 0)
ZEND_END_ARG_INFO()
Expand Down Expand Up @@ -495,7 +496,8 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_set_include_path, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, include_path, IS_STRING, 0)
ZEND_END_ARG_INFO()

#define arginfo_get_include_path arginfo_ob_get_flush
ZEND_BEGIN_ARG_INFO_EX(arginfo_get_include_path, 0, 0, 0)
ZEND_END_ARG_INFO()

#define arginfo_restore_include_path arginfo_flush

Expand Down Expand Up @@ -648,7 +650,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_dns_get_mx, 0, 2, _IS_BOOL, 0)
ZEND_END_ARG_INFO()
#endif

#define arginfo_net_get_interfaces arginfo_ob_get_flush
#define arginfo_net_get_interfaces arginfo_get_include_path

#if HAVE_FTOK
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ftok, 0, 2, IS_LONG, 0)
Expand All @@ -674,13 +676,13 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_md5_file, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, raw_output, _IS_BOOL, 0)
ZEND_END_ARG_INFO()

#define arginfo_getmyuid arginfo_ob_get_flush
#define arginfo_getmyuid arginfo_get_include_path

#define arginfo_getmygid arginfo_ob_get_flush
#define arginfo_getmygid arginfo_get_include_path

#define arginfo_getmypid arginfo_ob_get_flush
#define arginfo_getmypid arginfo_get_include_path

#define arginfo_getmyinode arginfo_ob_get_flush
#define arginfo_getmyinode arginfo_get_include_path

#define arginfo_getlastmod arginfo_ob_get_level

Expand Down Expand Up @@ -873,15 +875,15 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_pathinfo, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, options, IS_LONG, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_stristr, 0, 0, 2)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_stristr, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, haystack, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, needle, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, before_needle, _IS_BOOL, 0)
ZEND_END_ARG_INFO()

#define arginfo_strstr arginfo_stristr

ZEND_BEGIN_ARG_INFO_EX(arginfo_strpos, 0, 0, 2)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_strpos, 0, 2, MAY_BE_LONG|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, haystack, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, needle, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, offset, IS_LONG, 0)
Expand All @@ -893,7 +895,7 @@ ZEND_END_ARG_INFO()

#define arginfo_strripos arginfo_strpos

ZEND_BEGIN_ARG_INFO_EX(arginfo_strrchr, 0, 0, 2)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_strrchr, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, haystack, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, needle, IS_STRING, 0)
ZEND_END_ARG_INFO()
Expand Down Expand Up @@ -1112,7 +1114,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_chroot, 0, 1, _IS_BOOL, 0)
ZEND_END_ARG_INFO()
#endif

#define arginfo_getcwd arginfo_ob_get_flush
#define arginfo_getcwd arginfo_get_include_path

#define arginfo_rewinddir arginfo_closedir

Expand Down Expand Up @@ -1239,15 +1241,15 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phpcredits, 0, 0, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, flag, IS_LONG, 0)
ZEND_END_ARG_INFO()

#define arginfo_php_sapi_name arginfo_ob_get_flush
#define arginfo_php_sapi_name arginfo_get_include_path

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_php_uname, 0, 0, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, mode, IS_STRING, 0)
ZEND_END_ARG_INFO()

#define arginfo_php_ini_scanned_files arginfo_ob_get_flush
#define arginfo_php_ini_scanned_files arginfo_get_include_path

#define arginfo_php_ini_loaded_file arginfo_ob_get_flush
#define arginfo_php_ini_loaded_file arginfo_get_include_path

ZEND_BEGIN_ARG_INFO_EX(arginfo_iptcembed, 0, 0, 2)
ZEND_ARG_TYPE_INFO(0, iptcdata, IS_STRING, 0)
Expand Down
Loading