diff --git a/Zend/tests/get_resource_id.phpt b/Zend/tests/get_resource_id.phpt new file mode 100644 index 000000000000..70b3995d46c3 --- /dev/null +++ b/Zend/tests/get_resource_id.phpt @@ -0,0 +1,18 @@ +--TEST-- +get_resource_id() function +--FILE-- + +--EXPECT-- +bool(true) +bool(true) diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 5682d02822f9..319b6de1b817 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -1505,6 +1505,20 @@ ZEND_FUNCTION(get_resource_type) } /* }}} */ +/* {{{ proto int get_resource_id(resource res) + Get the resource ID for a given resource */ +ZEND_FUNCTION(get_resource_id) +{ + zval *resource; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_RESOURCE(resource) + ZEND_PARSE_PARAMETERS_END(); + + RETURN_LONG(Z_RES_HANDLE_P(resource)); +} +/* }}} */ + /* {{{ proto array get_resources([string resouce_type]) Get an array with all active resources */ ZEND_FUNCTION(get_resources) diff --git a/Zend/zend_builtin_functions.stub.php b/Zend/zend_builtin_functions.stub.php index ec3d5a5203d8..c09ad1740ec0 100644 --- a/Zend/zend_builtin_functions.stub.php +++ b/Zend/zend_builtin_functions.stub.php @@ -91,6 +91,8 @@ function get_defined_vars(): array {} function get_resource_type($res): string {} +function get_resource_id($res): int {} + function get_resources(string $type = UNKNOWN): array {} function get_loaded_extensions(bool $zend_extensions = false): array {} diff --git a/Zend/zend_builtin_functions_arginfo.h b/Zend/zend_builtin_functions_arginfo.h index ab4510f3d8ee..d00ecd549ded 100644 --- a/Zend/zend_builtin_functions_arginfo.h +++ b/Zend/zend_builtin_functions_arginfo.h @@ -155,6 +155,10 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_get_resource_type, 0, 1, IS_STRI ZEND_ARG_INFO(0, res) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_get_resource_id, 0, 1, IS_LONG, 0) + ZEND_ARG_INFO(0, res) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_get_resources, 0, 0, IS_ARRAY, 0) ZEND_ARG_TYPE_INFO(0, type, IS_STRING, 0) ZEND_END_ARG_INFO() @@ -244,6 +248,7 @@ ZEND_FUNCTION(get_declared_interfaces); ZEND_FUNCTION(get_defined_functions); ZEND_FUNCTION(get_defined_vars); ZEND_FUNCTION(get_resource_type); +ZEND_FUNCTION(get_resource_id); ZEND_FUNCTION(get_resources); ZEND_FUNCTION(get_loaded_extensions); ZEND_FUNCTION(get_defined_constants); @@ -305,6 +310,7 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(get_defined_functions, arginfo_get_defined_functions) ZEND_FE(get_defined_vars, arginfo_get_defined_vars) ZEND_FE(get_resource_type, arginfo_get_resource_type) + ZEND_FE(get_resource_id, arginfo_get_resource_id) ZEND_FE(get_resources, arginfo_get_resources) ZEND_FE(get_loaded_extensions, arginfo_get_loaded_extensions) ZEND_FE(get_defined_constants, arginfo_get_defined_constants)