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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
--TEST--
ReflectionClass::getHook() inheritance
--FILE--
<?php
class A {
public $foo {
get {
return 'A::$foo::get';
}
set {
echo "A::\$foo::set\n";
}
}
}
class B extends A {
public $foo {
get {
return 'B::$foo';
}
}
}
$a = new A();
$b = new B();
echo ((new ReflectionProperty(A::class, 'foo'))->getHook(PropertyHookType::Get)->invoke($a)), "\n";
echo ((new ReflectionProperty(A::class, 'foo'))->getHook(PropertyHookType::Get)->invoke($b)), "\n";
echo ((new ReflectionProperty(B::class, 'foo'))->getHook(PropertyHookType::Get)->invoke($b)), "\n";
((new ReflectionProperty(A::class, 'foo'))->getHook(PropertyHookType::Set)->invoke($a, null));
((new ReflectionProperty(A::class, 'foo'))->getHook(PropertyHookType::Set)->invoke($b, null));
((new ReflectionProperty(B::class, 'foo'))->getHook(PropertyHookType::Set)->invoke($b, null));
?>
--EXPECT--
A::$foo::get
A::$foo::get
B::$foo
A::$foo::set
A::$foo::set
A::$foo::set
|