1--TEST-- 2Readonly property reflection 3--FILE-- 4<?php 5 6class Test { 7 public int $rw; 8 public readonly int $ro; 9} 10 11$rp = new ReflectionProperty(Test::class, 'rw'); 12var_dump($rp->isReadOnly()); 13var_dump(($rp->getModifiers() & ReflectionProperty::IS_READONLY) != 0); 14 15$rp = new ReflectionProperty(Test::class, 'ro'); 16var_dump($rp->isReadOnly()); 17var_dump(($rp->getModifiers() & ReflectionProperty::IS_READONLY) != 0); 18 19$rp = new ReflectionProperty(Test::class, 'ro'); 20echo $rp; 21 22?> 23--EXPECT-- 24bool(false) 25bool(false) 26bool(true) 27bool(true) 28Property [ public protected(set) readonly int $ro ] 29