diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 88a7af1c241ca..dfbf461a5687a 100755 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -487,6 +487,7 @@ static const zend_function_entry basic_functions[] = { /* {{{ */ PHP_FE(strval, arginfo_strval) PHP_FE(boolval, arginfo_boolval) PHP_FE(gettype, arginfo_gettype) + PHP_FE(get_debug_type, arginfo_get_debug_type) PHP_FE(settype, arginfo_settype) PHP_FE(is_null, arginfo_is_null) PHP_FE(is_resource, arginfo_is_resource) diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php index c153b752e6293..8e0b671142ade 100755 --- a/ext/standard/basic_functions.stub.php +++ b/ext/standard/basic_functions.stub.php @@ -1366,6 +1366,9 @@ function socket_set_timeout($socket, int $seconds, int $microseconds = 0): bool /** @param mixed $var */ function gettype($var): string {} +/** @param mixed $var */ +function get_debug_type($var): string {} + function settype(&$var, string $type): bool {} /** @param mixed $value */ diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h index fa5e762c2e627..3a7c02b7cd260 100755 --- a/ext/standard/basic_functions_arginfo.h +++ b/ext/standard/basic_functions_arginfo.h @@ -2061,6 +2061,8 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gettype, 0, 1, IS_STRING, 0) ZEND_ARG_INFO(0, var) ZEND_END_ARG_INFO() +#define arginfo_get_debug_type arginfo_gettype + ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_settype, 0, 2, _IS_BOOL, 0) ZEND_ARG_INFO(1, var) ZEND_ARG_TYPE_INFO(0, type, IS_STRING, 0) diff --git a/ext/standard/php_type.h b/ext/standard/php_type.h index be056201dbfb9..b0d543ed9723e 100644 --- a/ext/standard/php_type.h +++ b/ext/standard/php_type.h @@ -22,6 +22,7 @@ PHP_FUNCTION(floatval); PHP_FUNCTION(strval); PHP_FUNCTION(boolval); PHP_FUNCTION(gettype); +PHP_FUNCTION(get_debug_type); PHP_FUNCTION(settype); PHP_FUNCTION(is_null); PHP_FUNCTION(is_resource); diff --git a/ext/standard/tests/general_functions/get_debug_type_basic.phpt b/ext/standard/tests/general_functions/get_debug_type_basic.phpt new file mode 100644 index 0000000000000..35fc8085175c8 --- /dev/null +++ b/ext/standard/tests/general_functions/get_debug_type_basic.phpt @@ -0,0 +1,57 @@ +--TEST-- +Test get_debug_type() class reading +--FILE-- +ce->ce_flags & ZEND_ACC_ANON_CLASS) { + name = ZSTR_VAL(Z_OBJ_P(arg)->ce->name); + RETURN_NEW_STR(zend_string_init(name, strlen(name), 0)); + } else { + RETURN_STR_COPY(Z_OBJ_P(arg)->ce->name); + } + case IS_RESOURCE: + name = zend_rsrc_list_get_rsrc_type(Z_RES_P(arg)); + if (name) { + RETURN_NEW_STR(zend_strpprintf(0, "resource (%s)", name)); + } else { + RETURN_INTERNED_STR(ZSTR_KNOWN(ZEND_STR_CLOSED_RESOURCE)); + } + default: + RETURN_INTERNED_STR(ZSTR_KNOWN(ZEND_STR_UNKNOWN)); + } +} +/* }}} */ + + /* {{{ proto bool settype(mixed &var, string type) Set the type of the variable */ PHP_FUNCTION(settype)