1--TEST--
2Test increment functions on typed property references
3--SKIPIF--
4<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64 bit platform only"); ?>
5--FILE--
6<?php
7$foo = new class {
8    public ?int $bar;
9};
10
11$bar = &$foo->bar;
12
13$bar *= 1;
14
15var_dump($bar--);
16var_dump(--$bar);
17var_dump(++$bar);
18var_dump($bar++);
19
20$bar = PHP_INT_MAX;
21
22try {
23    var_dump($bar++);
24} catch (Throwable $e) {
25    echo $e->getMessage() . "\n";
26}
27
28try {
29    var_dump(++$bar);
30} catch (Throwable $e) {
31    echo $e->getMessage() . "\n";
32}
33
34$bar = PHP_INT_MIN;
35
36
37try {
38    var_dump($bar--);
39} catch (Throwable $e) {
40    echo $e->getMessage() . "\n";
41}
42
43try {
44    var_dump(--$bar);
45} catch (Throwable $e) {
46    echo $e->getMessage() . "\n";
47}
48
49?>
50--EXPECT--
51int(0)
52int(-2)
53int(-1)
54int(-1)
55Cannot increment a reference held by property class@anonymous::$bar of type ?int past its maximal value
56Cannot increment a reference held by property class@anonymous::$bar of type ?int past its maximal value
57Cannot decrement a reference held by property class@anonymous::$bar of type ?int past its minimal value
58Cannot decrement a reference held by property class@anonymous::$bar of type ?int past its minimal value
59