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