1--TEST--
2Test << operator : various numbers as strings
3--SKIPIF--
4<?php
5if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
6?>
7--FILE--
8<?php
9
10$strVals = array(
11   "0","65","-44", "1.2", "-7.7", "abc", "123abc", "123e5", "123e5xyz", " 123abc", "123 abc", "123abc ", "3.4a",
12   "a5.9"
13);
14
15error_reporting(E_ERROR);
16
17foreach ($strVals as $strVal) {
18   foreach($strVals as $otherVal) {
19      echo "--- testing: '$strVal' << '$otherVal' ---\n";
20      try {
21        var_dump($strVal<<$otherVal);
22      } catch (\Throwable $e) {
23        echo get_class($e) . ': ' . $e->getMessage() . "\n";
24      }
25   }
26}
27
28
29?>
30--EXPECT--
31--- testing: '0' << '0' ---
32int(0)
33--- testing: '0' << '65' ---
34int(0)
35--- testing: '0' << '-44' ---
36ArithmeticError: Bit shift by negative number
37--- testing: '0' << '1.2' ---
38int(0)
39--- testing: '0' << '-7.7' ---
40ArithmeticError: Bit shift by negative number
41--- testing: '0' << 'abc' ---
42TypeError: Unsupported operand types: string << string
43--- testing: '0' << '123abc' ---
44int(0)
45--- testing: '0' << '123e5' ---
46int(0)
47--- testing: '0' << '123e5xyz' ---
48int(0)
49--- testing: '0' << ' 123abc' ---
50int(0)
51--- testing: '0' << '123 abc' ---
52int(0)
53--- testing: '0' << '123abc ' ---
54int(0)
55--- testing: '0' << '3.4a' ---
56int(0)
57--- testing: '0' << 'a5.9' ---
58TypeError: Unsupported operand types: string << string
59--- testing: '65' << '0' ---
60int(65)
61--- testing: '65' << '65' ---
62int(0)
63--- testing: '65' << '-44' ---
64ArithmeticError: Bit shift by negative number
65--- testing: '65' << '1.2' ---
66int(130)
67--- testing: '65' << '-7.7' ---
68ArithmeticError: Bit shift by negative number
69--- testing: '65' << 'abc' ---
70TypeError: Unsupported operand types: string << string
71--- testing: '65' << '123abc' ---
72int(0)
73--- testing: '65' << '123e5' ---
74int(0)
75--- testing: '65' << '123e5xyz' ---
76int(0)
77--- testing: '65' << ' 123abc' ---
78int(0)
79--- testing: '65' << '123 abc' ---
80int(0)
81--- testing: '65' << '123abc ' ---
82int(0)
83--- testing: '65' << '3.4a' ---
84int(520)
85--- testing: '65' << 'a5.9' ---
86TypeError: Unsupported operand types: string << string
87--- testing: '-44' << '0' ---
88int(-44)
89--- testing: '-44' << '65' ---
90int(0)
91--- testing: '-44' << '-44' ---
92ArithmeticError: Bit shift by negative number
93--- testing: '-44' << '1.2' ---
94int(-88)
95--- testing: '-44' << '-7.7' ---
96ArithmeticError: Bit shift by negative number
97--- testing: '-44' << 'abc' ---
98TypeError: Unsupported operand types: string << string
99--- testing: '-44' << '123abc' ---
100int(0)
101--- testing: '-44' << '123e5' ---
102int(0)
103--- testing: '-44' << '123e5xyz' ---
104int(0)
105--- testing: '-44' << ' 123abc' ---
106int(0)
107--- testing: '-44' << '123 abc' ---
108int(0)
109--- testing: '-44' << '123abc ' ---
110int(0)
111--- testing: '-44' << '3.4a' ---
112int(-352)
113--- testing: '-44' << 'a5.9' ---
114TypeError: Unsupported operand types: string << string
115--- testing: '1.2' << '0' ---
116int(1)
117--- testing: '1.2' << '65' ---
118int(0)
119--- testing: '1.2' << '-44' ---
120ArithmeticError: Bit shift by negative number
121--- testing: '1.2' << '1.2' ---
122int(2)
123--- testing: '1.2' << '-7.7' ---
124ArithmeticError: Bit shift by negative number
125--- testing: '1.2' << 'abc' ---
126TypeError: Unsupported operand types: string << string
127--- testing: '1.2' << '123abc' ---
128int(0)
129--- testing: '1.2' << '123e5' ---
130int(0)
131--- testing: '1.2' << '123e5xyz' ---
132int(0)
133--- testing: '1.2' << ' 123abc' ---
134int(0)
135--- testing: '1.2' << '123 abc' ---
136int(0)
137--- testing: '1.2' << '123abc ' ---
138int(0)
139--- testing: '1.2' << '3.4a' ---
140int(8)
141--- testing: '1.2' << 'a5.9' ---
142TypeError: Unsupported operand types: string << string
143--- testing: '-7.7' << '0' ---
144int(-7)
145--- testing: '-7.7' << '65' ---
146int(0)
147--- testing: '-7.7' << '-44' ---
148ArithmeticError: Bit shift by negative number
149--- testing: '-7.7' << '1.2' ---
150int(-14)
151--- testing: '-7.7' << '-7.7' ---
152ArithmeticError: Bit shift by negative number
153--- testing: '-7.7' << 'abc' ---
154TypeError: Unsupported operand types: string << string
155--- testing: '-7.7' << '123abc' ---
156int(0)
157--- testing: '-7.7' << '123e5' ---
158int(0)
159--- testing: '-7.7' << '123e5xyz' ---
160int(0)
161--- testing: '-7.7' << ' 123abc' ---
162int(0)
163--- testing: '-7.7' << '123 abc' ---
164int(0)
165--- testing: '-7.7' << '123abc ' ---
166int(0)
167--- testing: '-7.7' << '3.4a' ---
168int(-56)
169--- testing: '-7.7' << 'a5.9' ---
170TypeError: Unsupported operand types: string << string
171--- testing: 'abc' << '0' ---
172TypeError: Unsupported operand types: string << string
173--- testing: 'abc' << '65' ---
174TypeError: Unsupported operand types: string << string
175--- testing: 'abc' << '-44' ---
176TypeError: Unsupported operand types: string << string
177--- testing: 'abc' << '1.2' ---
178TypeError: Unsupported operand types: string << string
179--- testing: 'abc' << '-7.7' ---
180TypeError: Unsupported operand types: string << string
181--- testing: 'abc' << 'abc' ---
182TypeError: Unsupported operand types: string << string
183--- testing: 'abc' << '123abc' ---
184TypeError: Unsupported operand types: string << string
185--- testing: 'abc' << '123e5' ---
186TypeError: Unsupported operand types: string << string
187--- testing: 'abc' << '123e5xyz' ---
188TypeError: Unsupported operand types: string << string
189--- testing: 'abc' << ' 123abc' ---
190TypeError: Unsupported operand types: string << string
191--- testing: 'abc' << '123 abc' ---
192TypeError: Unsupported operand types: string << string
193--- testing: 'abc' << '123abc ' ---
194TypeError: Unsupported operand types: string << string
195--- testing: 'abc' << '3.4a' ---
196TypeError: Unsupported operand types: string << string
197--- testing: 'abc' << 'a5.9' ---
198TypeError: Unsupported operand types: string << string
199--- testing: '123abc' << '0' ---
200int(123)
201--- testing: '123abc' << '65' ---
202int(0)
203--- testing: '123abc' << '-44' ---
204ArithmeticError: Bit shift by negative number
205--- testing: '123abc' << '1.2' ---
206int(246)
207--- testing: '123abc' << '-7.7' ---
208ArithmeticError: Bit shift by negative number
209--- testing: '123abc' << 'abc' ---
210TypeError: Unsupported operand types: string << string
211--- testing: '123abc' << '123abc' ---
212int(0)
213--- testing: '123abc' << '123e5' ---
214int(0)
215--- testing: '123abc' << '123e5xyz' ---
216int(0)
217--- testing: '123abc' << ' 123abc' ---
218int(0)
219--- testing: '123abc' << '123 abc' ---
220int(0)
221--- testing: '123abc' << '123abc ' ---
222int(0)
223--- testing: '123abc' << '3.4a' ---
224int(984)
225--- testing: '123abc' << 'a5.9' ---
226TypeError: Unsupported operand types: string << string
227--- testing: '123e5' << '0' ---
228int(12300000)
229--- testing: '123e5' << '65' ---
230int(0)
231--- testing: '123e5' << '-44' ---
232ArithmeticError: Bit shift by negative number
233--- testing: '123e5' << '1.2' ---
234int(24600000)
235--- testing: '123e5' << '-7.7' ---
236ArithmeticError: Bit shift by negative number
237--- testing: '123e5' << 'abc' ---
238TypeError: Unsupported operand types: string << string
239--- testing: '123e5' << '123abc' ---
240int(0)
241--- testing: '123e5' << '123e5' ---
242int(0)
243--- testing: '123e5' << '123e5xyz' ---
244int(0)
245--- testing: '123e5' << ' 123abc' ---
246int(0)
247--- testing: '123e5' << '123 abc' ---
248int(0)
249--- testing: '123e5' << '123abc ' ---
250int(0)
251--- testing: '123e5' << '3.4a' ---
252int(98400000)
253--- testing: '123e5' << 'a5.9' ---
254TypeError: Unsupported operand types: string << string
255--- testing: '123e5xyz' << '0' ---
256int(12300000)
257--- testing: '123e5xyz' << '65' ---
258int(0)
259--- testing: '123e5xyz' << '-44' ---
260ArithmeticError: Bit shift by negative number
261--- testing: '123e5xyz' << '1.2' ---
262int(24600000)
263--- testing: '123e5xyz' << '-7.7' ---
264ArithmeticError: Bit shift by negative number
265--- testing: '123e5xyz' << 'abc' ---
266TypeError: Unsupported operand types: string << string
267--- testing: '123e5xyz' << '123abc' ---
268int(0)
269--- testing: '123e5xyz' << '123e5' ---
270int(0)
271--- testing: '123e5xyz' << '123e5xyz' ---
272int(0)
273--- testing: '123e5xyz' << ' 123abc' ---
274int(0)
275--- testing: '123e5xyz' << '123 abc' ---
276int(0)
277--- testing: '123e5xyz' << '123abc ' ---
278int(0)
279--- testing: '123e5xyz' << '3.4a' ---
280int(98400000)
281--- testing: '123e5xyz' << 'a5.9' ---
282TypeError: Unsupported operand types: string << string
283--- testing: ' 123abc' << '0' ---
284int(123)
285--- testing: ' 123abc' << '65' ---
286int(0)
287--- testing: ' 123abc' << '-44' ---
288ArithmeticError: Bit shift by negative number
289--- testing: ' 123abc' << '1.2' ---
290int(246)
291--- testing: ' 123abc' << '-7.7' ---
292ArithmeticError: Bit shift by negative number
293--- testing: ' 123abc' << 'abc' ---
294TypeError: Unsupported operand types: string << string
295--- testing: ' 123abc' << '123abc' ---
296int(0)
297--- testing: ' 123abc' << '123e5' ---
298int(0)
299--- testing: ' 123abc' << '123e5xyz' ---
300int(0)
301--- testing: ' 123abc' << ' 123abc' ---
302int(0)
303--- testing: ' 123abc' << '123 abc' ---
304int(0)
305--- testing: ' 123abc' << '123abc ' ---
306int(0)
307--- testing: ' 123abc' << '3.4a' ---
308int(984)
309--- testing: ' 123abc' << 'a5.9' ---
310TypeError: Unsupported operand types: string << string
311--- testing: '123 abc' << '0' ---
312int(123)
313--- testing: '123 abc' << '65' ---
314int(0)
315--- testing: '123 abc' << '-44' ---
316ArithmeticError: Bit shift by negative number
317--- testing: '123 abc' << '1.2' ---
318int(246)
319--- testing: '123 abc' << '-7.7' ---
320ArithmeticError: Bit shift by negative number
321--- testing: '123 abc' << 'abc' ---
322TypeError: Unsupported operand types: string << string
323--- testing: '123 abc' << '123abc' ---
324int(0)
325--- testing: '123 abc' << '123e5' ---
326int(0)
327--- testing: '123 abc' << '123e5xyz' ---
328int(0)
329--- testing: '123 abc' << ' 123abc' ---
330int(0)
331--- testing: '123 abc' << '123 abc' ---
332int(0)
333--- testing: '123 abc' << '123abc ' ---
334int(0)
335--- testing: '123 abc' << '3.4a' ---
336int(984)
337--- testing: '123 abc' << 'a5.9' ---
338TypeError: Unsupported operand types: string << string
339--- testing: '123abc ' << '0' ---
340int(123)
341--- testing: '123abc ' << '65' ---
342int(0)
343--- testing: '123abc ' << '-44' ---
344ArithmeticError: Bit shift by negative number
345--- testing: '123abc ' << '1.2' ---
346int(246)
347--- testing: '123abc ' << '-7.7' ---
348ArithmeticError: Bit shift by negative number
349--- testing: '123abc ' << 'abc' ---
350TypeError: Unsupported operand types: string << string
351--- testing: '123abc ' << '123abc' ---
352int(0)
353--- testing: '123abc ' << '123e5' ---
354int(0)
355--- testing: '123abc ' << '123e5xyz' ---
356int(0)
357--- testing: '123abc ' << ' 123abc' ---
358int(0)
359--- testing: '123abc ' << '123 abc' ---
360int(0)
361--- testing: '123abc ' << '123abc ' ---
362int(0)
363--- testing: '123abc ' << '3.4a' ---
364int(984)
365--- testing: '123abc ' << 'a5.9' ---
366TypeError: Unsupported operand types: string << string
367--- testing: '3.4a' << '0' ---
368int(3)
369--- testing: '3.4a' << '65' ---
370int(0)
371--- testing: '3.4a' << '-44' ---
372ArithmeticError: Bit shift by negative number
373--- testing: '3.4a' << '1.2' ---
374int(6)
375--- testing: '3.4a' << '-7.7' ---
376ArithmeticError: Bit shift by negative number
377--- testing: '3.4a' << 'abc' ---
378TypeError: Unsupported operand types: string << string
379--- testing: '3.4a' << '123abc' ---
380int(0)
381--- testing: '3.4a' << '123e5' ---
382int(0)
383--- testing: '3.4a' << '123e5xyz' ---
384int(0)
385--- testing: '3.4a' << ' 123abc' ---
386int(0)
387--- testing: '3.4a' << '123 abc' ---
388int(0)
389--- testing: '3.4a' << '123abc ' ---
390int(0)
391--- testing: '3.4a' << '3.4a' ---
392int(24)
393--- testing: '3.4a' << 'a5.9' ---
394TypeError: Unsupported operand types: string << string
395--- testing: 'a5.9' << '0' ---
396TypeError: Unsupported operand types: string << string
397--- testing: 'a5.9' << '65' ---
398TypeError: Unsupported operand types: string << string
399--- testing: 'a5.9' << '-44' ---
400TypeError: Unsupported operand types: string << string
401--- testing: 'a5.9' << '1.2' ---
402TypeError: Unsupported operand types: string << string
403--- testing: 'a5.9' << '-7.7' ---
404TypeError: Unsupported operand types: string << string
405--- testing: 'a5.9' << 'abc' ---
406TypeError: Unsupported operand types: string << string
407--- testing: 'a5.9' << '123abc' ---
408TypeError: Unsupported operand types: string << string
409--- testing: 'a5.9' << '123e5' ---
410TypeError: Unsupported operand types: string << string
411--- testing: 'a5.9' << '123e5xyz' ---
412TypeError: Unsupported operand types: string << string
413--- testing: 'a5.9' << ' 123abc' ---
414TypeError: Unsupported operand types: string << string
415--- testing: 'a5.9' << '123 abc' ---
416TypeError: Unsupported operand types: string << string
417--- testing: 'a5.9' << '123abc ' ---
418TypeError: Unsupported operand types: string << string
419--- testing: 'a5.9' << '3.4a' ---
420TypeError: Unsupported operand types: string << string
421--- testing: 'a5.9' << 'a5.9' ---
422TypeError: Unsupported operand types: string << string
423