1
0
mirror of https://github.com/php/php-src.git synced 2026-04-28 18:53:33 +02:00
Files
archived-php-src/ext/reflection/tests/ReflectionProperty_isWritable_unrelated_object.phpt
2026-02-27 14:26:06 +01:00

37 lines
665 B
PHP

--TEST--
Test ReflectionProperty::isWritable() unrelated object
--FILE--
<?php
class A {
}
class B extends A {
public $prop;
}
class C extends B {}
class D {}
function test($obj) {
$r = new ReflectionProperty('B', 'prop');
try {
var_dump($r->isWritable(null, $obj));
} catch (Exception $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
}
test(new A);
test(new B);
test(new C);
test(new D);
?>
--EXPECT--
ReflectionException: Given object is not an instance of the class this property was declared in
bool(true)
bool(true)
ReflectionException: Given object is not an instance of the class this property was declared in