]> granicus.if.org Git - php/commitdiff
Rename zend_zval_get_type() API
authorNikita Popov <nikita.ppv@gmail.com>
Wed, 13 May 2020 12:46:15 +0000 (14:46 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 13 May 2020 12:56:05 +0000 (14:56 +0200)
We have a bunch of APIs for getting type names and it's sometimes
hard to keep them apart ... make it clear that this is the one
you definitely do not want to use.

Zend/zend_API.c
Zend/zend_API.h
Zend/zend_vm_def.h
Zend/zend_vm_execute.h
ext/standard/type.c

index 3670557d0d29695c5584bda674f6db16ab5c12af..fe6c68e5e5889f0dc9cb0c43cfdb16b2397840f2 100644 (file)
@@ -138,7 +138,9 @@ ZEND_API const char *zend_zval_type_name(const zval *arg) /* {{{ */
 }
 /* }}} */
 
-ZEND_API zend_string *zend_zval_get_type(const zval *arg) /* {{{ */
+/* This API exists *only* for use in gettype().
+ * For anything else, you likely want zend_zval_type_name(). */
+ZEND_API zend_string *zend_zval_get_legacy_type(const zval *arg) /* {{{ */
 {
        switch (Z_TYPE_P(arg)) {
                case IS_NULL:
index 366f85c81f08f38e702b99f5c7265fcd3dfeb498..c3554568923152b26b95c1e3b31cf670d37af7e2 100644 (file)
@@ -301,7 +301,7 @@ ZEND_API int zend_parse_parameters_ex(int flags, int num_args, const char *type_
 #define zend_parse_parameters_throw(num_args, ...) \
        zend_parse_parameters(num_args, __VA_ARGS__)
 ZEND_API const char *zend_zval_type_name(const zval *arg);
-ZEND_API zend_string *zend_zval_get_type(const zval *arg);
+ZEND_API zend_string *zend_zval_get_legacy_type(const zval *arg);
 
 ZEND_API int zend_parse_method_parameters(int num_args, zval *this_ptr, const char *type_spec, ...);
 ZEND_API int zend_parse_method_parameters_ex(int flags, int num_args, zval *this_ptr, const char *type_spec, ...);
index 1395d48605e4b3108ae46dd5cdee7c013286af0f..5be0f1156de3b4af5fe29e127135e2a1517d833d 100644 (file)
@@ -8562,7 +8562,7 @@ ZEND_VM_COLD_CONST_HANDLER(193, ZEND_GET_TYPE, CONST|TMP|VAR|CV, UNUSED)
 
        SAVE_OPLINE();
        op1 = GET_OP1_ZVAL_PTR_DEREF(BP_VAR_R);
-       type = zend_zval_get_type(op1);
+       type = zend_zval_get_legacy_type(op1);
        if (EXPECTED(type)) {
                ZVAL_INTERNED_STR(EX_VAR(opline->result.var), type);
        } else {
index 6bf3ff510172c5c32b928825997e4fd309d7e29e..4b54565719b9efbdb91bf1e250797e534580a658 100644 (file)
@@ -9360,7 +9360,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_GET_TYPE_SPEC_CON
 
        SAVE_OPLINE();
        op1 = RT_CONSTANT(opline, opline->op1);
-       type = zend_zval_get_type(op1);
+       type = zend_zval_get_legacy_type(op1);
        if (EXPECTED(type)) {
                ZVAL_INTERNED_STR(EX_VAR(opline->result.var), type);
        } else {
@@ -19087,7 +19087,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_GET_TYPE_SPEC_TMP_UNUSED_HANDL
 
        SAVE_OPLINE();
        op1 = _get_zval_ptr_tmp(opline->op1.var EXECUTE_DATA_CC);
-       type = zend_zval_get_type(op1);
+       type = zend_zval_get_legacy_type(op1);
        if (EXPECTED(type)) {
                ZVAL_INTERNED_STR(EX_VAR(opline->result.var), type);
        } else {
@@ -26693,7 +26693,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_GET_TYPE_SPEC_VAR_UNUSED_HANDL
 
        SAVE_OPLINE();
        op1 = _get_zval_ptr_var_deref(opline->op1.var EXECUTE_DATA_CC);
-       type = zend_zval_get_type(op1);
+       type = zend_zval_get_legacy_type(op1);
        if (EXPECTED(type)) {
                ZVAL_INTERNED_STR(EX_VAR(opline->result.var), type);
        } else {
@@ -45286,7 +45286,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_GET_TYPE_SPEC_CV_UNUSED_HANDLE
 
        SAVE_OPLINE();
        op1 = _get_zval_ptr_cv_deref_BP_VAR_R(opline->op1.var EXECUTE_DATA_CC);
-       type = zend_zval_get_type(op1);
+       type = zend_zval_get_legacy_type(op1);
        if (EXPECTED(type)) {
                ZVAL_INTERNED_STR(EX_VAR(opline->result.var), type);
        } else {
index 915fa2414d494c610c04dcba0446732138c6b380..7424aea4261df1d55b4147230a3f9234394cd280 100644 (file)
@@ -28,7 +28,7 @@ PHP_FUNCTION(gettype)
                Z_PARAM_ZVAL(arg)
        ZEND_PARSE_PARAMETERS_END();
 
-       type = zend_zval_get_type(arg);
+       type = zend_zval_get_legacy_type(arg);
        if (EXPECTED(type)) {
                RETURN_INTERNED_STR(type);
        } else {