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