php-src/Zend/tests/property_hooks/interface_get_value_as_ref.phpt
Ilija Tovilo 780a8280d2
[RFC] Property hooks (#13455)
RFC: https://wiki.php.net/rfc/property-hooks

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2024-07-14 11:55:03 +02:00

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)
}