1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 08:12:21 +01:00
Files
archived-php-src/ext/reflection/tests/ReflectionProperty_isWritable_static.phpt
2026-02-27 14:26:06 +01:00

37 lines
836 B
PHP

--TEST--
Test ReflectionProperty::isWritable() static
--FILE--
<?php
class A {
public static $a;
public static int $b;
public static int $c = 42;
protected static int $d = 42;
private static int $e = 42;
public private(set) static int $f = 42;
}
$r = new ReflectionProperty('A', 'a');
try {
$r->isWritable(null, new A);
} catch (Exception $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
$rc = new ReflectionClass('A');
foreach ($rc->getProperties() as $rp) {
echo $rp->getName() . ' from global: ';
var_dump($rp->isWritable(null));
}
?>
--EXPECT--
ReflectionException: null is expected as object argument for static properties
a from global: bool(true)
b from global: bool(true)
c from global: bool(true)
d from global: bool(false)
e from global: bool(false)
f from global: bool(false)