Skip to content

Commit f43a19e

Browse files
committed
Slightly clean up reflection constant printing
The basic formatting is always the same, the only thing that differs is how the value is printed, so don't duplicate the rest.
1 parent 5502910 commit f43a19e

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

ext/reflection/php_reflection.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -560,30 +560,25 @@ static void _const_string(smart_str *str, char *name, zval *value, char *indent)
560560
/* {{{ _class_const_string */
561561
static void _class_const_string(smart_str *str, char *name, zend_class_constant *c, char *indent)
562562
{
563-
char *visibility = zend_visibility_string(ZEND_CLASS_CONST_FLAGS(c));
564-
const char *type;
565-
566563
if (zval_update_constant_ex(&c->value, c->ce) == FAILURE) {
567564
return;
568565
}
569566

570-
type = zend_zval_type_name(&c->value);
571-
567+
const char *visibility = zend_visibility_string(ZEND_CLASS_CONST_FLAGS(c));
568+
const char *type = zend_zval_type_name(&c->value);
569+
smart_str_append_printf(str, "%sConstant [ %s %s %s ] { ",
570+
indent, visibility, type, name);
572571
if (Z_TYPE(c->value) == IS_ARRAY) {
573-
smart_str_append_printf(str, "%sConstant [ %s %s %s ] { Array }\n",
574-
indent, visibility, type, name);
572+
smart_str_appends(str, "Array");
575573
} else if (Z_TYPE(c->value) == IS_OBJECT) {
576-
smart_str_append_printf(str, "%sConstant [ %s %s %s ] { Object }\n",
577-
indent, visibility, type, name);
574+
smart_str_appends(str, "Object");
578575
} else {
579576
zend_string *tmp_value_str;
580577
zend_string *value_str = zval_get_tmp_string(&c->value, &tmp_value_str);
581-
582-
smart_str_append_printf(str, "%sConstant [ %s %s %s ] { %s }\n",
583-
indent, visibility, type, name, ZSTR_VAL(value_str));
584-
578+
smart_str_append(str, value_str);
585579
zend_tmp_string_release(tmp_value_str);
586580
}
581+
smart_str_appends(str, " }\n");
587582
}
588583
/* }}} */
589584

0 commit comments

Comments
 (0)