diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 10eaaa9734833..ac787ee269cb3 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -566,6 +566,10 @@ static void _class_const_string(smart_str *str, zend_string *name, zend_class_co const char *final = ZEND_CLASS_CONST_FLAGS(c) & ZEND_ACC_FINAL ? "final " : ""; zend_string *type_str = ZEND_TYPE_IS_SET(c->type) ? zend_type_to_string(c->type) : NULL; const char *type = type_str ? ZSTR_VAL(type_str) : zend_zval_type_name(&c->value); + + if (c->doc_comment) { + smart_str_append_printf(str, "%s%s\n", indent, ZSTR_VAL(c->doc_comment)); + } smart_str_append_printf(str, "%sConstant [ %s%s %s %s ] { ", indent, final, visibility, type, ZSTR_VAL(name)); if (Z_TYPE(c->value) == IS_ARRAY) { @@ -889,6 +893,9 @@ static zval *property_get_default(zend_property_info *prop_info) { /* {{{ _property_string */ static void _property_string(smart_str *str, zend_property_info *prop, const char *prop_name, char* indent) { + if (prop && prop->doc_comment) { + smart_str_append_printf(str, "%s%s\n", indent, ZSTR_VAL(prop->doc_comment)); + } smart_str_append_printf(str, "%sProperty [ ", indent); if (!prop) { smart_str_append_printf(str, " public $%s", prop_name); diff --git a/ext/reflection/tests/ReflectionClassConstant_basic1.phpt b/ext/reflection/tests/ReflectionClassConstant_basic1.phpt index 33d923d97130c..4b8c8a32f7854 100644 --- a/ext/reflection/tests/ReflectionClassConstant_basic1.phpt +++ b/ext/reflection/tests/ReflectionClassConstant_basic1.phpt @@ -57,7 +57,8 @@ reflectClassConstant($instance, "BAD_CONST"); Reflecting on class constant TestClass::PUB __toString(): -string(35) "Constant [ public bool PUB ] { 1 } +string(57) "/** My Doc comment */ +Constant [ public bool PUB ] { 1 } " getName(): string(3) "PUB" @@ -89,7 +90,8 @@ bool Reflecting on class constant TestClass::PROT __toString(): -string(38) "Constant [ protected int PROT ] { 4 } +string(65) "/** Another doc comment */ +Constant [ protected int PROT ] { 4 } " getName(): string(4) "PROT" diff --git a/ext/reflection/tests/constructor_promotion.phpt b/ext/reflection/tests/constructor_promotion.phpt index d0a09aaee048f..b18ff459c4431 100644 --- a/ext/reflection/tests/constructor_promotion.phpt +++ b/ext/reflection/tests/constructor_promotion.phpt @@ -46,6 +46,7 @@ Class [ class Test ] { - Properties [3] { Property [ public $z = NULL ] Property [ public int $x ] + /** @SomeAnnotation() */ Property [ public string $y ] }