mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00

RFC: https://wiki.php.net/rfc/property-hooks Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
28 lines
451 B
PHP
28 lines
451 B
PHP
--TEST--
|
|
Access hooked property from magic method
|
|
--FILE--
|
|
<?php
|
|
|
|
class Test {
|
|
private $prop {
|
|
get { echo __METHOD__, "\n"; return 42; }
|
|
set { echo __METHOD__, "\n"; }
|
|
}
|
|
|
|
public function __get($name) {
|
|
return $this->{$name};
|
|
}
|
|
|
|
public function __set($name, $value) {
|
|
$this->{$name} = $value;
|
|
}
|
|
}
|
|
|
|
$test = new Test;
|
|
$test->prop;
|
|
$test->prop = 42;
|
|
|
|
?>
|
|
--EXPECT--
|
|
Test::$prop::get
|
|
Test::$prop::set
|