com php-src: code de-duplication in ReflectionType::__t oString and ReflectionNamedType::getName: ext/refle ction/php_reflection.c
| From: | Remi Collet | Date: | Thu, 15 Jun 2017 13:38:03 +0000 |
| Subject: | com php-src: code de-duplication in ReflectionType::__t oString and ReflectionNamedType::getName: ext/refle ction/php_reflection.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-98078@lists.php.net to get a copy of this message | ||
Commit: fdfc5c1b3dbc9c8030ff8019ef9bf66d9f46d2d8
Author: Remi Collet <remi@php.net> Thu, 15 Jun 2017 15:38:03 +0200
Parents: 76db01d9ff213aec3f5f0e532c67c6ea8c4b5751
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=fdfc5c1b3dbc9c8030ff8019ef9bf66d9f46d2d8
Log:
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
Changed paths:
M ext/reflection/php_reflection.c
Diff:
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index 19975d2..badbf8e 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -2904,15 +2904,15 @@ static zend_string *reflection_type_name(type_reference *param) {
return zend_string_copy(ZEND_TYPE_NAME(param->arg_info->type));
}
switch (ZEND_TYPE_CODE(param->arg_info->type)) {
- case IS_ARRAY: return zend_string_init("array", sizeof("array") - 1, 0);
- case IS_CALLABLE: return zend_string_init("callable", sizeof("callable") - 1,
0);
- case IS_STRING: return zend_string_init("string", sizeof("string") - 1, 0);
+ /* keep this for BC, bool vs boolean, int vs integer */
case _IS_BOOL: return zend_string_init("bool", sizeof("bool") - 1, 0);
case IS_LONG: return zend_string_init("int", sizeof("int") - 1, 0);
- case IS_DOUBLE: return zend_string_init("float", sizeof("float") - 1, 0);
- case IS_VOID: return zend_string_init("void", sizeof("void") - 1, 0);
- case IS_ITERABLE: return zend_string_init("iterable", sizeof("iterable") - 1,
0);
- EMPTY_SWITCH_DEFAULT_CASE()
+ /* use zend API for other types */
+ default:
+ {
+ char *name = zend_get_type_by_const(ZEND_TYPE_CODE(param->arg_info->type));
+ return zend_string_init(name, strlen(name), 0);
+ }
}
}
/* }}} */