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>
31 lines
388 B
PHP
31 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)
|
|
}
|