diff options
Diffstat (limited to 'ext/reflection/php_reflection.c')
-rw-r--r-- | ext/reflection/php_reflection.c | 54 |
1 files changed, 20 insertions, 34 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 5cc023831e..18e3a0cecc 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -582,17 +582,14 @@ static void _parameter_string(smart_str *str, zend_function *fptr, struct _zend_ } else { smart_str_append_printf(str, "<required> "); } - if (ZEND_TYPE_IS_CLASS(arg_info->type)) { - smart_str_append_printf(str, "%s ", - ZSTR_VAL(ZEND_TYPE_NAME(arg_info->type))); - if (ZEND_TYPE_ALLOW_NULL(arg_info->type)) { - smart_str_append_printf(str, "or NULL "); - } - } else if (ZEND_TYPE_IS_CODE(arg_info->type)) { - smart_str_append_printf(str, "%s ", zend_get_type_by_const(ZEND_TYPE_CODE(arg_info->type))); + if (ZEND_TYPE_IS_SET(arg_info->type)) { + /* TODO: We should be using ?Type instead of "or NULL" here. */ + zend_string *type_str = zend_type_to_string(ZEND_TYPE_WITHOUT_NULL(arg_info->type)); + smart_str_append_printf(str, "%s ", ZSTR_VAL(type_str)); if (ZEND_TYPE_ALLOW_NULL(arg_info->type)) { smart_str_append_printf(str, "or NULL "); } + zend_string_release(type_str); } if (arg_info->pass_by_reference) { smart_str_appendc(str, '&'); @@ -802,17 +799,15 @@ static void _function_string(smart_str *str, zend_function *fptr, zend_class_ent smart_str_free(¶m_indent); if (fptr->op_array.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) { smart_str_append_printf(str, " %s- Return [ ", indent); - if (ZEND_TYPE_IS_CLASS(fptr->common.arg_info[-1].type)) { - smart_str_append_printf(str, "%s ", - ZSTR_VAL(ZEND_TYPE_NAME(fptr->common.arg_info[-1].type))); - if (ZEND_TYPE_ALLOW_NULL(fptr->common.arg_info[-1].type)) { - smart_str_appends(str, "or NULL "); - } - } else if (ZEND_TYPE_IS_CODE(fptr->common.arg_info[-1].type)) { - smart_str_append_printf(str, "%s ", zend_get_type_by_const(ZEND_TYPE_CODE(fptr->common.arg_info[-1].type))); + if (ZEND_TYPE_IS_SET(fptr->common.arg_info[-1].type)) { + /* TODO: We should use ?Type instead of "or NULL" here */ + zend_string *type_str = + zend_type_to_string(ZEND_TYPE_WITHOUT_NULL(fptr->common.arg_info[-1].type)); + smart_str_append_printf(str, "%s ", ZSTR_VAL(type_str)); if (ZEND_TYPE_ALLOW_NULL(fptr->common.arg_info[-1].type)) { smart_str_appends(str, "or NULL "); } + zend_string_release(type_str); } smart_str_appends(str, "]\n"); } @@ -2565,13 +2560,15 @@ ZEND_METHOD(reflection_parameter, isArray) { reflection_object *intern; parameter_reference *param; + zend_type type; if (zend_parse_parameters_none() == FAILURE) { return; } GET_REFLECTION_OBJECT_PTR(param); - RETVAL_BOOL(ZEND_TYPE_CODE(param->arg_info->type) == IS_ARRAY); + type = ZEND_TYPE_WITHOUT_NULL(param->arg_info->type); + RETVAL_BOOL(ZEND_TYPE_MASK(type) == MAY_BE_ARRAY); } /* }}} */ @@ -2581,13 +2578,15 @@ ZEND_METHOD(reflection_parameter, isCallable) { reflection_object *intern; parameter_reference *param; + zend_type type; if (zend_parse_parameters_none() == FAILURE) { return; } GET_REFLECTION_OBJECT_PTR(param); - RETVAL_BOOL(ZEND_TYPE_CODE(param->arg_info->type) == IS_CALLABLE); + type = ZEND_TYPE_WITHOUT_NULL(param->arg_info->type); + RETVAL_BOOL(ZEND_TYPE_MASK(type) == MAY_BE_CALLABLE); } /* }}} */ @@ -2817,19 +2816,6 @@ ZEND_METHOD(reflection_type, allowsNull) } /* }}} */ -/* {{{ reflection_type_name */ -static zend_string *reflection_type_name(type_reference *param) { - if (ZEND_TYPE_IS_NAME(param->type)) { - return zend_string_copy(ZEND_TYPE_NAME(param->type)); - } else if (ZEND_TYPE_IS_CE(param->type)) { - return zend_string_copy(ZEND_TYPE_CE(param->type)->name); - } else { - const char *name = zend_get_type_by_const(ZEND_TYPE_CODE(param->type)); - return zend_string_init(name, strlen(name), 0); - } -} -/* }}} */ - /* {{{ proto public string ReflectionType::__toString() Return the text of the type hint */ ZEND_METHOD(reflection_type, __toString) @@ -2842,7 +2828,7 @@ ZEND_METHOD(reflection_type, __toString) } GET_REFLECTION_OBJECT_PTR(param); - RETURN_STR(reflection_type_name(param)); + RETURN_STR(zend_type_to_string(ZEND_TYPE_WITHOUT_NULL(param->type))); } /* }}} */ @@ -2858,7 +2844,7 @@ ZEND_METHOD(reflection_named_type, getName) } GET_REFLECTION_OBJECT_PTR(param); - RETURN_STR(reflection_type_name(param)); + RETURN_STR(zend_type_to_string(ZEND_TYPE_WITHOUT_NULL(param->type))); } /* }}} */ @@ -2874,7 +2860,7 @@ ZEND_METHOD(reflection_named_type, isBuiltin) } GET_REFLECTION_OBJECT_PTR(param); - RETVAL_BOOL(ZEND_TYPE_IS_CODE(param->type)); + RETVAL_BOOL(ZEND_TYPE_IS_MASK(param->type)); } /* }}} */ |