1--TEST--
2Different kinds of indirect modification with by-val and by-ref getters
3--FILE--
4<?php
5
6
7class Test {
8    public $byVal {
9        set {
10            echo __METHOD__, "\n";
11            $this->byVal = $value;
12        }
13    }
14}
15
16$test = new Test;
17
18$test->byVal = 0;
19$test->byVal++;
20++$test->byVal;
21$test->byVal += 1;
22var_dump($test->byVal);
23$test->byVal = [];
24try {
25    $test->byVal[] = 1;
26} catch (\Error $e) {
27    echo $e->getMessage(), "\n";
28}
29var_dump($test->byVal);
30try {
31    $ref =& $test->byVal;
32} catch (\Error $e) {
33    echo $e->getMessage(), "\n";
34}
35$ref = 42;
36var_dump($test->byVal);
37
38?>
39--EXPECT--
40Test::$byVal::set
41Test::$byVal::set
42Test::$byVal::set
43Test::$byVal::set
44int(3)
45Test::$byVal::set
46Indirect modification of Test::$byVal is not allowed
47array(0) {
48}
49Indirect modification of Test::$byVal is not allowed
50array(0) {
51}
52