1--TEST-- 2Test typed properties overflowing 3--FILE-- 4<?php 5 6$foo = new class { 7 public int $bar = PHP_INT_MAX; 8}; 9 10try { 11 $foo->bar++; 12} catch(TypeError $t) { 13 var_dump($t->getMessage()); 14} 15 16var_dump($foo); 17 18try { 19 $foo->bar += 1; 20} catch(TypeError $t) { 21 var_dump($t->getMessage()); 22} 23 24var_dump($foo); 25 26try { 27 ++$foo->bar; 28} catch(TypeError $t) { 29 var_dump($t->getMessage()); 30} 31 32var_dump($foo); 33 34try { 35 $foo->bar = $foo->bar + 1; 36} catch(TypeError $t) { 37 var_dump($t->getMessage()); 38} 39 40var_dump($foo); 41--EXPECTF-- 42string(82) "Cannot increment property class@anonymous::$bar of type int past its maximal value" 43object(class@anonymous)#1 (1) { 44 ["bar"]=> 45 int(%d) 46} 47string(60) "Typed property class@anonymous::$bar must be int, float used" 48object(class@anonymous)#1 (1) { 49 ["bar"]=> 50 int(%d) 51} 52string(82) "Cannot increment property class@anonymous::$bar of type int past its maximal value" 53object(class@anonymous)#1 (1) { 54 ["bar"]=> 55 int(%d) 56} 57string(60) "Typed property class@anonymous::$bar must be int, float used" 58object(class@anonymous)#1 (1) { 59 ["bar"]=> 60 int(%d) 61} 62