mirror of
https://github.com/php/php-src.git
synced 2024-11-27 03:44:07 +08:00
Display class constant and property doc comments via reflection (#13499)
This commit is contained in:
parent
db6a567607
commit
4b405d8520
@ -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, "<dynamic> public $%s", prop_name);
|
||||
|
@ -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"
|
||||
|
@ -46,6 +46,7 @@ Class [ <user> class Test ] {
|
||||
- Properties [3] {
|
||||
Property [ public $z = NULL ]
|
||||
Property [ public int $x ]
|
||||
/** @SomeAnnotation() */
|
||||
Property [ public string $y ]
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user