mirror of
https://github.com/php/php-src.git
synced 2026-04-28 18:53:33 +02:00
e4f727d61e
RFC: https://wiki.php.net/rfc/isreadable-iswriteable Fixes GH-15309 Fixes GH-16175 Closes GH-16209
37 lines
665 B
PHP
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
|