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