1--TEST--
2Behavior of failing compound assignment
3--INI--
4opcache.optimization_level=0
5--FILE--
6<?php
7
8try {
9    $a = 1;
10    $a %= 0;
11} catch (Error $e) { var_dump($a); }
12
13try {
14    $a = 1;
15    $a >>= -1;
16} catch (Error $e) { var_dump($a); }
17
18try {
19    $a = 1;
20    $a <<= -1;
21} catch (Error $e) { var_dump($a); }
22
23set_error_handler(function($type, $msg) { throw new Exception($msg); });
24
25try {
26    $a = [];
27    $a .= "foo";
28} catch (Throwable $e) { var_dump($a); }
29
30try {
31    $a = "foo";
32    $a .= [];
33} catch (Throwable $e) { var_dump($a); }
34
35$x = new stdClass;
36try { $x += 1; }
37catch (Throwable $e) {}
38var_dump($x);
39
40$x = 1;
41try { $x += new stdClass; }
42catch (Throwable $e) {}
43var_dump($x);
44
45$x = "foo";
46try { $x += new stdClass; }
47catch (Throwable $e) {}
48var_dump($x);
49
50$x = new stdClass;
51try { $x -= 1; }
52catch (Throwable $e) {}
53var_dump($x);
54
55$x = 1;
56try { $x -= new stdClass; }
57catch (Throwable $e) {}
58var_dump($x);
59
60$x = "foo";
61try { $x -= new stdClass; }
62catch (Throwable $e) {}
63var_dump($x);
64
65$x = new stdClass;
66try { $x *= 1; }
67catch (Throwable $e) {}
68var_dump($x);
69
70$x = 1;
71try { $x *= new stdClass; }
72catch (Throwable $e) {}
73var_dump($x);
74
75$x = "foo";
76try { $x *= new stdClass; }
77catch (Throwable $e) {}
78var_dump($x);
79
80$x = new stdClass;
81try { $x /= 1; }
82catch (Throwable $e) {}
83var_dump($x);
84
85$x = 1;
86try { $x /= new stdClass; }
87catch (Throwable $e) {}
88var_dump($x);
89
90$x = "foo";
91try { $x /= new stdClass; }
92catch (Throwable $e) {}
93var_dump($x);
94
95$x = new stdClass;
96try { $x %= 1; }
97catch (Throwable $e) {}
98var_dump($x);
99
100$x = 1;
101try { $x %= new stdClass; }
102catch (Throwable $e) {}
103var_dump($x);
104
105$x = "foo";
106try { $x %= new stdClass; }
107catch (Throwable $e) {}
108var_dump($x);
109
110$x = new stdClass;
111try { $x **= 1; }
112catch (Throwable $e) {}
113var_dump($x);
114
115$x = 1;
116try { $x **= new stdClass; }
117catch (Throwable $e) {}
118var_dump($x);
119
120$x = "foo";
121try { $x **= new stdClass; }
122catch (Throwable $e) {}
123var_dump($x);
124
125$x = new stdClass;
126try { $x ^= 1; }
127catch (Throwable $e) {}
128var_dump($x);
129
130$x = 1;
131try { $x ^= new stdClass; }
132catch (Throwable $e) {}
133var_dump($x);
134
135$x = "foo";
136try { $x ^= new stdClass; }
137catch (Throwable $e) {}
138var_dump($x);
139
140$x = new stdClass;
141try { $x &= 1; }
142catch (Throwable $e) {}
143var_dump($x);
144
145$x = 1;
146try { $x &= new stdClass; }
147catch (Throwable $e) {}
148var_dump($x);
149
150$x = "foo";
151try { $x &= new stdClass; }
152catch (Throwable $e) {}
153var_dump($x);
154
155$x = new stdClass;
156try { $x |= 1; }
157catch (Throwable $e) {}
158var_dump($x);
159
160$x = 1;
161try { $x |= new stdClass; }
162catch (Throwable $e) {}
163var_dump($x);
164
165$x = "foo";
166try { $x |= new stdClass; }
167catch (Throwable $e) {}
168var_dump($x);
169
170$x = new stdClass;
171try { $x <<= 1; }
172catch (Throwable $e) {}
173var_dump($x);
174
175$x = 1;
176try { $x <<= new stdClass; }
177catch (Throwable $e) {}
178var_dump($x);
179
180$x = "foo";
181try { $x <<= new stdClass; }
182catch (Throwable $e) {}
183var_dump($x);
184
185$x = new stdClass;
186try { $x >>= 1; }
187catch (Throwable $e) {}
188var_dump($x);
189
190$x = 1;
191try { $x >>= new stdClass; }
192catch (Throwable $e) {}
193var_dump($x);
194
195$x = "foo";
196try { $x >>= new stdClass; }
197catch (Throwable $e) {}
198var_dump($x);
199
200?>
201--EXPECTF--
202int(1)
203int(1)
204int(1)
205array(0) {
206}
207string(3) "foo"
208object(stdClass)#%d (0) {
209}
210int(1)
211string(3) "foo"
212object(stdClass)#%d (0) {
213}
214int(1)
215string(3) "foo"
216object(stdClass)#%d (0) {
217}
218int(1)
219string(3) "foo"
220object(stdClass)#%d (0) {
221}
222int(1)
223string(3) "foo"
224object(stdClass)#%d (0) {
225}
226int(1)
227string(3) "foo"
228object(stdClass)#%d (0) {
229}
230int(1)
231string(3) "foo"
232object(stdClass)#%d (0) {
233}
234int(1)
235string(3) "foo"
236object(stdClass)#%d (0) {
237}
238int(1)
239string(3) "foo"
240object(stdClass)#%d (0) {
241}
242int(1)
243string(3) "foo"
244object(stdClass)#%d (0) {
245}
246int(1)
247string(3) "foo"
248object(stdClass)#%d (0) {
249}
250int(1)
251string(3) "foo"
252