1--TEST-- 2Virtual get hook allows returning by reference 3--FILE-- 4<?php 5 6class Test { 7 private $_prop; 8 public $prop { 9 &get => $this->_prop; 10 set { $this->_prop = $value; } 11 } 12} 13 14function inc(&$ref) { 15 $ref++; 16} 17 18$test = new Test(); 19$test->prop = 42; 20 21$prop = &$test->prop; 22$prop++; 23var_dump($test); 24var_dump($test->prop); 25unset($prop); 26 27inc($test->prop); 28var_dump($test); 29var_dump($test->prop); 30 31?> 32--EXPECT-- 33object(Test)#1 (1) { 34 ["_prop":"Test":private]=> 35 &int(43) 36} 37int(43) 38object(Test)#1 (1) { 39 ["_prop":"Test":private]=> 40 int(44) 41} 42int(44) 43