mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
780a8280d2
RFC: https://wiki.php.net/rfc/property-hooks Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
32 lines
388 B
PHP
32 lines
388 B
PHP
--TEST--
|
|
By-value get may be implemented as by-reference
|
|
--FILE--
|
|
<?php
|
|
|
|
interface I {
|
|
public $prop { get; }
|
|
}
|
|
|
|
class A implements I {
|
|
private $_prop;
|
|
public $prop {
|
|
&get => $this->_prop;
|
|
}
|
|
}
|
|
|
|
function test(I $i) {
|
|
$ref = &$i->prop;
|
|
$ref = 42;
|
|
}
|
|
|
|
$a = new A();
|
|
test($a);
|
|
var_dump($a);
|
|
|
|
?>
|
|
--EXPECT--
|
|
object(A)#1 (1) {
|
|
["_prop":"A":private]=>
|
|
int(42)
|
|
}
|