mirror of
https://github.com/php/php-src.git
synced 2026-03-26 01:02:25 +01:00
RFC: https://wiki.php.net/rfc/property-hooks Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
29 lines
520 B
PHP
29 lines
520 B
PHP
--TEST--
|
|
ReflectionProperty::{get,set}Value() invokes hooks
|
|
--FILE--
|
|
<?php
|
|
|
|
class Test {
|
|
public $a {
|
|
get {
|
|
echo "Get called\n";
|
|
return 'Foo';
|
|
}
|
|
set {
|
|
echo "Set called with value $value\n";
|
|
}
|
|
}
|
|
}
|
|
|
|
$propertyReflection = (new ReflectionProperty(Test::class, 'a'));
|
|
|
|
$test = new Test();
|
|
var_dump($propertyReflection->getValue($test));
|
|
$propertyReflection->setValue($test, 'Baz');
|
|
|
|
?>
|
|
--EXPECT--
|
|
Get called
|
|
string(3) "Foo"
|
|
Set called with value Baz
|