1--TEST-- 2Typed property on by-ref property 3--FILE-- 4<?php 5 6$a = new class { 7 public int $foo = 1; 8 public $_; 9}; 10 11$a->_ = &$a->foo; 12 13$a->_ += 1; 14var_dump($a->foo); 15 16$a->_ .= "1"; 17var_dump($a->foo); 18 19try { 20 $a->_ .= "e50"; 21} catch (Error $e) { echo $e->getMessage(), "\n"; } 22var_dump($a->foo); 23 24$a->_--; 25var_dump($a->foo); 26 27--$a->_; 28var_dump($a->foo); 29 30$a->foo = PHP_INT_MIN; 31 32try { 33 $a->_--; 34} catch (Error $e) { echo $e->getMessage(), "\n"; } 35echo gettype($a->foo),"\n"; 36 37try { 38 --$a->_; 39} catch (Error $e) { echo $e->getMessage(), "\n"; } 40echo gettype($a->foo),"\n"; 41 42$a->foo = PHP_INT_MAX; 43 44try { 45 $a->_++; 46} catch (Error $e) { echo $e->getMessage(), "\n"; } 47echo gettype($a->foo),"\n"; 48 49try { 50 ++$a->_; 51} catch (Error $e) { echo $e->getMessage(), "\n"; } 52echo gettype($a->foo),"\n"; 53 54$a->_ = 0; 55try { 56 $a->_ = []; 57} catch (Error $e) { echo $e->getMessage(), "\n"; } 58var_dump($a->foo); 59 60$a->_ = 1; 61var_dump($a->foo); 62 63?> 64--EXPECT-- 65int(2) 66int(21) 67Cannot assign string to reference held by property class@anonymous::$foo of type int 68int(21) 69int(20) 70int(19) 71Cannot decrement a reference held by property class@anonymous::$foo of type int past its minimal value 72integer 73Cannot decrement a reference held by property class@anonymous::$foo of type int past its minimal value 74integer 75Cannot increment a reference held by property class@anonymous::$foo of type int past its maximal value 76integer 77Cannot increment a reference held by property class@anonymous::$foo of type int past its maximal value 78integer 79Cannot assign array to reference held by property class@anonymous::$foo of type int 80int(0) 81int(1) 82