Skip to content

Commit fdfc5c1

Browse files
committed
code de-duplication in ReflectionType::__toString and ReflectionNamedType::getName
This code duplication introduce an inconsistency in displayed type name - bool (reflection) vs boolean - int (reflection) vs integer And reflection already use zend_get_type_by_const in other methods... Inconsistenty is kept for BC reason. Could be fixed in 8.0
1 parent 76db01d commit fdfc5c1

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

ext/reflection/php_reflection.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2904,15 +2904,15 @@ static zend_string *reflection_type_name(type_reference *param) {
29042904
return zend_string_copy(ZEND_TYPE_NAME(param->arg_info->type));
29052905
}
29062906
switch (ZEND_TYPE_CODE(param->arg_info->type)) {
2907-
case IS_ARRAY: return zend_string_init("array", sizeof("array") - 1, 0);
2908-
case IS_CALLABLE: return zend_string_init("callable", sizeof("callable") - 1, 0);
2909-
case IS_STRING: return zend_string_init("string", sizeof("string") - 1, 0);
2907+
/* keep this for BC, bool vs boolean, int vs integer */
29102908
case _IS_BOOL: return zend_string_init("bool", sizeof("bool") - 1, 0);
29112909
case IS_LONG: return zend_string_init("int", sizeof("int") - 1, 0);
2912-
case IS_DOUBLE: return zend_string_init("float", sizeof("float") - 1, 0);
2913-
case IS_VOID: return zend_string_init("void", sizeof("void") - 1, 0);
2914-
case IS_ITERABLE: return zend_string_init("iterable", sizeof("iterable") - 1, 0);
2915-
EMPTY_SWITCH_DEFAULT_CASE()
2910+
/* use zend API for other types */
2911+
default:
2912+
{
2913+
char *name = zend_get_type_by_const(ZEND_TYPE_CODE(param->arg_info->type));
2914+
return zend_string_init(name, strlen(name), 0);
2915+
}
29162916
}
29172917
}
29182918
/* }}} */

0 commit comments

Comments
 (0)