Skip to content

Commit 8d25b62

Browse files
committed
Display the readonly property modifier when printing reflection info
1 parent f5ee342 commit 8d25b62

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

ext/reflection/php_reflection.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,9 @@ static void _property_string(smart_str *str, zend_property_info *prop, const cha
891891
if (prop->flags & ZEND_ACC_STATIC) {
892892
smart_str_appends(str, "static ");
893893
}
894+
if (prop->flags & ZEND_ACC_READONLY) {
895+
smart_str_appends(str, "readonly ");
896+
}
894897
if (ZEND_TYPE_IS_SET(prop->type)) {
895898
zend_string *type_str = zend_type_to_string(prop->type);
896899
smart_str_append(str, type_str);

ext/reflection/tests/readonly_properties.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@ $rp = new ReflectionProperty(Test::class, 'ro');
1616
var_dump($rp->isReadOnly());
1717
var_dump(($rp->getModifiers() & ReflectionProperty::IS_READONLY) != 0);
1818

19+
$rp = new ReflectionProperty(Test::class, 'ro');
20+
echo $rp;
21+
1922
?>
2023
--EXPECT--
2124
bool(false)
2225
bool(false)
2326
bool(true)
2427
bool(true)
28+
Property [ public readonly int $ro ]

0 commit comments

Comments
 (0)