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