Display the readonly property modifier when printing reflection info

This commit is contained in:
Máté Kocsis 2021-07-25 12:13:48 +02:00
parent f5ee3429db
commit 8d25b62414
No known key found for this signature in database
GPG Key ID: FD055E41728BF310
2 changed files with 7 additions and 0 deletions

View File

@ -891,6 +891,9 @@ static void _property_string(smart_str *str, zend_property_info *prop, const cha
if (prop->flags & ZEND_ACC_STATIC) {
smart_str_appends(str, "static ");
}
if (prop->flags & ZEND_ACC_READONLY) {
smart_str_appends(str, "readonly ");
}
if (ZEND_TYPE_IS_SET(prop->type)) {
zend_string *type_str = zend_type_to_string(prop->type);
smart_str_append(str, type_str);

View File

@ -16,9 +16,13 @@ $rp = new ReflectionProperty(Test::class, 'ro');
var_dump($rp->isReadOnly());
var_dump(($rp->getModifiers() & ReflectionProperty::IS_READONLY) != 0);
$rp = new ReflectionProperty(Test::class, 'ro');
echo $rp;
?>
--EXPECT--
bool(false)
bool(false)
bool(true)
bool(true)
Property [ public readonly int $ro ]