diff options
63 files changed, 515 insertions, 635 deletions
diff --git a/Zend/zend_API.h b/Zend/zend_API.h index d46fe6968a..70e757c1bb 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -1634,6 +1634,9 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char * #define Z_PARAM_PATH_STR(dest) \ Z_PARAM_PATH_STR_EX(dest, 0, 0) +#define Z_PARAM_PATH_STR_OR_NULL(dest) \ + Z_PARAM_PATH_STR_EX(dest, 1, 0) + /* old "r" */ #define Z_PARAM_RESOURCE_EX2(dest, check_null, deref, separate) \ Z_PARAM_PROLOGUE(deref, separate); \ diff --git a/Zend/zend_weakrefs.stub.php b/Zend/zend_weakrefs.stub.php index 4074ac0122..c341e0a463 100644 --- a/Zend/zend_weakrefs.stub.php +++ b/Zend/zend_weakrefs.stub.php @@ -15,15 +15,11 @@ final class WeakMap implements ArrayAccess, Countable, IteratorAggregate { /** * @param object $object - * @return mixed */ - public function offsetGet($object) {} + public function offsetGet($object): mixed {} - /** - * @param object $object - * @param mixed $value - */ - public function offsetSet($object, $value): void {} + /** @param object $object */ + public function offsetSet($object, mixed $value): void {} /** @param object $object */ public function offsetExists($object): bool {} diff --git a/Zend/zend_weakrefs_arginfo.h b/Zend/zend_weakrefs_arginfo.h index 43d206a897..da953a9800 100644 --- a/Zend/zend_weakrefs_arginfo.h +++ b/Zend/zend_weakrefs_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 8a90ffe614346c65d312bc5061fd304056b5640a */ + * Stub hash: 0569bc7e10a1ec15a3a9eec481da27b647eb1d1d */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_WeakReference___construct, 0, 0, 0) ZEND_END_ARG_INFO() @@ -11,13 +11,13 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_WeakReference_get, 0, 0, IS_OBJECT, 1) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_WeakMap_offsetGet, 0, 0, 1) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_WeakMap_offsetGet, 0, 1, IS_MIXED, 0) ZEND_ARG_INFO(0, object) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_WeakMap_offsetSet, 0, 2, IS_VOID, 0) ZEND_ARG_INFO(0, object) - ZEND_ARG_INFO(0, value) + ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_WeakMap_offsetExists, 0, 1, _IS_BOOL, 0) diff --git a/ext/com_dotnet/com_com.c b/ext/com_dotnet/com_com.c index 54a1533266..ef8d99567f 100644 --- a/ext/com_dotnet/com_com.c +++ b/ext/com_dotnet/com_com.c @@ -29,11 +29,12 @@ PHP_METHOD(com, __construct) { zval *object = getThis(); - zval *server_params = NULL; + zend_string *server_name = NULL; + HashTable *server_params = NULL; php_com_dotnet_object *obj; char *module_name, *typelib_name = NULL; size_t module_name_len = 0, typelib_name_len = 0; - zend_string *server_name = NULL, *user_name = NULL, *password = NULL, *domain_name = NULL; + zend_string *user_name = NULL, *password = NULL, *domain_name = NULL; OLECHAR *moniker; CLSID clsid; CLSCTX ctx = CLSCTX_SERVER; @@ -50,16 +51,13 @@ PHP_METHOD(com, __construct) zend_long cp = GetACP(); const struct php_win32_cp *cp_it; - if (FAILURE == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, - ZEND_NUM_ARGS(), "s|S!ls", - &module_name, &module_name_len, &server_name, - &cp, &typelib_name, &typelib_name_len) && - FAILURE == zend_parse_parameters( - ZEND_NUM_ARGS(), "sa|ls", - &module_name, &module_name_len, &server_params, &cp, - &typelib_name, &typelib_name_len)) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_START(1, 4) + Z_PARAM_STRING(module_name, module_name_len) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_ARRAY_HT_OR_NULL(server_name, server_params) + Z_PARAM_LONG(cp) + Z_PARAM_STRING(typelib_name, typelib_name_len) + ZEND_PARSE_PARAMETERS_END(); php_com_initialize(); obj = CDNO_FETCH(object); @@ -78,28 +76,28 @@ PHP_METHOD(com, __construct) /* decode the data from the array */ - if (NULL != (tmp = zend_hash_str_find(Z_ARRVAL_P(server_params), + if (NULL != (tmp = zend_hash_str_find(server_params, "Server", sizeof("Server")-1))) { server_name = zval_get_string(tmp); ctx = CLSCTX_REMOTE_SERVER; } - if (NULL != (tmp = zend_hash_str_find(Z_ARRVAL_P(server_params), + if (NULL != (tmp = zend_hash_str_find(server_params, "Username", sizeof("Username")-1))) { user_name = zval_get_string(tmp); } - if (NULL != (tmp = zend_hash_str_find(Z_ARRVAL_P(server_params), + if (NULL != (tmp = zend_hash_str_find(server_params, "Password", sizeof("Password")-1))) { password = zval_get_string(tmp); } - if (NULL != (tmp = zend_hash_str_find(Z_ARRVAL_P(server_params), + if (NULL != (tmp = zend_hash_str_find(server_params, "Domain", sizeof("Domain")-1))) { domain_name = zval_get_string(tmp); } - if (NULL != (tmp = zend_hash_str_find(Z_ARRVAL_P(server_params), + if (NULL != (tmp = zend_hash_str_find(server_params, "Flags", sizeof("Flags")-1))) { ctx = (CLSCTX)zval_get_long(tmp); } @@ -686,34 +684,35 @@ PHP_FUNCTION(com_create_guid) /* {{{ Connect events from a COM object to a PHP object */ PHP_FUNCTION(com_event_sink) { - zval *object, *sinkobject, *sink=NULL; + zval *object, *sinkobject; + zend_string *sink_str = NULL; + HashTable *sink_ht = NULL; char *dispname = NULL, *typelibname = NULL; php_com_dotnet_object *obj; ITypeInfo *typeinfo = NULL; - RETVAL_FALSE; + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_OBJECT_OF_CLASS(object, php_com_variant_class_entry) + Z_PARAM_OBJECT(sinkobject) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_ARRAY_HT_OR_NULL(sink_str, sink_ht) + ZEND_PARSE_PARAMETERS_END(); - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "Oo|z/", - &object, php_com_variant_class_entry, &sinkobject, &sink)) { - RETURN_THROWS(); - } + RETVAL_FALSE; php_com_initialize(); obj = CDNO_FETCH(object); - if (sink && Z_TYPE_P(sink) == IS_ARRAY) { + if (sink_ht) { /* 0 => typelibname, 1 => dispname */ zval *tmp; - if ((tmp = zend_hash_index_find(Z_ARRVAL_P(sink), 0)) != NULL && Z_TYPE_P(tmp) == IS_STRING) + if ((tmp = zend_hash_index_find(sink_ht, 0)) != NULL && Z_TYPE_P(tmp) == IS_STRING) typelibname = Z_STRVAL_P(tmp); - if ((tmp = zend_hash_index_find(Z_ARRVAL_P(sink), 1)) != NULL && Z_TYPE_P(tmp) == IS_STRING) + if ((tmp = zend_hash_index_find(sink_ht, 1)) != NULL && Z_TYPE_P(tmp) == IS_STRING) dispname = Z_STRVAL_P(tmp); - } else if (sink != NULL) { - if (!try_convert_to_string(sink)) { - RETURN_THROWS(); - } - dispname = Z_STRVAL_P(sink); + } else if (sink_str) { + dispname = ZSTR_VAL(sink_str); } typeinfo = php_com_locate_typeinfo(typelibname, obj, dispname, 1); diff --git a/ext/com_dotnet/com_extension.stub.php b/ext/com_dotnet/com_extension.stub.php index 8323b0796b..9b1edf9d38 100644 --- a/ext/com_dotnet/com_extension.stub.php +++ b/ext/com_dotnet/com_extension.stub.php @@ -58,8 +58,7 @@ function com_get_active_object(string $progid, ?int $code_page = null): variant function com_create_guid(): string|false {} -/** @param array|string|null $sinkinterface */ -function com_event_sink(variant $comobject, object $sinkobject, $sinkinterface = UNKNOWN): bool {} +function com_event_sink(variant $comobject, object $sinkobject, array|string|null $sinkinterface = null): bool {} /** @param com|dotnet|variant|string $comobject */ function com_print_typeinfo($comobject, ?string $dispinterface = null, bool $wantsink = false): bool {} @@ -75,8 +74,7 @@ class variant class com { - /** @param string|array|null $server_name */ - public function __construct(string $module_name, $server_name = UNKNOWN, int $codepage = CP_ACP, string $typelib = "") {} + public function __construct(string $module_name, array|string|null $server_name = null, int $codepage = CP_ACP, string $typelib = "") {} } #if HAVE_MSCOREE_H diff --git a/ext/com_dotnet/com_extension_arginfo.h b/ext/com_dotnet/com_extension_arginfo.h index aec8108d88..3e583c3211 100644 --- a/ext/com_dotnet/com_extension_arginfo.h +++ b/ext/com_dotnet/com_extension_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 48167f9ee38966beaf550cd0a7b07d873575b48e */ + * Stub hash: f78e9db58131f9d67021eaea4c3d4be75cafe2ac */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_variant_set, 0, 2, IS_VOID, 0) ZEND_ARG_OBJ_INFO(0, variant, variant, 0) @@ -92,7 +92,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_com_event_sink, 0, 2, _IS_BOOL, 0) ZEND_ARG_OBJ_INFO(0, comobject, variant, 0) ZEND_ARG_TYPE_INFO(0, sinkobject, IS_OBJECT, 0) - ZEND_ARG_INFO(0, sinkinterface) + ZEND_ARG_TYPE_MASK(0, sinkinterface, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_com_print_typeinfo, 0, 1, _IS_BOOL, 0) @@ -118,7 +118,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_com___construct, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, module_name, IS_STRING, 0) - ZEND_ARG_INFO(0, server_name) + ZEND_ARG_TYPE_MASK(0, server_name, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, "null") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, codepage, IS_LONG, 0, "CP_ACP") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, typelib, IS_STRING, 0, "\"\"") ZEND_END_ARG_INFO() diff --git a/ext/ctype/ctype.stub.php b/ext/ctype/ctype.stub.php index 5ae356cc4f..bcc722c12d 100644 --- a/ext/ctype/ctype.stub.php +++ b/ext/ctype/ctype.stub.php @@ -2,35 +2,24 @@ /** @generate-function-entries */ -/** @param string|int $text */ function ctype_alnum(mixed $text): bool {} -/** @param string|int $text */ function ctype_alpha(mixed $text): bool {} -/** @param string|int $text */ function ctype_cntrl(mixed $text): bool {} -/** @param string|int $text */ function ctype_digit(mixed $text): bool {} -/** @param string|int $text */ function ctype_lower(mixed $text): bool {} -/** @param string|int $text */ function ctype_graph(mixed $text): bool {} -/** @param string|int $text */ function ctype_print(mixed $text): bool {} -/** @param string|int $text */ function ctype_punct(mixed $text): bool {} -/** @param string|int $text */ function ctype_space(mixed $text): bool {} -/** @param string|int $text */ function ctype_upper(mixed $text): bool {} -/** @param string|int $text */ function ctype_xdigit(mixed $text): bool {} diff --git a/ext/ctype/ctype_arginfo.h b/ext/ctype/ctype_arginfo.h index 72e4d7b35c..10d8ae9bf1 100644 --- a/ext/ctype/ctype_arginfo.h +++ b/ext/ctype/ctype_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 5263184b90f82d53c6da4388c79b76a8c17977e9 */ + * Stub hash: aa287af25fe33a05d15d85b92b0edcfae00284a2 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ctype_alnum, 0, 1, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, text, IS_MIXED, 0) diff --git a/ext/ffi/ffi.c b/ext/ffi/ffi.c index 4a304fea83..5c218ecf1b 100644 --- a/ext/ffi/ffi.c +++ b/ext/ffi/ffi.c @@ -3590,7 +3590,7 @@ static void zend_ffi_tags_cleanup(zend_ffi_dcl *dcl) /* {{{ */ ZEND_METHOD(FFI, new) /* {{{ */ { zend_string *type_def = NULL; - zval *ztype = NULL; + zend_object *type_obj = NULL; zend_ffi_type *type, *type_ptr; zend_ffi_cdata *cdata; void *ptr; @@ -3601,11 +3601,7 @@ ZEND_METHOD(FFI, new) /* {{{ */ ZEND_FFI_VALIDATE_API_RESTRICTION(); ZEND_PARSE_PARAMETERS_START(1, 3) - if (Z_TYPE_P(EX_VAR_NUM(0)) == IS_STRING) { - Z_PARAM_STR(type_def) - } else { - Z_PARAM_OBJECT_OF_CLASS(ztype, zend_ffi_ctype_ce) - } + Z_PARAM_STR_OR_OBJ_OF_CLASS(type_def, type_obj, zend_ffi_ctype_ce) Z_PARAM_OPTIONAL Z_PARAM_BOOL(owned) Z_PARAM_BOOL(persistent) @@ -3670,7 +3666,7 @@ ZEND_METHOD(FFI, new) /* {{{ */ type_ptr = dcl.type; } else { - zend_ffi_ctype *ctype = (zend_ffi_ctype*)Z_OBJ_P(ztype); + zend_ffi_ctype *ctype = (zend_ffi_ctype*) type_obj; type_ptr = type = ctype->type; if (ZEND_FFI_TYPE_IS_OWNED(type)) { diff --git a/ext/ffi/ffi.stub.php b/ext/ffi/ffi.stub.php index df2ffc53f1..67b083eb2d 100644 --- a/ext/ffi/ffi.stub.php +++ b/ext/ffi/ffi.stub.php @@ -10,8 +10,7 @@ final class FFI public static function scope(string $scope_name): ?FFI {} - /** @param FFI\CType|string $type */ - public static function new($type, bool $owned = true, bool $persistent = false): ?FFI\CData {} + public static function new(FFI\CType|string $type, bool $owned = true, bool $persistent = false): ?FFI\CData {} /** @prefer-ref $ptr */ public static function free(FFI\CData $ptr): void {} diff --git a/ext/ffi/ffi_arginfo.h b/ext/ffi/ffi_arginfo.h index 7b1f809233..d35c7e898b 100644 --- a/ext/ffi/ffi_arginfo.h +++ b/ext/ffi/ffi_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: a486305cd865e2798f7d9916760a3ec3c6f114b0 */ + * Stub hash: c5ad08a2c62988e2b50468c1c5b941b5c28f23b5 */ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_FFI_cdef, 0, 0, FFI, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, code, IS_STRING, 0, "\"\"") @@ -15,7 +15,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_FFI_scope, 0, 1, FFI, 1) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_FFI_new, 0, 1, FFI\\CData, 1) - ZEND_ARG_INFO(0, type) + ZEND_ARG_OBJ_TYPE_MASK(0, type, FFI\\CType, MAY_BE_STRING, NULL) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, owned, _IS_BOOL, 0, "true") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, persistent, _IS_BOOL, 0, "false") ZEND_END_ARG_INFO() diff --git a/ext/intl/calendar/calendar.stub.php b/ext/intl/calendar/calendar.stub.php index bc09ae70a3..5c89535497 100644 --- a/ext/intl/calendar/calendar.stub.php +++ b/ext/intl/calendar/calendar.stub.php @@ -50,11 +50,10 @@ class IntlCalendar public function clear(?int $field = null) {} /** - * @param DateTime|string $dateTime * @return IntlCalendar|null * @alias intlcal_from_date_time */ - public static function fromDateTime($dateTime, ?string $locale = null) {} + public static function fromDateTime(DateTime|string $dateTime, ?string $locale = null) {} /** * @return int diff --git a/ext/intl/calendar/calendar_arginfo.h b/ext/intl/calendar/calendar_arginfo.h index 99626bd19e..f84bf76140 100644 --- a/ext/intl/calendar/calendar_arginfo.h +++ b/ext/intl/calendar/calendar_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 3facb6bdce18efae3d6b9594d1fcddfb220dd54d */ + * Stub hash: 0ac7a1d4e011518fc956fb05624b45b061fa9710 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlCalendar___construct, 0, 0, 0) ZEND_END_ARG_INFO() @@ -32,7 +32,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlCalendar_clear, 0, 0, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlCalendar_fromDateTime, 0, 0, 1) - ZEND_ARG_INFO(0, dateTime) + ZEND_ARG_OBJ_TYPE_MASK(0, dateTime, DateTime, MAY_BE_STRING, NULL) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, locale, IS_STRING, 1, "null") ZEND_END_ARG_INFO() diff --git a/ext/intl/calendar/calendar_methods.cpp b/ext/intl/calendar/calendar_methods.cpp index df3fc24c61..ed27551d66 100644 --- a/ext/intl/calendar/calendar_methods.cpp +++ b/ext/intl/calendar/calendar_methods.cpp @@ -941,38 +941,35 @@ U_CFUNC PHP_FUNCTION(intlcal_set_skipped_wall_time_option) U_CFUNC PHP_FUNCTION(intlcal_from_date_time) { - zval *zv_arg, - zv_tmp, - *zv_datetime = NULL, - zv_timestamp; + zend_object *date_obj; + zend_string *date_str; + zval zv_tmp, zv_arg, zv_timestamp; php_date_obj *datetime; - char *locale_str = NULL; + char *locale_str = NULL; size_t locale_str_len; TimeZone *timeZone; - UErrorCode status = U_ZERO_ERROR; + UErrorCode status = U_ZERO_ERROR; Calendar *cal; intl_error_reset(NULL); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|s!", - &zv_arg, &locale_str, &locale_str_len) == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR_OR_OBJ_OF_CLASS(date_str, date_obj, php_date_get_date_ce()) + Z_PARAM_OPTIONAL + Z_PARAM_STRING_OR_NULL(locale_str, locale_str_len) + ZEND_PARSE_PARAMETERS_END(); - if (!(Z_TYPE_P(zv_arg) == IS_OBJECT && instanceof_function( - Z_OBJCE_P(zv_arg), php_date_get_date_ce()))) { + if (date_str) { object_init_ex(&zv_tmp, php_date_get_date_ce()); - zend_call_known_instance_method_with_1_params( - Z_OBJCE(zv_tmp)->constructor, Z_OBJ(zv_tmp), NULL, zv_arg); - zv_datetime = &zv_tmp; + ZVAL_STR(&zv_arg, date_str); + zend_call_known_instance_method_with_1_params(Z_OBJCE(zv_tmp)->constructor, Z_OBJ(zv_tmp), NULL, &zv_arg); + date_obj = Z_OBJ(zv_tmp); if (EG(exception)) { zend_object_store_ctor_failed(Z_OBJ(zv_tmp)); goto error; } - } else { - zv_datetime = zv_arg; } - datetime = Z_PHPDATE_P(zv_datetime); + datetime = php_date_obj_from_obj(date_obj); if (!datetime->time) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "intlcal_from_date_time: DateTime object is unconstructed", @@ -980,7 +977,7 @@ U_CFUNC PHP_FUNCTION(intlcal_from_date_time) goto error; } - zend_call_method_with_0_params(Z_OBJ_P(zv_datetime), php_date_get_date_ce(), NULL, "gettimestamp", &zv_timestamp); + zend_call_method_with_0_params(date_obj, php_date_get_date_ce(), NULL, "gettimestamp", &zv_timestamp); if (Z_TYPE(zv_timestamp) != IS_LONG) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "intlcal_from_date_time: bad DateTime; call to " @@ -1023,8 +1020,8 @@ U_CFUNC PHP_FUNCTION(intlcal_from_date_time) calendar_object_create(return_value, cal); error: - if (zv_datetime && zv_datetime != zv_arg) { - zval_ptr_dtor(zv_datetime); + if (date_str) { + OBJ_RELEASE(date_obj); } } diff --git a/ext/intl/dateformat/dateformat.stub.php b/ext/intl/dateformat/dateformat.stub.php index cdb5aedb03..5d77e07555 100644 --- a/ext/intl/dateformat/dateformat.stub.php +++ b/ext/intl/dateformat/dateformat.stub.php @@ -99,7 +99,7 @@ class IntlDateFormatter public function isLenient() {} /** - * @param array|int $value + * @param object|array|string|int|float $value * @return string|false * @alias datefmt_format */ diff --git a/ext/intl/dateformat/dateformat_arginfo.h b/ext/intl/dateformat/dateformat_arginfo.h index ae128d8bf9..d94c886003 100644 --- a/ext/intl/dateformat/dateformat_arginfo.h +++ b/ext/intl/dateformat/dateformat_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: e98080c0b9107da6a2bf3ce99929554eb9a3c70e */ + * Stub hash: 1b018a6b473db965a89c4ce9ebce3133d8d304db */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlDateFormatter___construct, 0, 0, 3) ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 1) diff --git a/ext/intl/intl_data.h b/ext/intl/intl_data.h index 29a053ab20..a076ebd705 100644 --- a/ext/intl/intl_data.h +++ b/ext/intl/intl_data.h @@ -71,6 +71,16 @@ typedef struct _intl_data { RETURN_FALSE; \ } +/* Check status in object, if error goto a label */ +#define INTL_METHOD_CHECK_STATUS_OR_GOTO(obj, msg, label) \ + intl_error_set_code( NULL, INTL_DATA_ERROR_CODE((obj)) ); \ + if( U_FAILURE( INTL_DATA_ERROR_CODE((obj)) ) ) \ + { \ + intl_errors_set_custom_msg( INTL_DATA_ERROR_P((obj)), msg, 0 ); \ + RETVAL_FALSE; \ + goto label; \ + } + /* Check status in object, if error return null */ #define INTL_METHOD_CHECK_STATUS_OR_NULL(obj, msg) \ intl_error_set_code( NULL, INTL_DATA_ERROR_CODE((obj)) ); \ diff --git a/ext/intl/php_intl.stub.php b/ext/intl/php_intl.stub.php index 8cb198e7d6..bf5e631ba4 100644 --- a/ext/intl/php_intl.stub.php +++ b/ext/intl/php_intl.stub.php @@ -89,8 +89,7 @@ function intlcal_set_repeated_wall_time_option(IntlCalendar $calendar, int $wall function intlcal_set_skipped_wall_time_option(IntlCalendar $calendar, int $wallTimeOption): bool {} -/** @param DateTime|string $dateTime */ -function intlcal_from_date_time($dateTime, ?string $locale = null): ?IntlCalendar {} +function intlcal_from_date_time(DateTime|string $dateTime, ?string $locale = null): ?IntlCalendar {} function intlcal_to_date_time(IntlCalendar $calendar): DateTime|false {} @@ -188,7 +187,7 @@ function datefmt_set_lenient(IntlDateFormatter $df, bool $lenient): void {} function datefmt_is_lenient(IntlDateFormatter $df): bool {} -/** @param mixed $value */ +/** @param object|array|string|int|float $value */ function datefmt_format(IntlDateFormatter $df, $value): string|false {} /** @@ -227,7 +226,7 @@ function numfmt_parse_currency(NumberFormatter $fmt, string $value, &$currency, /** @param int|float $value */ function numfmt_set_attribute(NumberFormatter $fmt, int $attr, $value): bool {} -function numfmt_get_attribute(NumberFormatter $fmt, int $attr): int|double|false {} +function numfmt_get_attribute(NumberFormatter $fmt, int $attr): int|float|false {} function numfmt_set_text_attribute(NumberFormatter $fmt, int $attr, string $value): bool {} @@ -372,7 +371,7 @@ function intltz_count_equivalent_ids(string $zoneId): int|false {} function intltz_create_default(): IntlTimeZone {} /** - * @param IntlTimeZone|string|int|double|null $countryOrRawOffset + * @param IntlTimeZone|string|int|float|null $countryOrRawOffset * @return IntlIterator|false */ function intltz_create_enumeration($countryOrRawOffset = null) {} @@ -436,8 +435,7 @@ function transliterator_list_ids(): array|false {} function transliterator_create_inverse(Transliterator $orig_trans): ?Transliterator {} -/** @param Transliterator|string $transliterator */ -function transliterator_transliterate($transliterator, string $subject, int $start = 0, int $end = -1): string|false {} +function transliterator_transliterate(Transliterator|string $transliterator, string $subject, int $start = 0, int $end = -1): string|false {} function transliterator_get_error_code(Transliterator $trans): int|false {} diff --git a/ext/intl/php_intl_arginfo.h b/ext/intl/php_intl_arginfo.h index d66163c1b5..cdead23643 100644 --- a/ext/intl/php_intl_arginfo.h +++ b/ext/intl/php_intl_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 57c63e06f2c6cf6c58a63081f19fe3e6d6901e88 */ + * Stub hash: 9284fbafde8c7430a30a8fff5537bf9e6d9c6125 */ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_intlcal_create_instance, 0, 0, IntlCalendar, 1) ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, timeZone, "null") @@ -162,7 +162,7 @@ ZEND_END_ARG_INFO() #define arginfo_intlcal_set_skipped_wall_time_option arginfo_intlcal_set_repeated_wall_time_option ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_intlcal_from_date_time, 0, 1, IntlCalendar, 1) - ZEND_ARG_INFO(0, dateTime) + ZEND_ARG_OBJ_TYPE_MASK(0, dateTime, DateTime, MAY_BE_STRING, NULL) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, locale, IS_STRING, 1, "null") ZEND_END_ARG_INFO() @@ -405,7 +405,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_numfmt_set_attribute, 0, 3, _IS_ ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_numfmt_get_attribute, 0, 2, double, MAY_BE_LONG|MAY_BE_FALSE) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_numfmt_get_attribute, 0, 2, MAY_BE_LONG|MAY_BE_DOUBLE|MAY_BE_FALSE) ZEND_ARG_OBJ_INFO(0, fmt, NumberFormatter, 0) ZEND_ARG_TYPE_INFO(0, attr, IS_LONG, 0) ZEND_END_ARG_INFO() @@ -763,7 +763,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_transliterator_create_inverse, 0, ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_transliterator_transliterate, 0, 2, MAY_BE_STRING|MAY_BE_FALSE) - ZEND_ARG_INFO(0, transliterator) + ZEND_ARG_OBJ_TYPE_MASK(0, transliterator, Transliterator, MAY_BE_STRING, NULL) ZEND_ARG_TYPE_INFO(0, subject, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, start, IS_LONG, 0, "0") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, end, IS_LONG, 0, "-1") diff --git a/ext/intl/timezone/timezone.stub.php b/ext/intl/timezone/timezone.stub.php index 5e6208bb73..da8c2c88d7 100644 --- a/ext/intl/timezone/timezone.stub.php +++ b/ext/intl/timezone/timezone.stub.php @@ -19,7 +19,7 @@ class IntlTimeZone public static function createDefault() {} /** - * @param IntlTimeZone|string|int|double|null $countryOrRawOffset + * @param IntlTimeZone|string|int|float|null $countryOrRawOffset * @return IntlIterator|false * @alias intltz_create_enumeration */ diff --git a/ext/intl/timezone/timezone_arginfo.h b/ext/intl/timezone/timezone_arginfo.h index b21975eed4..ce14cdced3 100644 --- a/ext/intl/timezone/timezone_arginfo.h +++ b/ext/intl/timezone/timezone_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 94e3c8228a0625a2c5825b0747fb1e5e08808b50 */ + * Stub hash: 69c4f052e9c75c4adb5b1b7056db981b2b26a22f */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlTimeZone___construct, 0, 0, 0) ZEND_END_ARG_INFO() diff --git a/ext/intl/transliterator/transliterator_methods.c b/ext/intl/transliterator/transliterator_methods.c index 5ec0e10b78..faf61e4914 100644 --- a/ext/intl/transliterator/transliterator_methods.c +++ b/ext/intl/transliterator/transliterator_methods.c @@ -280,47 +280,41 @@ PHP_FUNCTION( transliterator_transliterate ) TRANSLITERATOR_METHOD_INIT_VARS; object = getThis(); + ZVAL_UNDEF(&tmp_object); - if( object == NULL ) - { + if (object == NULL) { /* in non-OOP version, accept both a transliterator and a string */ - zval *arg1; - if( zend_parse_parameters( ZEND_NUM_ARGS(), "zs|ll", - &arg1, &str, &str_len, &start, &limit ) == FAILURE ) - { - RETURN_THROWS(); - } - - if( Z_TYPE_P( arg1 ) == IS_OBJECT && - instanceof_function( Z_OBJCE_P( arg1 ), Transliterator_ce_ptr ) ) - { - object = arg1; - } - else - { /* not a transliterator object as first argument */ + zend_string *arg1_str; + zend_object *arg1_obj; + + ZEND_PARSE_PARAMETERS_START(2, 4) + Z_PARAM_STR_OR_OBJ_OF_CLASS(arg1_str, arg1_obj, Transliterator_ce_ptr) + Z_PARAM_STRING(str, str_len) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(start) + Z_PARAM_LONG(limit) + ZEND_PARSE_PARAMETERS_END(); + + if (arg1_str) { /* not a transliterator object as first argument */ int res; - if( !try_convert_to_string( arg1 ) ) { - RETURN_THROWS(); - } object = &tmp_object; - res = create_transliterator( Z_STRVAL_P( arg1 ), Z_STRLEN_P( arg1 ), - TRANSLITERATOR_FORWARD, object ); + res = create_transliterator(ZSTR_VAL(arg1_str), ZSTR_LEN(arg1_str), TRANSLITERATOR_FORWARD, object); if( res == FAILURE ) { zend_string *message = intl_error_get_message( NULL ); php_error_docref(NULL, E_WARNING, "Could not create " - "transliterator with ID \"%s\" (%s)", Z_STRVAL_P( arg1 ), ZSTR_VAL(message) ); + "transliterator with ID \"%s\" (%s)", ZSTR_VAL(arg1_str), ZSTR_VAL(message) ); zend_string_free( message ); ZVAL_UNDEF(&tmp_object); /* don't set U_ILLEGAL_ARGUMENT_ERROR to allow fetching of inner error */ goto cleanup; } + } else { + ZVAL_OBJ_COPY(&tmp_object, arg1_obj); + object = &tmp_object; } - } - else if( zend_parse_parameters( ZEND_NUM_ARGS(), "s|ll", - &str, &str_len, &start, &limit ) == FAILURE ) - { + } else if(zend_parse_parameters( ZEND_NUM_ARGS(), "s|ll", &str, &str_len, &start, &limit) == FAILURE) { RETURN_THROWS(); } @@ -329,7 +323,8 @@ PHP_FUNCTION( transliterator_transliterate ) intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "transliterator_transliterate: \"end\" argument should be " "either non-negative or -1", 0 ); - RETURN_FALSE; + RETVAL_FALSE; + goto cleanup_object; } if( start < 0 || ((limit != -1 ) && (start > limit )) ) @@ -337,16 +332,16 @@ PHP_FUNCTION( transliterator_transliterate ) intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "transliterator_transliterate: \"start\" argument should be " "non-negative and not bigger than \"end\" (if defined)", 0 ); - RETURN_FALSE; + RETVAL_FALSE; + goto cleanup_object; } /* end argument parsing/validation */ TRANSLITERATOR_METHOD_FETCH_OBJECT; - intl_convert_utf8_to_utf16( &ustr, &ustr_len, str, str_len, - TRANSLITERATOR_ERROR_CODE_P( to ) ); - INTL_METHOD_CHECK_STATUS( to, "String conversion of string to UTF-16 failed" ); + intl_convert_utf8_to_utf16(&ustr, &ustr_len, str, str_len, TRANSLITERATOR_ERROR_CODE_P(to)); + INTL_METHOD_CHECK_STATUS_OR_GOTO(to, "String conversion of string to UTF-16 failed", cleanup_object); /* we've started allocating resources, goto from now on */ @@ -424,6 +419,7 @@ cleanup: RETVAL_FALSE; } +cleanup_object: zval_ptr_dtor( &tmp_object ); } /* }}} */ diff --git a/ext/oci8/oci8.stub.php b/ext/oci8/oci8.stub.php index f73226bb53..5c964c16f8 100644 --- a/ext/oci8/oci8.stub.php +++ b/ext/oci8/oci8.stub.php @@ -2,39 +2,28 @@ /** @generate-function-entries */ -/** - * @param resource $statement_resource - * @param mixed $variable - */ -function oci_define_by_name($statement_resource, string $column_name, &$variable, int $type = 0): bool {} +/** @param resource $statement_resource */ +function oci_define_by_name($statement_resource, string $column_name, mixed &$variable, int $type = 0): bool {} /** * @param resource $statement_resource - * @param mixed $variable * @alias oci_define_by_name * @deprecated */ -function ocidefinebyname($statement_resource, string $column_name, &$variable, int $type = 0): bool {} +function ocidefinebyname($statement_resource, string $column_name, mixed &$variable, int $type = 0): bool {} -/** - * @param resource $statement_resource - * @param mixed $variable - */ -function oci_bind_by_name($statement_resource, string $column_name, &$variable, int $maximum_length = -1, int $type = 0): bool {} +/** @param resource $statement_resource */ +function oci_bind_by_name($statement_resource, string $column_name, mixed &$variable, int $maximum_length = -1, int $type = 0): bool {} /** * @param resource $statement_resource - * @param mixed $variable * @alias oci_bind_by_name * @deprecated */ -function ocibindbyname($statement_resource, string $column_name, &$variable, int $maximum_length = -1, int $type = 0): bool {} +function ocibindbyname($statement_resource, string $column_name, mixed &$variable, int $maximum_length = -1, int $type = 0): bool {} -/** - * @param resource $statement_resource - * @param mixed $variable - */ -function oci_bind_array_by_name($statement_resource, string $column_name, &$variable, int $maximum_array_length, int $maximum_item_length = -1, int $type = SQLT_AFC): bool {} +/** @param resource $statement_resource */ +function oci_bind_array_by_name($statement_resource, string $column_name, mixed &$variable, int $maximum_array_length, int $maximum_item_length = -1, int $type = SQLT_AFC): bool {} function oci_free_descriptor(OCILob $lob_descriptor): bool {} diff --git a/ext/oci8/oci8_arginfo.h b/ext/oci8/oci8_arginfo.h index 4ebacd5260..77638aa9a0 100644 --- a/ext/oci8/oci8_arginfo.h +++ b/ext/oci8/oci8_arginfo.h @@ -1,10 +1,10 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 1c1a73f6a4de5fa2ca9595125822d65bc4f5fc55 */ + * Stub hash: a5a245b354b48a56c274c8f74c974d92ec430853 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_define_by_name, 0, 3, _IS_BOOL, 0) ZEND_ARG_INFO(0, statement_resource) ZEND_ARG_TYPE_INFO(0, column_name, IS_STRING, 0) - ZEND_ARG_INFO(1, variable) + ZEND_ARG_TYPE_INFO(1, variable, IS_MIXED, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, type, IS_LONG, 0, "0") ZEND_END_ARG_INFO() @@ -13,7 +13,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_bind_by_name, 0, 3, _IS_BOOL, 0) ZEND_ARG_INFO(0, statement_resource) ZEND_ARG_TYPE_INFO(0, column_name, IS_STRING, 0) - ZEND_ARG_INFO(1, variable) + ZEND_ARG_TYPE_INFO(1, variable, IS_MIXED, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, maximum_length, IS_LONG, 0, "-1") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, type, IS_LONG, 0, "0") ZEND_END_ARG_INFO() @@ -23,7 +23,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_bind_array_by_name, 0, 4, _IS_BOOL, 0) ZEND_ARG_INFO(0, statement_resource) ZEND_ARG_TYPE_INFO(0, column_name, IS_STRING, 0) - ZEND_ARG_INFO(1, variable) + ZEND_ARG_TYPE_INFO(1, variable, IS_MIXED, 0) ZEND_ARG_TYPE_INFO(0, maximum_array_length, IS_LONG, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, maximum_item_length, IS_LONG, 0, "-1") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, type, IS_LONG, 0, "SQLT_AFC") diff --git a/ext/pdo/pdo_dbh.stub.php b/ext/pdo/pdo_dbh.stub.php index a35e34e098..2348abf048 100644 --- a/ext/pdo/pdo_dbh.stub.php +++ b/ext/pdo/pdo_dbh.stub.php @@ -46,7 +46,7 @@ class PDO public function rollBack() {} /** - * @param mixed $value + * @param array|int $value * @return bool */ public function setAttribute(int $attribute, $value) {} diff --git a/ext/pdo/pdo_dbh_arginfo.h b/ext/pdo/pdo_dbh_arginfo.h index b5cf1d81d0..a3ab1994ed 100644 --- a/ext/pdo/pdo_dbh_arginfo.h +++ b/ext/pdo/pdo_dbh_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 623f0a96bc1ae5eadcac5ba92eb73189cd3230cd */ + * Stub hash: 0c7acc78768ad1fb77a09a24ebd4d4e660b350c9 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO___construct, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, dsn, IS_STRING, 0) diff --git a/ext/pdo/pdo_stmt.stub.php b/ext/pdo/pdo_stmt.stub.php index d81097c164..d0141ceb45 100644 --- a/ext/pdo/pdo_stmt.stub.php +++ b/ext/pdo/pdo_stmt.stub.php @@ -55,11 +55,8 @@ class PDOStatement implements IteratorAggregate /** @return int|false */ public function rowCount() {} - /** - * @param mixed $value - * @return bool - */ - public function setAttribute(int $attribute, $value) {} + /** @return bool */ + public function setAttribute(int $attribute, mixed $value) {} /** @return bool */ public function setFetchMode(int $mode, mixed ...$params) {} diff --git a/ext/pdo/pdo_stmt_arginfo.h b/ext/pdo/pdo_stmt_arginfo.h index a819f6a91e..c05606c6fa 100644 --- a/ext/pdo/pdo_stmt_arginfo.h +++ b/ext/pdo/pdo_stmt_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 45c43e025d9194f2dd7b2ab13d86a4e5f316fa48 */ + * Stub hash: 18f2af62bebcbbbf0e298f781860c251cfa07930 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_bindColumn, 0, 0, 2) ZEND_ARG_TYPE_MASK(0, column, MAY_BE_STRING|MAY_BE_LONG, NULL) @@ -72,7 +72,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_setAttribute, 0, 0, 2) ZEND_ARG_TYPE_INFO(0, attribute, IS_LONG, 0) - ZEND_ARG_INFO(0, value) + ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_setFetchMode, 0, 0, 1) diff --git a/ext/phar/phar_object.stub.php b/ext/phar/phar_object.stub.php index d9b69f784f..da6ab987ed 100644 --- a/ext/phar/phar_object.stub.php +++ b/ext/phar/phar_object.stub.php @@ -127,11 +127,8 @@ class Phar extends RecursiveDirectoryIterator implements Countable, ArrayAccess /** @return bool */ public function setDefaultStub(?string $index = null, ?string $webindex = null) {} - /** - * @param mixed $metadata - * @return void - */ - public function setMetadata($metadata) {} + /** @return void */ + public function setMetadata(mixed $metadata) {} /** @return void */ public function setSignatureAlgorithm(int $algorithm, string $privatekey = UNKNOWN) {} @@ -401,11 +398,10 @@ class PharData extends RecursiveDirectoryIterator implements Countable, ArrayAcc public function setDefaultStub(?string $index = null, ?string $webindex = null) {} /** - * @param mixed $metadata * @return void * @alias Phar::setMetadata */ - public function setMetadata($metadata) {} + public function setMetadata(mixed $metadata) {} /** * @return void diff --git a/ext/phar/phar_object_arginfo.h b/ext/phar/phar_object_arginfo.h index 95799bd487..e3963fe1a9 100644 --- a/ext/phar/phar_object_arginfo.h +++ b/ext/phar/phar_object_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: be0f8bcd0ef8fdac59700160dff7d0beb210aa48 */ + * Stub hash: d735d786b6804e336f45ac99c80276f5c67d4258 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar___construct, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) @@ -129,7 +129,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar_setDefaultStub, 0, 0, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar_setMetadata, 0, 0, 1) - ZEND_ARG_INFO(0, metadata) + ZEND_ARG_TYPE_INFO(0, metadata, IS_MIXED, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar_setSignatureAlgorithm, 0, 0, 1) @@ -360,9 +360,7 @@ ZEND_END_ARG_INFO() #define arginfo_class_PharFileInfo_isCRCChecked arginfo_class_Phar___destruct -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PharFileInfo_setMetadata, 0, 0, 1) - ZEND_ARG_TYPE_INFO(0, metadata, IS_MIXED, 0) -ZEND_END_ARG_INFO() +#define arginfo_class_PharFileInfo_setMetadata arginfo_class_Phar_setMetadata ZEND_METHOD(Phar, __construct); diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c index 7cc7714d38..ab512c68d0 100644 --- a/ext/snmp/snmp.c +++ b/ext/snmp/snmp.c @@ -659,31 +659,17 @@ retry: * OID parser (and type, value for SNMP_SET command) */ -static int php_snmp_parse_oid(zval *object, int st, struct objid_query *objid_query, zval *oid, zval *type, zval *value) +static int php_snmp_parse_oid(zval *object, int st, struct objid_query *objid_query, zend_string *oid_str, HashTable *oid_ht, zval *type, zval *value) { char *pptr; uint32_t idx_type = 0, idx_value = 0; zval *tmp_oid, *tmp_type, *tmp_value; - if (Z_TYPE_P(oid) != IS_ARRAY) { - convert_to_string_ex(oid); - } - - if (st & SNMP_CMD_SET) { - if (Z_TYPE_P(type) != IS_ARRAY) { - convert_to_string_ex(type); - } - - if (Z_TYPE_P(value) != IS_ARRAY) { - convert_to_string_ex(value); - } - } - objid_query->count = 0; objid_query->array_output = ((st & SNMP_CMD_WALK) ? TRUE : FALSE); - if (Z_TYPE_P(oid) == IS_STRING) { + if (oid_str) { objid_query->vars = (snmpobjarg *)emalloc(sizeof(snmpobjarg)); - objid_query->vars[objid_query->count].oid = Z_STRVAL_P(oid); + objid_query->vars[objid_query->count].oid = ZSTR_VAL(oid_str); if (st & SNMP_CMD_SET) { if (Z_TYPE_P(type) == IS_STRING && Z_TYPE_P(value) == IS_STRING) { if (Z_STRLEN_P(type) != 1) { @@ -701,14 +687,14 @@ static int php_snmp_parse_oid(zval *object, int st, struct objid_query *objid_qu } } objid_query->count++; - } else if (Z_TYPE_P(oid) == IS_ARRAY) { /* we got objid array */ - if (zend_hash_num_elements(Z_ARRVAL_P(oid)) == 0) { + } else if (oid_ht) { /* we got objid array */ + if (zend_hash_num_elements(oid_ht) == 0) { php_error_docref(NULL, E_WARNING, "Got empty OID array"); return FALSE; } - objid_query->vars = (snmpobjarg *)safe_emalloc(sizeof(snmpobjarg), zend_hash_num_elements(Z_ARRVAL_P(oid)), 0); + objid_query->vars = (snmpobjarg *)safe_emalloc(sizeof(snmpobjarg), zend_hash_num_elements(oid_ht), 0); objid_query->array_output = ( (st & SNMP_CMD_SET) ? FALSE : TRUE ); - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(oid), tmp_oid) { + ZEND_HASH_FOREACH_VAL(oid_ht, tmp_oid) { convert_to_string_ex(tmp_oid); objid_query->vars[objid_query->count].oid = Z_STRVAL_P(tmp_oid); if (st & SNMP_CMD_SET) { @@ -1091,7 +1077,9 @@ static int netsnmp_session_set_security(struct snmp_session *session, char *sec_ */ static void php_snmp(INTERNAL_FUNCTION_PARAMETERS, int st, int version) { - zval *oid, *value = NULL, *type = NULL; + zend_string *oid_str; + HashTable *oid_ht; + zval *value = NULL, *type = NULL; char *a1, *a2, *a3, *a4, *a5, *a6, *a7; size_t a1_len, a2_len, a3_len, a4_len, a5_len, a6_len, a7_len; zend_bool use_orignames = 0, suffix_keys = 0; @@ -1112,64 +1100,104 @@ static void php_snmp(INTERNAL_FUNCTION_PARAMETERS, int st, int version) if (session_less_mode) { if (version == SNMP_VERSION_3) { if (st & SNMP_CMD_SET) { - if (zend_parse_parameters(argc, "ssssssszzz|ll", &a1, &a1_len, &a2, &a2_len, &a3, &a3_len, - &a4, &a4_len, &a5, &a5_len, &a6, &a6_len, &a7, &a7_len, &oid, &type, &value, &timeout, &retries) == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_START(10, 12) + Z_PARAM_STRING(a1, a1_len) + Z_PARAM_STRING(a2, a2_len) + Z_PARAM_STRING(a3, a3_len) + Z_PARAM_STRING(a4, a4_len) + Z_PARAM_STRING(a5, a5_len) + Z_PARAM_STRING(a6, a6_len) + Z_PARAM_STRING(a7, a7_len) + Z_PARAM_STR_OR_ARRAY_HT(oid_str, oid_ht) + Z_PARAM_ZVAL(type) + Z_PARAM_ZVAL(value) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(timeout) + Z_PARAM_LONG(retries) + ZEND_PARSE_PARAMETERS_END(); } else { /* SNMP_CMD_GET * SNMP_CMD_GETNEXT * SNMP_CMD_WALK */ - if (zend_parse_parameters(argc, "sssssssz|ll", &a1, &a1_len, &a2, &a2_len, &a3, &a3_len, - &a4, &a4_len, &a5, &a5_len, &a6, &a6_len, &a7, &a7_len, &oid, &timeout, &retries) == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_START(8, 10) + Z_PARAM_STRING(a1, a1_len) + Z_PARAM_STRING(a2, a2_len) + Z_PARAM_STRING(a3, a3_len) + Z_PARAM_STRING(a4, a4_len) + Z_PARAM_STRING(a5, a5_len) + Z_PARAM_STRING(a6, a6_len) + Z_PARAM_STRING(a7, a7_len) + Z_PARAM_STR_OR_ARRAY_HT(oid_str, oid_ht) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(timeout) + Z_PARAM_LONG(retries) + ZEND_PARSE_PARAMETERS_END(); } } else { if (st & SNMP_CMD_SET) { - if (zend_parse_parameters(argc, "sszzz|ll", &a1, &a1_len, &a2, &a2_len, &oid, &type, &value, &timeout, &retries) == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_START(5, 7) + Z_PARAM_STRING(a1, a1_len) + Z_PARAM_STRING(a2, a2_len) + Z_PARAM_STR_OR_ARRAY_HT(oid_str, oid_ht) + Z_PARAM_ZVAL(type) + Z_PARAM_ZVAL(value) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(timeout) + Z_PARAM_LONG(retries) + ZEND_PARSE_PARAMETERS_END(); } else { /* SNMP_CMD_GET * SNMP_CMD_GETNEXT * SNMP_CMD_WALK */ - if (zend_parse_parameters(argc, "ssz|ll", &a1, &a1_len, &a2, &a2_len, &oid, &timeout, &retries) == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_START(3, 5) + Z_PARAM_STRING(a1, a1_len) + Z_PARAM_STRING(a2, a2_len) + Z_PARAM_STR_OR_ARRAY_HT(oid_str, oid_ht) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(timeout) + Z_PARAM_LONG(retries) + ZEND_PARSE_PARAMETERS_END(); } } } else { if (st & SNMP_CMD_SET) { - if (zend_parse_parameters(argc, "zzz", &oid, &type, &value) == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR_OR_ARRAY_HT(oid_str, oid_ht) + Z_PARAM_ZVAL(type) + Z_PARAM_ZVAL(value) + ZEND_PARSE_PARAMETERS_END(); } else if (st & SNMP_CMD_WALK) { - if (zend_parse_parameters(argc, "z|bll", &oid, &suffix_keys, &(objid_query.max_repetitions), &(objid_query.non_repeaters)) == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_START(1, 4) + Z_PARAM_STR_OR_ARRAY_HT(oid_str, oid_ht) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(suffix_keys) + Z_PARAM_LONG(objid_query.max_repetitions) + Z_PARAM_LONG(objid_query.non_repeaters) + ZEND_PARSE_PARAMETERS_END(); if (suffix_keys) { st |= SNMP_USE_SUFFIX_AS_KEYS; } } else if (st & SNMP_CMD_GET) { - if (zend_parse_parameters(argc, "z|b", &oid, &use_orignames) == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR_OR_ARRAY_HT(oid_str, oid_ht) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(use_orignames) + ZEND_PARSE_PARAMETERS_END(); if (use_orignames) { st |= SNMP_ORIGINAL_NAMES_AS_KEYS; } } else { /* SNMP_CMD_GETNEXT */ - if (zend_parse_parameters(argc, "z", &oid) == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR_OR_ARRAY_HT(oid_str, oid_ht) + ZEND_PARSE_PARAMETERS_END(); } } - if (!php_snmp_parse_oid(getThis(), st, &objid_query, oid, type, value)) { + if (!php_snmp_parse_oid(getThis(), st, &objid_query, oid_str, oid_ht, type, value)) { RETURN_FALSE; } diff --git a/ext/snmp/snmp.stub.php b/ext/snmp/snmp.stub.php index 06632b602d..72d42e3461 100644 --- a/ext/snmp/snmp.stub.php +++ b/ext/snmp/snmp.stub.php @@ -2,30 +2,22 @@ /** @generate-function-entries */ -/** @param array|string $object_id */ -function snmpget(string $host, string $community, $object_id, int $timeout = UNKNOWN, int $retries = UNKNOWN): array|bool {} +function snmpget(string $host, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {} -/** @param array|string $object_id */ -function snmpgetnext(string $host, string $community, $object_id, int $timeout = UNKNOWN, int $retries = UNKNOWN): array|bool {} +function snmpgetnext(string $host, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {} -/** @param array|string $object_id */ -function snmpwalk(string $host, string $community, $object_id, int $timeout = UNKNOWN, int $retries = UNKNOWN): array|bool {} +function snmpwalk(string $host, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {} -/** @param array|string $object_id */ -function snmprealwalk(string $host, string $community, $object_id, int $timeout = UNKNOWN, int $retries = UNKNOWN): array|bool {} +function snmprealwalk(string $host, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {} -/** - * @param array|string $object_id - * @alias snmprealwalk - */ -function snmpwalkoid(string $host, string $community, $object_id, int $timeout = UNKNOWN, int $retries = UNKNOWN): array|bool {} +/** @alias snmprealwalk */ +function snmpwalkoid(string $host, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {} /** - * @param array|string $object_id * @param array|string $type * @param array|string $value */ -function snmpset(string $host, string $community, $object_id, $type, $value, int $timeout = UNKNOWN, int $retries = UNKNOWN): array|bool {} +function snmpset(string $host, string $community, array|string $object_id, $type, $value, int $timeout = -1, int $retries = -1): array|bool {} function snmp_get_quick_print(): bool {} @@ -38,43 +30,33 @@ function snmp_set_oid_output_format(int $oid_format): bool {} /** @alias snmp_set_oid_output_format */ function snmp_set_oid_numeric_print(int $oid_format): bool {} -/** @param array|string $object_id */ -function snmp2_get(string $host, string $community, $object_id, int $timeout = UNKNOWN, int $retries = UNKNOWN): array|bool {} +function snmp2_get(string $host, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {} -/** @param array|string $object_id */ -function snmp2_getnext(string $host, string $community, $object_id, int $timeout = UNKNOWN, int $retries = UNKNOWN): array|bool {} +function snmp2_getnext(string $host, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {} -/** @param array|string $object_id */ -function snmp2_walk(string $host, string $community, $object_id, int $timeout = UNKNOWN, int $retries = UNKNOWN): array|bool {} +function snmp2_walk(string $host, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {} -/** @param array|string $object_id */ -function snmp2_real_walk(string $host, string $community, $object_id, int $timeout = UNKNOWN, int $retries = UNKNOWN): array|bool {} +function snmp2_real_walk(string $host, string $community, array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {} /** - * @param array|string $object_id * @param array|string $type * @param array|string $value */ -function snmp2_set(string $host, string $community, $object_id, $type, $value, int $timeout = UNKNOWN, int $retries = UNKNOWN): array|bool {} +function snmp2_set(string $host, string $community, array|string $object_id, $type, $value, int $timeout = -1, int $retries = -1): array|bool {} -/** @param array|string $object_id */ -function snmp3_get(string $host, string $sec_name, string $sec_level, string $auth_protocol, string $auth_passphrase, string $priv_protocol, string $priv_passphrase, $object_id, int $timeout = UNKNOWN, int $retries = UNKNOWN): array|bool {} +function snmp3_get(string $host, string $sec_name, string $sec_level, string $auth_protocol, string $auth_passphrase, string $priv_protocol, string $priv_passphrase, array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {} -/** @param array|string $object_id */ -function snmp3_getnext(string $host, string $sec_name, string $sec_level, string $auth_protocol, string $auth_passphrase, string $priv_protocol, string $priv_passphrase, $object_id, int $timeout = UNKNOWN, int $retries = UNKNOWN): array|bool {} +function snmp3_getnext(string $host, string $sec_name, string $sec_level, string $auth_protocol, string $auth_passphrase, string $priv_protocol, string $priv_passphrase, array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {} -/** @param array|string $object_id */ -function snmp3_walk(string $host, string $sec_name, string $sec_level, string $auth_protocol, string $auth_passphrase, string $priv_protocol, string $priv_passphrase, $object_id, int $timeout = UNKNOWN, int $retries = UNKNOWN): array|bool {} +function snmp3_walk(string $host, string $sec_name, string $sec_level, string $auth_protocol, string $auth_passphrase, string $priv_protocol, string $priv_passphrase, array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {} -/** @param array|string $object_id */ -function snmp3_real_walk(string $host, string $sec_name, string $sec_level, string $auth_protocol, string $auth_passphrase, string $priv_protocol, string $priv_passphrase, $object_id, int $timeout = UNKNOWN, int $retries = UNKNOWN): array|bool {} +function snmp3_real_walk(string $host, string $sec_name, string $sec_level, string $auth_protocol, string $auth_passphrase, string $priv_protocol, string $priv_passphrase, array|string $object_id, int $timeout = -1, int $retries = -1): array|bool {} /** - * @param array|string $object_id * @param array|string $type * @param array|string $value */ -function snmp3_set(string $host, string $sec_name, string $sec_level, string $auth_protocol, string $auth_passphrase, string $priv_protocol, string $priv_passphrase, $object_id, $type, $value, int $timeout = UNKNOWN, int $retries = UNKNOWN): array|bool {} +function snmp3_set(string $host, string $sec_name, string $sec_level, string $auth_protocol, string $auth_passphrase, string $priv_protocol, string $priv_passphrase, array|string $object_id, $type, $value, int $timeout = -1, int $retries = -1): array|bool {} function snmp_set_valueretrieval(int $method): bool {} @@ -84,7 +66,7 @@ function snmp_read_mib(string $filename): bool {} class SNMP { - public function __construct(int $version, string $host, string $community, int $timeout = UNKNOWN, int $retries = UNKNOWN) {} + public function __construct(int $version, string $host, string $community, int $timeout = -1, int $retries = -1) {} /** @return bool */ public function close() {} @@ -92,31 +74,21 @@ class SNMP /** @return bool */ public function setSecurity(string $sec_level, string $auth_protocol = '', string $auth_passphrase = '', string $priv_protocol = '', string $priv_passphrase = '', string $contextName = '', string $contextEngineID = '') {} - /** - * @param array|string $object_id - * @return array|bool - */ - public function get($object_id, bool $use_orignames = false) {} + /** @return array|bool */ + public function get(array|string $object_id, bool $use_orignames = false) {} - /** - * @param array|string $object_id - * @return array|bool - */ - public function getnext($object_id) {} + /** @return array|bool */ + public function getnext(array|string $object_id) {} - /** - * @param array|string $object_id - * @return array|bool - */ - public function walk($object_id, bool $suffix_keys = false, int $max_repetitions = UNKNOWN, int $non_repeaters = UNKNOWN) {} + /** @return array|bool */ + public function walk(array|string $object_id, bool $suffix_keys = false, int $max_repetitions = UNKNOWN, int $non_repeaters = UNKNOWN) {} /** - * @param array|string $object_id * @param array|string $type * @param array|string $value * @return array|bool */ - public function set($object_id, $type, $value) {} + public function set(array|string $object_id, $type, $value) {} /** @return int */ public function getErrno() {} diff --git a/ext/snmp/snmp_arginfo.h b/ext/snmp/snmp_arginfo.h index b12f4f8a24..8a734fd573 100644 --- a/ext/snmp/snmp_arginfo.h +++ b/ext/snmp/snmp_arginfo.h @@ -1,12 +1,12 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 2b0a8233a01de36e93c025bc40c3a2f707825595 */ + * Stub hash: 02b1dd87856dfdb43039f4544f3e5225a1fb1a6e */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_snmpget, 0, 3, MAY_BE_ARRAY|MAY_BE_BOOL) ZEND_ARG_TYPE_INFO(0, host, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, community, IS_STRING, 0) - ZEND_ARG_INFO(0, object_id) - ZEND_ARG_TYPE_INFO(0, timeout, IS_LONG, 0) - ZEND_ARG_TYPE_INFO(0, retries, IS_LONG, 0) + ZEND_ARG_TYPE_MASK(0, object_id, MAY_BE_ARRAY|MAY_BE_STRING, NULL) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, timeout, IS_LONG, 0, "-1") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, retries, IS_LONG, 0, "-1") ZEND_END_ARG_INFO() #define arginfo_snmpgetnext arginfo_snmpget @@ -20,11 +20,11 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_snmpset, 0, 5, MAY_BE_ARRAY|MAY_BE_BOOL) ZEND_ARG_TYPE_INFO(0, host, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, community, IS_STRING, 0) - ZEND_ARG_INFO(0, object_id) + ZEND_ARG_TYPE_MASK(0, object_id, MAY_BE_ARRAY|MAY_BE_STRING, NULL) ZEND_ARG_INFO(0, type) ZEND_ARG_INFO(0, value) - ZEND_ARG_TYPE_INFO(0, timeout, IS_LONG, 0) - ZEND_ARG_TYPE_INFO(0, retries, IS_LONG, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, timeout, IS_LONG, 0, "-1") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, retries, IS_LONG, 0, "-1") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_snmp_get_quick_print, 0, 0, _IS_BOOL, 0) @@ -62,9 +62,9 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_snmp3_get, 0, 8, MAY_BE_ARRAY|MA ZEND_ARG_TYPE_INFO(0, auth_passphrase, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, priv_protocol, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, priv_passphrase, IS_STRING, 0) - ZEND_ARG_INFO(0, object_id) - ZEND_ARG_TYPE_INFO(0, timeout, IS_LONG, 0) - ZEND_ARG_TYPE_INFO(0, retries, IS_LONG, 0) + ZEND_ARG_TYPE_MASK(0, object_id, MAY_BE_ARRAY|MAY_BE_STRING, NULL) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, timeout, IS_LONG, 0, "-1") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, retries, IS_LONG, 0, "-1") ZEND_END_ARG_INFO() #define arginfo_snmp3_getnext arginfo_snmp3_get @@ -81,11 +81,11 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_snmp3_set, 0, 10, MAY_BE_ARRAY|M ZEND_ARG_TYPE_INFO(0, auth_passphrase, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, priv_protocol, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, priv_passphrase, IS_STRING, 0) - ZEND_ARG_INFO(0, object_id) + ZEND_ARG_TYPE_MASK(0, object_id, MAY_BE_ARRAY|MAY_BE_STRING, NULL) ZEND_ARG_INFO(0, type) ZEND_ARG_INFO(0, value) - ZEND_ARG_TYPE_INFO(0, timeout, IS_LONG, 0) - ZEND_ARG_TYPE_INFO(0, retries, IS_LONG, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, timeout, IS_LONG, 0, "-1") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, retries, IS_LONG, 0, "-1") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_snmp_set_valueretrieval, 0, 1, _IS_BOOL, 0) @@ -103,8 +103,8 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SNMP___construct, 0, 0, 3) ZEND_ARG_TYPE_INFO(0, version, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, host, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, community, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, timeout, IS_LONG, 0) - ZEND_ARG_TYPE_INFO(0, retries, IS_LONG, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, timeout, IS_LONG, 0, "-1") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, retries, IS_LONG, 0, "-1") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SNMP_close, 0, 0, 0) @@ -121,23 +121,23 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SNMP_setSecurity, 0, 0, 1) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SNMP_get, 0, 0, 1) - ZEND_ARG_INFO(0, object_id) + ZEND_ARG_TYPE_MASK(0, object_id, MAY_BE_ARRAY|MAY_BE_STRING, NULL) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, use_orignames, _IS_BOOL, 0, "false") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SNMP_getnext, 0, 0, 1) - ZEND_ARG_INFO(0, object_id) + ZEND_ARG_TYPE_MASK(0, object_id, MAY_BE_ARRAY|MAY_BE_STRING, NULL) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SNMP_walk, 0, 0, 1) - ZEND_ARG_INFO(0, object_id) + ZEND_ARG_TYPE_MASK(0, object_id, MAY_BE_ARRAY|MAY_BE_STRING, NULL) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, suffix_keys, _IS_BOOL, 0, "false") ZEND_ARG_TYPE_INFO(0, max_repetitions, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, non_repeaters, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SNMP_set, 0, 0, 3) - ZEND_ARG_INFO(0, object_id) + ZEND_ARG_TYPE_MASK(0, object_id, MAY_BE_ARRAY|MAY_BE_STRING, NULL) ZEND_ARG_INFO(0, type) ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index e307177fea..5beddc3391 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -1085,7 +1085,6 @@ static void spl_array_set_array(zval *object, spl_array_object *intern, zval *ar zend_throw_exception(spl_ce_InvalidArgumentException, "Passed variable is not an array or object", 0); return; } - if (Z_TYPE_P(array) == IS_ARRAY) { zval_ptr_dtor(&intern->array); if (Z_REFCOUNT_P(array) == 1) { @@ -1175,7 +1174,7 @@ PHP_METHOD(ArrayObject, __construct) return; /* nothing to do */ } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|zlC", &array, &ar_flags, &ce_get_iterator) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|AlC", &array, &ar_flags, &ce_get_iterator) == FAILURE) { RETURN_THROWS(); } @@ -1203,7 +1202,7 @@ PHP_METHOD(ArrayIterator, __construct) return; /* nothing to do */ } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|zl", &array, &ar_flags) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|Al", &array, &ar_flags) == FAILURE) { RETURN_THROWS(); } @@ -1280,7 +1279,7 @@ PHP_METHOD(ArrayObject, exchangeArray) zval *object = ZEND_THIS, *array; spl_array_object *intern = Z_SPLARRAY_P(object); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &array) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "A", &array) == FAILURE) { RETURN_THROWS(); } diff --git a/ext/spl/spl_array.stub.php b/ext/spl/spl_array.stub.php index 7b1ae02afc..114f1b6e32 100755 --- a/ext/spl/spl_array.stub.php +++ b/ext/spl/spl_array.stub.php @@ -4,39 +4,34 @@ class ArrayObject implements IteratorAggregate, ArrayAccess, Serializable, Countable { - /** @param array|object $input */ - public function __construct($input = [], int $flags = 0, string $iterator_class = ArrayIterator::class) {} + public function __construct(array|object $input = [], int $flags = 0, string $iterator_class = ArrayIterator::class) {} /** - * @param mixed $index + * @param string|int $index * @return bool */ public function offsetExists($index) {} /** - * @param mixed $index + * @param string|int $index * @return mixed */ public function offsetGet($index) {} /** - * @param mixed $index - * @param mixed $value + * @param string|int $index * @return void */ - public function offsetSet($index, $value) {} + public function offsetSet($index, mixed $value) {} /** - * @param mixed $index + * @param string|int $index * @return void */ public function offsetUnset($index) {} - /** - * @param mixed $value - * @return void - */ - public function append($value) {} + /** @return void */ + public function append(mixed $value) {} /** @return array */ public function getArrayCopy() {} @@ -50,29 +45,17 @@ class ArrayObject implements IteratorAggregate, ArrayAccess, Serializable, Count /** @return void */ public function setFlags(int $flags) {} - /** - * @param int $sort_flags - * @return bool - */ - public function asort($sort_flags = SORT_REGULAR) {} + /** @return bool */ + public function asort(int $sort_flags = SORT_REGULAR) {} - /** - * @param int $sort_flags - * @return bool - */ - public function ksort($sort_flags = SORT_REGULAR) {} + /** @return bool */ + public function ksort(int $sort_flags = SORT_REGULAR) {} - /** - * @param callback $cmp_function - * @return bool - */ - public function uasort($cmp_function) {} + /** @return bool */ + public function uasort(callable $cmp_function) {} - /** - * @param callback $cmp_function - * @return bool - */ - public function uksort($cmp_function) {} + /** @return bool */ + public function uksort(callable $cmp_function) {} /** @return bool */ public function natsort() {} @@ -95,11 +78,8 @@ class ArrayObject implements IteratorAggregate, ArrayAccess, Serializable, Count /** @return Iterator */ public function getIterator() {} - /** - * @param array|object $input - * @return array|null - */ - public function exchangeArray($input) {} + /** @return array|null */ + public function exchangeArray(array|object $input) {} /** @return void */ public function setIteratorClass(string $iteratorClass) {} @@ -113,44 +93,41 @@ class ArrayObject implements IteratorAggregate, ArrayAccess, Serializable, Count class ArrayIterator implements SeekableIterator, ArrayAccess, Serializable, Countable { - /** @param array|object $array */ - public function __construct($array = [], int $flags = 0) {} + public function __construct(array|object $array = [], int $flags = 0) {} /** - * @param mixed $index + * @param string|int $index * @return bool * @alias ArrayObject::offsetExists */ public function offsetExists($index) {} /** - * @param mixed $index + * @param string|int $index * @return mixed * @alias ArrayObject::offsetGet */ public function offsetGet($index) {} /** - * @param mixed $index - * @param mixed $value + * @param string|int $index * @return void * @alias ArrayObject::offsetSet */ - public function offsetSet($index, $value) {} + public function offsetSet($index, mixed $value) {} /** - * @param mixed $index + * @param string|int $index * @return void * @alias ArrayObject::offsetUnset */ public function offsetUnset($index) {} /** - * @param mixed $value * @return void * @alias ArrayObject::append */ - public function append($value) {} + public function append(mixed $value) {} /** * @return array @@ -177,32 +154,28 @@ class ArrayIterator implements SeekableIterator, ArrayAccess, Serializable, Coun public function setFlags(int $flags) {} /** - * @param int $sort_flags * @return bool * @alias ArrayObject::asort */ - public function asort($sort_flags = SORT_REGULAR) {} + public function asort(int $sort_flags = SORT_REGULAR) {} /** - * @param int $sort_flags * @return bool * @alias ArrayObject::ksort */ - public function ksort($sort_flags = SORT_REGULAR) {} + public function ksort(int $sort_flags = SORT_REGULAR) {} /** - * @param callback $cmp_function * @return bool * @alias ArrayObject::uasort */ - public function uasort($cmp_function) {} + public function uasort(callable $cmp_function) {} /** - * @param callback $cmp_function * @return bool * @alias ArrayObject::uksort */ - public function uksort($cmp_function) {} + public function uksort(callable $cmp_function) {} /** * @return bool diff --git a/ext/spl/spl_array_arginfo.h b/ext/spl/spl_array_arginfo.h index 5d0b1f3943..1f5fdcc061 100644 --- a/ext/spl/spl_array_arginfo.h +++ b/ext/spl/spl_array_arginfo.h @@ -1,8 +1,8 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 1230e3161d7c7fb549c5ac2ec5cde2dec585d849 */ + * Stub hash: bedd13338707177e28a021722df64be2f74a7945 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ArrayObject___construct, 0, 0, 0) - ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, input, "[]") + ZEND_ARG_TYPE_MASK(0, input, MAY_BE_ARRAY|MAY_BE_OBJECT, "[]") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "0") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, iterator_class, IS_STRING, 0, "ArrayIterator::class") ZEND_END_ARG_INFO() @@ -15,13 +15,13 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ArrayObject_offsetSet, 0, 0, 2) ZEND_ARG_INFO(0, index) - ZEND_ARG_INFO(0, value) + ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0) ZEND_END_ARG_INFO() #define arginfo_class_ArrayObject_offsetUnset arginfo_class_ArrayObject_offsetExists ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ArrayObject_append, 0, 0, 1) - ZEND_ARG_INFO(0, value) + ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ArrayObject_getArrayCopy, 0, 0, 0) @@ -36,13 +36,13 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ArrayObject_setFlags, 0, 0, 1) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ArrayObject_asort, 0, 0, 0) - ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, sort_flags, "SORT_REGULAR") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, sort_flags, IS_LONG, 0, "SORT_REGULAR") ZEND_END_ARG_INFO() #define arginfo_class_ArrayObject_ksort arginfo_class_ArrayObject_asort ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ArrayObject_uasort, 0, 0, 1) - ZEND_ARG_INFO(0, cmp_function) + ZEND_ARG_TYPE_INFO(0, cmp_function, IS_CALLABLE, 0) ZEND_END_ARG_INFO() #define arginfo_class_ArrayObject_uksort arginfo_class_ArrayObject_uasort @@ -66,7 +66,7 @@ ZEND_END_ARG_INFO() #define arginfo_class_ArrayObject_getIterator arginfo_class_ArrayObject_getArrayCopy ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ArrayObject_exchangeArray, 0, 0, 1) - ZEND_ARG_INFO(0, input) + ZEND_ARG_TYPE_MASK(0, input, MAY_BE_ARRAY|MAY_BE_OBJECT, NULL) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ArrayObject_setIteratorClass, 0, 0, 1) @@ -78,7 +78,7 @@ ZEND_END_ARG_INFO() #define arginfo_class_ArrayObject___debugInfo arginfo_class_ArrayObject_getArrayCopy ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ArrayIterator___construct, 0, 0, 0) - ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, array, "[]") + ZEND_ARG_TYPE_MASK(0, array, MAY_BE_ARRAY|MAY_BE_OBJECT, "[]") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "0") ZEND_END_ARG_INFO() diff --git a/ext/spl/spl_dllist.c b/ext/spl/spl_dllist.c index 1d91eceb6a..9d066ecf13 100644 --- a/ext/spl/spl_dllist.c +++ b/ext/spl/spl_dllist.c @@ -722,16 +722,14 @@ PHP_METHOD(SplDoublyLinkedList, getIteratorMode) /* {{{ Returns whether the requested $index exists. */ PHP_METHOD(SplDoublyLinkedList, offsetExists) { - zval *zindex; spl_dllist_object *intern; - zend_long index; + zend_long index; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &zindex) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &index) == FAILURE) { RETURN_THROWS(); } intern = Z_SPLDLLIST_P(ZEND_THIS); - index = spl_offset_convert_to_long(zindex); RETURN_BOOL(index >= 0 && index < intern->llist->count); } /* }}} */ @@ -739,58 +737,53 @@ PHP_METHOD(SplDoublyLinkedList, offsetExists) /* {{{ Returns the value at the specified $index. */ PHP_METHOD(SplDoublyLinkedList, offsetGet) { - zval *zindex; zend_long index; spl_dllist_object *intern; spl_ptr_llist_element *element; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &zindex) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &index) == FAILURE) { RETURN_THROWS(); } intern = Z_SPLDLLIST_P(ZEND_THIS); - index = spl_offset_convert_to_long(zindex); if (index < 0 || index >= intern->llist->count) { - zend_throw_exception(spl_ce_OutOfRangeException, "Offset invalid or out of range", 0); + zend_argument_error(spl_ce_OutOfRangeException, 1, "is out of range"); RETURN_THROWS(); } element = spl_ptr_llist_offset(intern->llist, index, intern->flags & SPL_DLLIST_IT_LIFO); - - if (element != NULL) { - zval *value = &element->data; - - ZVAL_COPY_DEREF(return_value, value); - } else { - zend_throw_exception(spl_ce_OutOfRangeException, "Offset invalid", 0); + if (element == NULL) { + zend_argument_error(spl_ce_OutOfRangeException, 1, "is an invalid offset"); + RETURN_THROWS(); } + + ZVAL_COPY_DEREF(return_value, &element->data); } /* }}} */ /* {{{ Sets the value at the specified $index to $newval. */ PHP_METHOD(SplDoublyLinkedList, offsetSet) { - zval *zindex, *value; - spl_dllist_object *intern; + zend_long index; + zend_bool index_is_null = 1; + zval *value; + spl_dllist_object *intern; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "zz", &zindex, &value) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l!z", &index, &index_is_null, &value) == FAILURE) { RETURN_THROWS(); } intern = Z_SPLDLLIST_P(ZEND_THIS); - if (Z_TYPE_P(zindex) == IS_NULL) { + if (index_is_null) { /* $obj[] = ... */ spl_ptr_llist_push(intern->llist, value); } else { /* $obj[$foo] = ... */ - zend_long index; spl_ptr_llist_element *element; - index = spl_offset_convert_to_long(zindex); - if (index < 0 || index >= intern->llist->count) { - zend_throw_exception(spl_ce_OutOfRangeException, "Offset invalid or out of range", 0); + zend_argument_error(spl_ce_OutOfRangeException, 1, "is out of range"); RETURN_THROWS(); } @@ -813,7 +806,7 @@ PHP_METHOD(SplDoublyLinkedList, offsetSet) } } else { zval_ptr_dtor(value); - zend_throw_exception(spl_ce_OutOfRangeException, "Offset invalid", 0); + zend_argument_error(spl_ce_OutOfRangeException, 1, "is an invalid offset"); RETURN_THROWS(); } } @@ -822,22 +815,20 @@ PHP_METHOD(SplDoublyLinkedList, offsetSet) /* {{{ Unsets the value at the specified $index. */ PHP_METHOD(SplDoublyLinkedList, offsetUnset) { - zval *zindex; zend_long index; spl_dllist_object *intern; spl_ptr_llist_element *element; spl_ptr_llist *llist; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &zindex) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &index) == FAILURE) { RETURN_THROWS(); } intern = Z_SPLDLLIST_P(ZEND_THIS); - index = spl_offset_convert_to_long(zindex); llist = intern->llist; if (index < 0 || index >= intern->llist->count) { - zend_throw_exception(spl_ce_OutOfRangeException, "Offset out of range", 0); + zend_argument_error(spl_ce_OutOfRangeException, 1, "is out of range"); RETURN_THROWS(); } @@ -878,7 +869,7 @@ PHP_METHOD(SplDoublyLinkedList, offsetUnset) SPL_LLIST_DELREF(element); } else { - zend_throw_exception(spl_ce_OutOfRangeException, "Offset invalid", 0); + zend_argument_error(spl_ce_OutOfRangeException, 1, "is an invalid offset"); RETURN_THROWS(); } } /* }}} */ @@ -1073,9 +1064,7 @@ PHP_METHOD(SplDoublyLinkedList, current) if (element == NULL || Z_ISUNDEF(element->data)) { RETURN_NULL(); } else { - zval *value = &element->data; - - ZVAL_COPY_DEREF(return_value, value); + ZVAL_COPY_DEREF(return_value, &element->data); } } /* }}} */ @@ -1243,20 +1232,19 @@ PHP_METHOD(SplDoublyLinkedList, __unserialize) { /* {{{ Inserts a new entry before the specified $index consisting of $newval. */ PHP_METHOD(SplDoublyLinkedList, add) { - zval *zindex, *value; + zval *value; spl_dllist_object *intern; spl_ptr_llist_element *element; zend_long index; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "zz", &zindex, &value) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "lz", &index, &value) == FAILURE) { RETURN_THROWS(); } intern = Z_SPLDLLIST_P(ZEND_THIS); - index = spl_offset_convert_to_long(zindex); if (index < 0 || index > intern->llist->count) { - zend_throw_exception(spl_ce_OutOfRangeException, "Offset invalid or out of range", 0); + zend_argument_error(spl_ce_OutOfRangeException, 1, "is out of range"); RETURN_THROWS(); } diff --git a/ext/spl/spl_dllist.stub.php b/ext/spl/spl_dllist.stub.php index 3cda7de01f..176aa15848 100755 --- a/ext/spl/spl_dllist.stub.php +++ b/ext/spl/spl_dllist.stub.php @@ -4,12 +4,8 @@ class SplDoublyLinkedList implements Iterator, Countable, ArrayAccess, Serializable { - /** - * @param mixed $index - * @param mixed $value - * @return void - */ - public function add($index, $value) {} + /** @return void */ + public function add(int $index, mixed $value) {} /** @return mixed */ public function pop() {} @@ -17,17 +13,11 @@ class SplDoublyLinkedList implements Iterator, Countable, ArrayAccess, Serializa /** @return mixed */ public function shift() {} - /** - * @param mixed $value - * @return void - */ - public function push($value) {} + /** @return void */ + public function push(mixed $value) {} - /** - * @param mixed $value - * @return void - */ - public function unshift($value) {} + /** @return void */ + public function unshift(mixed $value) {} /** @return mixed */ public function top() {} @@ -57,20 +47,19 @@ class SplDoublyLinkedList implements Iterator, Countable, ArrayAccess, Serializa public function offsetExists($index) {} /** - * @param mixed $index + * @param int $index * @return mixed */ public function offsetGet($index) {} /** - * @param mixed $index - * @param mixed $value + * @param int|null $index * @return void */ - public function offsetSet($index, $value) {} + public function offsetSet($index, mixed $value) {} /** - * @param mixed $index + * @param int $index * @return void */ public function offsetUnset($index) {} @@ -109,11 +98,10 @@ class SplDoublyLinkedList implements Iterator, Countable, ArrayAccess, Serializa class SplQueue extends SplDoublyLinkedList { /** - * @param mixed $value * @return void * @alias SplDoublyLinkedList::push */ - public function enqueue($value) {} + public function enqueue(mixed $value) {} /** * @return mixed diff --git a/ext/spl/spl_dllist_arginfo.h b/ext/spl/spl_dllist_arginfo.h index 70435e7e90..4ad6e4db55 100644 --- a/ext/spl/spl_dllist_arginfo.h +++ b/ext/spl/spl_dllist_arginfo.h @@ -1,9 +1,9 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 9d2c9ec251d72065d4502bbbc29e927c6b597731 */ + * Stub hash: 26a454261393ea3bdb6252b2d8140434664b5771 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplDoublyLinkedList_add, 0, 0, 2) - ZEND_ARG_INFO(0, index) - ZEND_ARG_INFO(0, value) + ZEND_ARG_TYPE_INFO(0, index, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplDoublyLinkedList_pop, 0, 0, 0) @@ -12,7 +12,7 @@ ZEND_END_ARG_INFO() #define arginfo_class_SplDoublyLinkedList_shift arginfo_class_SplDoublyLinkedList_pop ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplDoublyLinkedList_push, 0, 0, 1) - ZEND_ARG_INFO(0, value) + ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0) ZEND_END_ARG_INFO() #define arginfo_class_SplDoublyLinkedList_unshift arginfo_class_SplDoublyLinkedList_push @@ -39,7 +39,10 @@ ZEND_END_ARG_INFO() #define arginfo_class_SplDoublyLinkedList_offsetGet arginfo_class_SplDoublyLinkedList_offsetExists -#define arginfo_class_SplDoublyLinkedList_offsetSet arginfo_class_SplDoublyLinkedList_add +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplDoublyLinkedList_offsetSet, 0, 0, 2) + ZEND_ARG_INFO(0, index) + ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0) +ZEND_END_ARG_INFO() #define arginfo_class_SplDoublyLinkedList_offsetUnset arginfo_class_SplDoublyLinkedList_offsetExists diff --git a/ext/spl/spl_fixedarray.stub.php b/ext/spl/spl_fixedarray.stub.php index d571524db2..553de5c2fa 100755 --- a/ext/spl/spl_fixedarray.stub.php +++ b/ext/spl/spl_fixedarray.stub.php @@ -25,23 +25,22 @@ class SplFixedArray implements Iterator, ArrayAccess, Countable public function setSize(int $size) {} /** - * @param mixed $index + * @param int $index * @return bool */ public function offsetExists($index) {} /** - * @param mixed $index + * @param int $index * @return mixed */ public function offsetGet($index) {} /** - * @param mixed $index - * @param mixed $value + * @param int $index * @return void */ - public function offsetSet($index, $value) {} + public function offsetSet($index, mixed $value) {} /** * @param int $index diff --git a/ext/spl/spl_fixedarray_arginfo.h b/ext/spl/spl_fixedarray_arginfo.h index 056b8119df..899202683e 100644 --- a/ext/spl/spl_fixedarray_arginfo.h +++ b/ext/spl/spl_fixedarray_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: a14156d542422823fcee53eb8a151576d055f38f */ + * Stub hash: 4b6c37c54416ee46f610baba2a8b2be45d1db96f */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplFixedArray___construct, 0, 0, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, size, IS_LONG, 0, "0") @@ -31,7 +31,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplFixedArray_offsetSet, 0, 0, 2) ZEND_ARG_INFO(0, index) - ZEND_ARG_INFO(0, value) + ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0) ZEND_END_ARG_INFO() #define arginfo_class_SplFixedArray_offsetUnset arginfo_class_SplFixedArray_offsetExists diff --git a/ext/spl/spl_heap.stub.php b/ext/spl/spl_heap.stub.php index 5642d784e6..49f67af85d 100644 --- a/ext/spl/spl_heap.stub.php +++ b/ext/spl/spl_heap.stub.php @@ -4,19 +4,11 @@ class SplPriorityQueue implements Iterator, Countable { - /** - * @param mixed $priority1 - * @param mixed $priority2 - * @return int - */ - public function compare($priority1, $priority2) {} + /** @return int */ + public function compare(mixed $priority1, mixed $priority2) {} - /** - * @param mixed $value - * @param mixed $priority - * @return bool - */ - public function insert($value, $priority) {} + /** @return bool */ + public function insert(mixed $value, mixed $priority) {} /** @return int */ public function setExtractFlags(int $flags) {} @@ -90,11 +82,8 @@ abstract class SplHeap implements Iterator, Countable /** @return mixed */ public function extract() {} - /** - * @param mixed $value - * @return bool - */ - public function insert($value) {} + /** @return bool */ + public function insert(mixed $value) {} /** @return mixed */ public function top() {} @@ -123,12 +112,8 @@ abstract class SplHeap implements Iterator, Countable /** @return bool */ public function recoverFromCorruption() {} - /** - * @param mixed $value1 - * @param mixed $value2 - * @return int - */ - abstract protected function compare($value1, $value2); + /** @return int */ + abstract protected function compare(mixed $value1, mixed $value2); /** @return bool */ public function isCorrupted() {} @@ -139,20 +124,12 @@ abstract class SplHeap implements Iterator, Countable class SplMinHeap extends SplHeap { - /** - * @param mixed $value1 - * @param mixed $value2 - * @return int - */ - protected function compare($value1, $value2) {} + /** @return int */ + protected function compare(mixed $value1, mixed $value2) {} } class SplMaxHeap extends SplHeap { - /** - * @param mixed $value1 - * @param mixed $value2 - * @return int - */ - protected function compare($value1, $value2) {} + /** @return int */ + protected function compare(mixed $value1, mixed $value2) {} } diff --git a/ext/spl/spl_heap_arginfo.h b/ext/spl/spl_heap_arginfo.h index 0febb0fea7..f68961ffbb 100644 --- a/ext/spl/spl_heap_arginfo.h +++ b/ext/spl/spl_heap_arginfo.h @@ -1,14 +1,14 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 7f0aaeba31232e23367618eae98398fa41ac6ef5 */ + * Stub hash: e57b1d7e9139aa2759f548cf800857cccf1d1f25 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplPriorityQueue_compare, 0, 0, 2) - ZEND_ARG_INFO(0, priority1) - ZEND_ARG_INFO(0, priority2) + ZEND_ARG_TYPE_INFO(0, priority1, IS_MIXED, 0) + ZEND_ARG_TYPE_INFO(0, priority2, IS_MIXED, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplPriorityQueue_insert, 0, 0, 2) - ZEND_ARG_INFO(0, value) - ZEND_ARG_INFO(0, priority) + ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0) + ZEND_ARG_TYPE_INFO(0, priority, IS_MIXED, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplPriorityQueue_setExtractFlags, 0, 0, 1) @@ -45,7 +45,7 @@ ZEND_END_ARG_INFO() #define arginfo_class_SplHeap_extract arginfo_class_SplPriorityQueue_top ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplHeap_insert, 0, 0, 1) - ZEND_ARG_INFO(0, value) + ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0) ZEND_END_ARG_INFO() #define arginfo_class_SplHeap_top arginfo_class_SplPriorityQueue_top @@ -67,8 +67,8 @@ ZEND_END_ARG_INFO() #define arginfo_class_SplHeap_recoverFromCorruption arginfo_class_SplPriorityQueue_top ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplHeap_compare, 0, 0, 2) - ZEND_ARG_INFO(0, value1) - ZEND_ARG_INFO(0, value2) + ZEND_ARG_TYPE_INFO(0, value1, IS_MIXED, 0) + ZEND_ARG_TYPE_INFO(0, value2, IS_MIXED, 0) ZEND_END_ARG_INFO() #define arginfo_class_SplHeap_isCorrupted arginfo_class_SplPriorityQueue_top diff --git a/ext/spl/spl_iterators.stub.php b/ext/spl/spl_iterators.stub.php index fa97f45b62..cda9288668 100644 --- a/ext/spl/spl_iterators.stub.php +++ b/ext/spl/spl_iterators.stub.php @@ -53,7 +53,6 @@ interface RecursiveIterator extends Iterator class RecursiveIteratorIterator implements OuterIterator { - /** @param Traversable $iterator */ public function __construct(Traversable $iterator, int $mode = self::LEAVES_ONLY, int $flags = 0) {} /** @return void */ @@ -232,10 +231,9 @@ class CachingIterator extends IteratorIterator implements ArrayAccess, Countable /** * @param string $index - * @param mixed $value * @return void */ - public function offsetSet($index, $value) {} + public function offsetSet($index, mixed $value) {} /** * @param string $index diff --git a/ext/spl/spl_iterators_arginfo.h b/ext/spl/spl_iterators_arginfo.h index 66d4382cbe..58f414a16c 100644 --- a/ext/spl/spl_iterators_arginfo.h +++ b/ext/spl/spl_iterators_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: fcf9d56587eb60bdc7824ff7587a5c7365eee5c0 */ + * Stub hash: 3d98c82203230f2636c7fedb5717da5f7ab973f2 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_EmptyIterator_current, 0, 0, 0) ZEND_END_ARG_INFO() @@ -165,7 +165,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_CachingIterator_offsetSet, 0, 0, 2) ZEND_ARG_INFO(0, index) - ZEND_ARG_INFO(0, value) + ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0) ZEND_END_ARG_INFO() #define arginfo_class_CachingIterator_offsetUnset arginfo_class_CachingIterator_offsetGet diff --git a/ext/spl/spl_observer.stub.php b/ext/spl/spl_observer.stub.php index f3f4aab843..e399b13c98 100644 --- a/ext/spl/spl_observer.stub.php +++ b/ext/spl/spl_observer.stub.php @@ -22,11 +22,8 @@ interface SplSubject class SplObjectStorage implements Countable, Iterator, Serializable, ArrayAccess { - /** - * @param mixed $info - * @return void - */ - public function attach(object $object, $info = null) {} + /** @return void */ + public function attach(object $object, mixed $info = null) {} /** @return void */ public function detach(object $object) {} @@ -46,11 +43,8 @@ class SplObjectStorage implements Countable, Iterator, Serializable, ArrayAccess /** @return mixed */ public function getInfo() {} - /** - * @param mixed $info - * @return void - */ - public function setInfo($info) {} + /** @return void */ + public function setInfo(mixed $info) {} /** @return int */ public function count(int $mode = COUNT_NORMAL) {} @@ -91,11 +85,10 @@ class SplObjectStorage implements Countable, Iterator, Serializable, ArrayAccess /** * @param object $object - * @param mixed $info * @return void * @alias SplObjectStorage::attach */ - public function offsetSet($object, $info = null) {} + public function offsetSet($object, mixed $info = null) {} /** * @param object $object @@ -128,7 +121,6 @@ class MultipleIterator implements Iterator public function setFlags(int $flags) {} /** - * @param Iterator $iterator * @param int|string|null $info * @return void */ diff --git a/ext/spl/spl_observer_arginfo.h b/ext/spl/spl_observer_arginfo.h index 4d7b2b1dde..3c08a44268 100644 --- a/ext/spl/spl_observer_arginfo.h +++ b/ext/spl/spl_observer_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 4a31f2cc1b0c874f1256aef60afbd285dbe6c078 */ + * Stub hash: f795244462fc7b6aed3f38f6b2e1985b3a2ab7c1 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplObserver_update, 0, 0, 1) ZEND_ARG_OBJ_INFO(0, subject, SplSubject, 0) @@ -16,7 +16,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplObjectStorage_attach, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, object, IS_OBJECT, 0) - ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, info, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, info, IS_MIXED, 0, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplObjectStorage_detach, 0, 0, 1) @@ -36,7 +36,7 @@ ZEND_END_ARG_INFO() #define arginfo_class_SplObjectStorage_getInfo arginfo_class_SplSubject_notify ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplObjectStorage_setInfo, 0, 0, 1) - ZEND_ARG_INFO(0, info) + ZEND_ARG_TYPE_INFO(0, info, IS_MIXED, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplObjectStorage_count, 0, 0, 0) @@ -67,7 +67,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplObjectStorage_offsetSet, 0, 0, 1) ZEND_ARG_INFO(0, object) - ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, info, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, info, IS_MIXED, 0, "null") ZEND_END_ARG_INFO() #define arginfo_class_SplObjectStorage_offsetUnset arginfo_class_SplObjectStorage_offsetExists diff --git a/ext/spl/tests/SplDoublyLinkedList_add_invalid_offset.phpt b/ext/spl/tests/SplDoublyLinkedList_add_invalid_offset.phpt index 401d8ae1b3..347450fbe4 100644 --- a/ext/spl/tests/SplDoublyLinkedList_add_invalid_offset.phpt +++ b/ext/spl/tests/SplDoublyLinkedList_add_invalid_offset.phpt @@ -10,4 +10,4 @@ try { } ?> --EXPECT-- -Exception: Offset invalid or out of range +Exception: SplDoublyLinkedList::add(): Argument #1 ($index) is out of range diff --git a/ext/spl/tests/SplDoublyLinkedList_add_null_offset.phpt b/ext/spl/tests/SplDoublyLinkedList_add_null_offset.phpt index f8c58d9c70..1872436cea 100644 --- a/ext/spl/tests/SplDoublyLinkedList_add_null_offset.phpt +++ b/ext/spl/tests/SplDoublyLinkedList_add_null_offset.phpt @@ -4,10 +4,10 @@ Check that SplDoublyLinkedList::add throws an exception with an invalid offset a <?php try { $dll = new SplDoublyLinkedList(); - var_dump($dll->add(NULL,2)); -} catch (OutOfRangeException $e) { + var_dump($dll->add([],2)); +} catch (TypeError $e) { echo "Exception: ".$e->getMessage()."\n"; } ?> --EXPECT-- -Exception: Offset invalid or out of range +Exception: SplDoublyLinkedList::add(): Argument #1 ($index) must be of type int, array given diff --git a/ext/spl/tests/SplDoublyLinkedList_offsetGet_param_array.phpt b/ext/spl/tests/SplDoublyLinkedList_offsetGet_param_array.phpt index b6debb109b..eb88027f5e 100644 --- a/ext/spl/tests/SplDoublyLinkedList_offsetGet_param_array.phpt +++ b/ext/spl/tests/SplDoublyLinkedList_offsetGet_param_array.phpt @@ -11,7 +11,7 @@ $get = $array->offsetGet( array( 'fail' ) ); ?> --EXPECTF-- -Fatal error: Uncaught OutOfRangeException: Offset invalid or out of range in %s +Fatal error: Uncaught TypeError: SplDoublyLinkedList::offsetGet(): Argument #1 ($index) must be of type int, array given in %s Stack trace: #0 %s #1 {main} diff --git a/ext/spl/tests/SplDoublyLinkedList_offsetGet_param_string.phpt b/ext/spl/tests/SplDoublyLinkedList_offsetGet_param_string.phpt index 43ce18c5c5..421d12ddbb 100644 --- a/ext/spl/tests/SplDoublyLinkedList_offsetGet_param_string.phpt +++ b/ext/spl/tests/SplDoublyLinkedList_offsetGet_param_string.phpt @@ -11,7 +11,7 @@ $get = $array->offsetGet( 'fail' ); ?> --EXPECTF-- -Fatal error: Uncaught OutOfRangeException: Offset invalid or out of range in %s +Fatal error: Uncaught TypeError: SplDoublyLinkedList::offsetGet(): Argument #1 ($index) must be of type int, string given in %s Stack trace: #0 %s #1 {main} diff --git a/ext/spl/tests/SplDoublyLinkedList_offsetUnset_greater_than_elements.phpt b/ext/spl/tests/SplDoublyLinkedList_offsetUnset_greater_than_elements.phpt index 2512e23e78..4fa65b3a53 100644 --- a/ext/spl/tests/SplDoublyLinkedList_offsetUnset_greater_than_elements.phpt +++ b/ext/spl/tests/SplDoublyLinkedList_offsetUnset_greater_than_elements.phpt @@ -22,4 +22,4 @@ echo $e->getMessage(); ?> --EXPECT-- -Offset out of range +SplDoublyLinkedList::offsetUnset(): Argument #1 ($index) is out of range diff --git a/ext/spl/tests/SplDoublyLinkedList_offsetUnset_negative-parameter.phpt b/ext/spl/tests/SplDoublyLinkedList_offsetUnset_negative-parameter.phpt index 364eb5ca79..614ebdf01b 100644 --- a/ext/spl/tests/SplDoublyLinkedList_offsetUnset_negative-parameter.phpt +++ b/ext/spl/tests/SplDoublyLinkedList_offsetUnset_negative-parameter.phpt @@ -20,4 +20,4 @@ PHPNW Testfest 2009 - Paul Court ( g@rgoyle.com ) } ?> --EXPECT-- -Offset out of range +SplDoublyLinkedList::offsetUnset(): Argument #1 ($index) is out of range diff --git a/ext/spl/tests/SplDoublyLinkedList_offsetUnset_parameter-larger-num-elements.phpt b/ext/spl/tests/SplDoublyLinkedList_offsetUnset_parameter-larger-num-elements.phpt index 5ba7b27e56..6782bd9489 100644 --- a/ext/spl/tests/SplDoublyLinkedList_offsetUnset_parameter-larger-num-elements.phpt +++ b/ext/spl/tests/SplDoublyLinkedList_offsetUnset_parameter-larger-num-elements.phpt @@ -20,4 +20,4 @@ PHPNW Testfest 2009 - Paul Court ( g@rgoyle.com ) } ?> --EXPECT-- -Offset out of range +SplDoublyLinkedList::offsetUnset(): Argument #1 ($index) is out of range diff --git a/ext/spl/tests/arrayObject_exchangeArray_basic3.phpt b/ext/spl/tests/arrayObject_exchangeArray_basic3.phpt index d05a635500..8eea9c96fd 100644 --- a/ext/spl/tests/arrayObject_exchangeArray_basic3.phpt +++ b/ext/spl/tests/arrayObject_exchangeArray_basic3.phpt @@ -42,8 +42,8 @@ $ao = new ArrayObject($original); try { $copy = $ao->exchangeArray(null); $copy['addedToCopy'] = 'added To Copy'; -} catch (Exception $e) { - echo "Exception:" . $e->getMessage() . "\n"; +} catch (TypeError $e) { + echo $e->getMessage() . "\n"; } $original->addedToOriginal = 'added To Original'; var_dump($ao, $original, $copy); @@ -103,7 +103,7 @@ NULL --> exchangeArray() with bad arg type: -Exception:Passed variable is not an array or object +ArrayObject::exchangeArray(): Argument #1 ($input) must be of type array, null given Warning: Undefined variable $copy in %s on line %d object(ArrayObject)#3 (1) { diff --git a/ext/spl/tests/bug71412.phpt b/ext/spl/tests/bug71412.phpt index 8829aa64fe..e6623dd2fc 100644 --- a/ext/spl/tests/bug71412.phpt +++ b/ext/spl/tests/bug71412.phpt @@ -8,7 +8,7 @@ echo (new ReflectionMethod('ArrayIterator', '__construct')); Method [ <internal:SPL, ctor> public method __construct ] { - Parameters [2] { - Parameter #0 [ <optional> $array = [] ] + Parameter #0 [ <optional> object|array $array = [] ] Parameter #1 [ <optional> int $flags = 0 ] } } diff --git a/ext/spl/tests/bug71735.phpt b/ext/spl/tests/bug71735.phpt index fd89cade78..7063aaab5a 100644 --- a/ext/spl/tests/bug71735.phpt +++ b/ext/spl/tests/bug71735.phpt @@ -10,4 +10,4 @@ $var_1->offsetSet(100,new DateTime('2000-01-01')); } ?> --EXPECT-- -Offset invalid or out of range +SplDoublyLinkedList::offsetSet(): Argument #1 ($index) is out of range diff --git a/ext/spl/tests/dllist_006.phpt b/ext/spl/tests/dllist_006.phpt index 88190573e4..25b8bf3308 100644 --- a/ext/spl/tests/dllist_006.phpt +++ b/ext/spl/tests/dllist_006.phpt @@ -29,7 +29,7 @@ try { try { var_dump($a["a"]); -} catch (OutOfRangeException $e) { +} catch (TypeError $e) { echo "Exception: ".$e->getMessage()."\n"; } @@ -54,6 +54,6 @@ Unsetting.. int(3) int(4) int(2) -Exception: Offset invalid or out of range +Exception: SplDoublyLinkedList::offsetGet(): Argument #1 ($index) must be of type int, string given int(1) -Exception: Offset invalid or out of range +Exception: SplDoublyLinkedList::offsetGet(): Argument #1 ($index) is out of range diff --git a/ext/spl/tests/dllist_013.phpt b/ext/spl/tests/dllist_013.phpt index 49b89d39a8..8bcc5e5884 100644 --- a/ext/spl/tests/dllist_013.phpt +++ b/ext/spl/tests/dllist_013.phpt @@ -31,7 +31,7 @@ echo $dll->pop()."\n"; echo $dll->pop()."\n"; ?> --EXPECT-- -Exception: Offset invalid or out of range +Exception: SplDoublyLinkedList::add(): Argument #1 ($index) is out of range 7 7 6 diff --git a/ext/spl/tests/spl_iterator_getcallchildren.phpt b/ext/spl/tests/spl_iterator_getcallchildren.phpt index e14acd12da..8a0d1cd735 100644 --- a/ext/spl/tests/spl_iterator_getcallchildren.phpt +++ b/ext/spl/tests/spl_iterator_getcallchildren.phpt @@ -15,16 +15,16 @@ $test->next(); var_dump($test->current()); try { $output = $test->callGetChildren(); -} catch (InvalidArgumentException $ilae){ +} catch (TypeError $exception) { $output = null; - print "invalid argument exception\n"; + echo $exception->getMessage() . "\n"; } var_dump($output); ?> --EXPECT-- - array(3) { +array(3) { [0]=> int(7) [1]=> @@ -33,5 +33,5 @@ var_dump($output); int(9) } int(7) -invalid argument exception +ArrayIterator::__construct(): Argument #1 ($array) must be of type array, int given NULL diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c index 92c88ceaf1..0adb122ff5 100644 --- a/ext/tidy/tidy.c +++ b/ext/tidy/tidy.c @@ -67,23 +67,20 @@ } \ obj = Z_TIDY_P(object); \ -#define TIDY_APPLY_CONFIG_ZVAL(_doc, _val) \ - if(_val) { \ - if(Z_TYPE_P(_val) == IS_ARRAY) { \ - _php_tidy_apply_config_array(_doc, Z_ARRVAL_P(_val)); \ - } else { \ - convert_to_string_ex(_val); \ - TIDY_OPEN_BASE_DIR_CHECK(Z_STRVAL_P(_val)); \ - switch (tidyLoadConfig(_doc, Z_STRVAL_P(_val))) { \ - case -1: \ - php_error_docref(NULL, E_WARNING, "Could not load configuration file \"%s\"", Z_STRVAL_P(_val)); \ - break; \ - case 1: \ - php_error_docref(NULL, E_NOTICE, "There were errors while parsing the configuration file \"%s\"", Z_STRVAL_P(_val)); \ - break; \ - } \ - } \ - } +#define TIDY_APPLY_CONFIG(_doc, _val_str, _val_ht) \ + if (_val_ht) { \ + _php_tidy_apply_config_array(_doc, _val_ht); \ + } else if (_val_str) { \ + TIDY_OPEN_BASE_DIR_CHECK(ZSTR_VAL(_val_str)); \ + switch (tidyLoadConfig(_doc, ZSTR_VAL(_val_str))) { \ + case -1: \ + php_error_docref(NULL, E_WARNING, "Could not load configuration file \"%s\"", ZSTR_VAL(_val_str)); \ + break; \ + case 1: \ + php_error_docref(NULL, E_NOTICE, "There were errors while parsing the configuration file \"%s\"", ZSTR_VAL(_val_str)); \ + break; \ + } \ + } #define REGISTER_TIDY_CLASS(classname, name, parent, __flags) \ { \ @@ -336,22 +333,31 @@ static void php_tidy_quick_repair(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_fil size_t enc_len = 0; TidyDoc doc; TidyBuffer *errbuf; - zend_string *data, *arg1; - zval *config = NULL; + zend_string *data, *arg1, *config_str = NULL; + HashTable *config_ht = NULL; if (is_file) { zend_bool use_include_path = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "P|zsb", &arg1, &config, &enc, &enc_len, &use_include_path) == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_START(1, 4) + Z_PARAM_PATH_STR(arg1) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_ARRAY_HT_OR_NULL(config_str, config_ht) + Z_PARAM_STRING(enc, enc_len) + Z_PARAM_BOOL(use_include_path) + ZEND_PARSE_PARAMETERS_END(); + if (!(data = php_tidy_file_to_mem(ZSTR_VAL(arg1), use_include_path))) { RETURN_FALSE; } } else { - if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|zs", &arg1, &config, &enc, &enc_len) == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(arg1) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_ARRAY_HT_OR_NULL(config_str, config_ht) + Z_PARAM_STRING(enc, enc_len) + ZEND_PARSE_PARAMETERS_END(); + data = arg1; } @@ -376,9 +382,7 @@ static void php_tidy_quick_repair(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_fil TIDY_SET_DEFAULT_CONFIG(doc); - if (config) { - TIDY_APPLY_CONFIG_ZVAL(doc, config); - } + TIDY_APPLY_CONFIG(doc, config_str, config_ht); if(enc_len) { if (tidySetCharEncoding(doc, enc) < 0) { @@ -986,13 +990,16 @@ PHP_FUNCTION(tidy_parse_string) { char *enc = NULL; size_t enc_len = 0; - zend_string *input; - zval *options = NULL; + zend_string *input, *options_str = NULL; + HashTable *options_ht = NULL; PHPTidyObj *obj; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|zs", &input, &options, &enc, &enc_len) == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(input) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_ARRAY_HT_OR_NULL(options_str, options_ht) + Z_PARAM_STRING(enc, enc_len) + ZEND_PARSE_PARAMETERS_END(); if (ZEND_SIZE_T_UINT_OVFL(ZSTR_LEN(input))) { zend_argument_value_error(1, "is too long"); @@ -1002,7 +1009,7 @@ PHP_FUNCTION(tidy_parse_string) tidy_instanciate(tidy_ce_doc, return_value); obj = Z_TIDY_P(return_value); - TIDY_APPLY_CONFIG_ZVAL(obj->ptdoc->doc, options); + TIDY_APPLY_CONFIG(obj->ptdoc->doc, options_str, options_ht); if (php_tidy_parse_string(obj, ZSTR_VAL(input), (uint32_t)ZSTR_LEN(input), enc) == FAILURE) { zval_ptr_dtor(return_value); @@ -1044,15 +1051,18 @@ PHP_FUNCTION(tidy_parse_file) char *enc = NULL; size_t enc_len = 0; zend_bool use_include_path = 0; - zend_string *inputfile, *contents; - zval *options = NULL; + zend_string *inputfile, *contents, *options_str = NULL; + HashTable *options_ht = NULL; PHPTidyObj *obj; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "P|zsb", &inputfile, - &options, &enc, &enc_len, &use_include_path) == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_START(1, 4) + Z_PARAM_PATH_STR(inputfile) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_ARRAY_HT_OR_NULL(options_str, options_ht) + Z_PARAM_STRING(enc, enc_len) + Z_PARAM_BOOL(use_include_path) + ZEND_PARSE_PARAMETERS_END(); tidy_instanciate(tidy_ce_doc, return_value); obj = Z_TIDY_P(return_value); @@ -1067,7 +1077,7 @@ PHP_FUNCTION(tidy_parse_file) RETURN_THROWS(); } - TIDY_APPLY_CONFIG_ZVAL(obj->ptdoc->doc, options); + TIDY_APPLY_CONFIG(obj->ptdoc->doc, options_str, options_ht); if (php_tidy_parse_string(obj, ZSTR_VAL(contents), (uint32_t)ZSTR_LEN(contents), enc) == FAILURE) { zval_ptr_dtor(return_value); @@ -1335,17 +1345,19 @@ PHP_METHOD(tidy, __construct) char *enc = NULL; size_t enc_len = 0; zend_bool use_include_path = 0; - zval *options = NULL; - zend_string *contents, *inputfile = NULL; - + HashTable *options_ht = NULL; + zend_string *contents, *inputfile = NULL, *options_str = NULL; PHPTidyObj *obj; - TIDY_SET_CONTEXT; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|Pzsb", &inputfile, - &options, &enc, &enc_len, &use_include_path) == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_START(0, 4) + Z_PARAM_OPTIONAL + Z_PARAM_PATH_STR_OR_NULL(inputfile) + Z_PARAM_STR_OR_ARRAY_HT_OR_NULL(options_str, options_ht) + Z_PARAM_STRING(enc, enc_len) + Z_PARAM_BOOL(use_include_path) + ZEND_PARSE_PARAMETERS_END(); + TIDY_SET_CONTEXT; obj = Z_TIDY_P(object); if (inputfile) { @@ -1359,7 +1371,7 @@ PHP_METHOD(tidy, __construct) RETURN_THROWS(); } - TIDY_APPLY_CONFIG_ZVAL(obj->ptdoc->doc, options); + TIDY_APPLY_CONFIG(obj->ptdoc->doc, options_str, options_ht); php_tidy_parse_string(obj, ZSTR_VAL(contents), (uint32_t)ZSTR_LEN(contents), enc); @@ -1372,19 +1384,21 @@ PHP_METHOD(tidy, parseFile) char *enc = NULL; size_t enc_len = 0; zend_bool use_include_path = 0; - zval *options = NULL; - zend_string *inputfile, *contents; + HashTable *options_ht = NULL; + zend_string *inputfile, *contents, *options_str = NULL; PHPTidyObj *obj; - TIDY_SET_CONTEXT; + ZEND_PARSE_PARAMETERS_START(1, 4) + Z_PARAM_PATH_STR(inputfile) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_ARRAY_HT_OR_NULL(options_str, options_ht) + Z_PARAM_STRING(enc, enc_len) + Z_PARAM_BOOL(use_include_path) + ZEND_PARSE_PARAMETERS_END(); + TIDY_SET_CONTEXT; obj = Z_TIDY_P(object); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "P|zsb", &inputfile, - &options, &enc, &enc_len, &use_include_path) == FAILURE) { - RETURN_THROWS(); - } - if (!(contents = php_tidy_file_to_mem(ZSTR_VAL(inputfile), use_include_path))) { php_error_docref(NULL, E_WARNING, "Cannot load \"%s\" into memory%s", ZSTR_VAL(inputfile), (use_include_path) ? " (using include path)" : ""); RETURN_FALSE; @@ -1395,7 +1409,7 @@ PHP_METHOD(tidy, parseFile) RETURN_THROWS(); } - TIDY_APPLY_CONFIG_ZVAL(obj->ptdoc->doc, options); + TIDY_APPLY_CONFIG(obj->ptdoc->doc, options_str, options_ht); if (php_tidy_parse_string(obj, ZSTR_VAL(contents), (uint32_t)ZSTR_LEN(contents), enc) == FAILURE) { RETVAL_FALSE; @@ -1410,24 +1424,26 @@ PHP_METHOD(tidy, parseString) { char *enc = NULL; size_t enc_len = 0; - zval *options = NULL; + HashTable *options_ht = NULL; PHPTidyObj *obj; - zend_string *input; - - TIDY_SET_CONTEXT; + zend_string *input, *options_str = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|zs", &input, &options, &enc, &enc_len) == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(input) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_ARRAY_HT_OR_NULL(options_str, options_ht) + Z_PARAM_STRING(enc, enc_len) + ZEND_PARSE_PARAMETERS_END(); if (ZEND_SIZE_T_UINT_OVFL(ZSTR_LEN(input))) { zend_argument_value_error(1, "is too long"); RETURN_THROWS(); } + TIDY_SET_CONTEXT; obj = Z_TIDY_P(object); - TIDY_APPLY_CONFIG_ZVAL(obj->ptdoc->doc, options); + TIDY_APPLY_CONFIG(obj->ptdoc->doc, options_str, options_ht); if(php_tidy_parse_string(obj, ZSTR_VAL(input), (uint32_t)ZSTR_LEN(input), enc) == SUCCESS) { RETURN_TRUE; diff --git a/ext/tidy/tidy.stub.php b/ext/tidy/tidy.stub.php index fbb11adb93..76f4525132 100644 --- a/ext/tidy/tidy.stub.php +++ b/ext/tidy/tidy.stub.php @@ -2,23 +2,19 @@ /** @generate-function-entries */ -/** @param array|string $config_options */ -function tidy_parse_string(string $input, $config_options = UNKNOWN, string $encoding = UNKNOWN): tidy|false {} +function tidy_parse_string(string $input, array|string|null $config_options = null, string $encoding = UNKNOWN): tidy|false {} function tidy_get_error_buffer(tidy $object): string|false {} function tidy_get_output(tidy $object): string {} -/** @param array|string $config_options */ -function tidy_parse_file(string $file, $config_options = UNKNOWN, string $encoding = UNKNOWN, bool $use_include_path = false): tidy|false {} +function tidy_parse_file(string $file, array|string|null $config_options = null, string $encoding = UNKNOWN, bool $use_include_path = false): tidy|false {} function tidy_clean_repair(tidy $object): bool {} -/** @param array|string $config_options */ -function tidy_repair_string(string $data, $config_options = UNKNOWN, string $encoding = UNKNOWN): string|false {} +function tidy_repair_string(string $data, array|string|null $config_options = null, string $encoding = UNKNOWN): string|false {} -/** @param array|string $config_options */ -function tidy_repair_file(string $filename, $config_options = UNKNOWN, string $encoding = UNKNOWN, bool $use_include_path = false): string|false {} +function tidy_repair_file(string $filename, array|string|null $config_options = null, string $encoding = UNKNOWN, bool $use_include_path = false): string|false {} function tidy_diagnose(tidy $object): bool {} @@ -58,8 +54,7 @@ function tidy_get_body(tidy $tidy): ?tidyNode {} class tidy { - /** @param array|string $config_options */ - public function __construct(string $filename = UNKNOWN, $config_options = UNKNOWN, string $encoding = UNKNOWN, bool $use_include_path = false) {} + public function __construct(?string $filename = null, array|string|null $config_options = null, string $encoding = UNKNOWN, bool $use_include_path = false) {} /** * @return string|int|bool @@ -73,31 +68,23 @@ class tidy */ public function cleanRepair() {} - /** - * @param array|string $config_options - * @return bool - */ - public function parseFile(string $file, $config_options = UNKNOWN, string $encoding = UNKNOWN, bool $use_include_path = false) {} + /** @return bool */ + public function parseFile(string $file, array|string|null $config_options = null, string $encoding = UNKNOWN, bool $use_include_path = false) {} - /** - * @param array|string $config_options - * @return bool - */ - public function parseString(string $input, $config_options = UNKNOWN, string $encoding = UNKNOWN) {} + /** @return bool */ + public function parseString(string $input, array|string|null $config_options = null, string $encoding = UNKNOWN) {} /** - * @param array|string $config_options * @return bool * @alias tidy_repair_string */ - public function repairString(string $data, $config_options = UNKNOWN, string $encoding = UNKNOWN) {} + public function repairString(string $data, array|string|null $config_options = null, string $encoding = UNKNOWN) {} /** - * @param array|string $config_options * @return bool * @alias tidy_repair_file */ - public function repairFile(string $filename, $config_options = UNKNOWN, string $encoding = UNKNOWN, bool $use_include_path = false) {} + public function repairFile(string $filename, array|string|null $config_options = null, string $encoding = UNKNOWN, bool $use_include_path = false) {} /** * @return bool diff --git a/ext/tidy/tidy_arginfo.h b/ext/tidy/tidy_arginfo.h index aa845fdedb..30ca646812 100644 --- a/ext/tidy/tidy_arginfo.h +++ b/ext/tidy/tidy_arginfo.h @@ -1,9 +1,9 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 962dc7537b44115477b38efaefefa352e06b13bf */ + * Stub hash: cc7cee7934007aa4b195fb1be0626496937e9d38 */ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_tidy_parse_string, 0, 1, tidy, MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, input, IS_STRING, 0) - ZEND_ARG_INFO(0, config_options) + ZEND_ARG_TYPE_MASK(0, config_options, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, "null") ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) ZEND_END_ARG_INFO() @@ -17,7 +17,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_tidy_parse_file, 0, 1, tidy, MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, file, IS_STRING, 0) - ZEND_ARG_INFO(0, config_options) + ZEND_ARG_TYPE_MASK(0, config_options, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, "null") ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, use_include_path, _IS_BOOL, 0, "false") ZEND_END_ARG_INFO() @@ -28,13 +28,13 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_tidy_repair_string, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) - ZEND_ARG_INFO(0, config_options) + ZEND_ARG_TYPE_MASK(0, config_options, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, "null") ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_tidy_repair_file, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) - ZEND_ARG_INFO(0, config_options) + ZEND_ARG_TYPE_MASK(0, config_options, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, "null") ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, use_include_path, _IS_BOOL, 0, "false") ZEND_END_ARG_INFO() @@ -91,8 +91,8 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_tidy_get_body, 0, 1, tidyNode, 1) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_tidy___construct, 0, 0, 0) - ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) - ZEND_ARG_INFO(0, config_options) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, filename, IS_STRING, 1, "null") + ZEND_ARG_TYPE_MASK(0, config_options, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, "null") ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, use_include_path, _IS_BOOL, 0, "false") ZEND_END_ARG_INFO() @@ -106,26 +106,26 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_tidy_parseFile, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, file, IS_STRING, 0) - ZEND_ARG_INFO(0, config_options) + ZEND_ARG_TYPE_MASK(0, config_options, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, "null") ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, use_include_path, _IS_BOOL, 0, "false") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_tidy_parseString, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, input, IS_STRING, 0) - ZEND_ARG_INFO(0, config_options) + ZEND_ARG_TYPE_MASK(0, config_options, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, "null") ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_tidy_repairString, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) - ZEND_ARG_INFO(0, config_options) + ZEND_ARG_TYPE_MASK(0, config_options, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, "null") ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_tidy_repairFile, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) - ZEND_ARG_INFO(0, config_options) + ZEND_ARG_TYPE_MASK(0, config_options, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, "null") ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, use_include_path, _IS_BOOL, 0, "false") ZEND_END_ARG_INFO() |