1--TEST--
2Implicit float string to int conversions should warn for variables
3--FILE--
4<?php
5
6echo 'Bitwise ops:' . \PHP_EOL;
7
8$float = '1.5';
9
10$var = $float|3;
11var_dump($var);
12
13$var = $float&3;
14var_dump($var);
15
16$var = $float^3;
17var_dump($var);
18
19$var = $float << 3;
20var_dump($var);
21
22$var = $float >> 3;
23var_dump($var);
24
25$var = $float;
26$var <<= 3;
27var_dump($var);
28
29$var = $float;
30$var >>= 3;
31var_dump($var);
32
33$var = 3 << $float;
34var_dump($var);
35
36$var = 3 >> $float;
37var_dump($var);
38
39echo 'Modulo:' . \PHP_EOL;
40$modFloat = '6.5';
41$var = $modFloat % 2;
42var_dump($var);
43
44$modFloat = '2.5';
45$var = 9 % $modFloat;
46var_dump($var);
47
48echo 'Function calls:' . \PHP_EOL;
49function foo(int $a) {
50    return $a;
51}
52var_dump(foo($float));
53
54$cp = '60.5';
55var_dump(chr($cp));
56
57echo 'Function returns:' . \PHP_EOL;
58function bar(): int {
59    $var = '3.5';
60    return $var;
61}
62var_dump(bar());
63
64echo 'Typed property assignment:' . \PHP_EOL;
65class Test {
66    public int $a;
67}
68
69$instance = new Test();
70$instance->a = $float;
71var_dump($instance->a);
72
73?>
74--EXPECTF--
75Bitwise ops:
76
77Deprecated: Implicit conversion from float-string "1.5" to int loses precision in %s on line %d
78int(3)
79
80Deprecated: Implicit conversion from float-string "1.5" to int loses precision in %s on line %d
81int(1)
82
83Deprecated: Implicit conversion from float-string "1.5" to int loses precision in %s on line %d
84int(2)
85
86Deprecated: Implicit conversion from float-string "1.5" to int loses precision in %s on line %d
87int(8)
88
89Deprecated: Implicit conversion from float-string "1.5" to int loses precision in %s on line %d
90int(0)
91
92Deprecated: Implicit conversion from float-string "1.5" to int loses precision in %s on line %d
93int(8)
94
95Deprecated: Implicit conversion from float-string "1.5" to int loses precision in %s on line %d
96int(0)
97
98Deprecated: Implicit conversion from float-string "1.5" to int loses precision in %s on line %d
99int(6)
100
101Deprecated: Implicit conversion from float-string "1.5" to int loses precision in %s on line %d
102int(1)
103Modulo:
104
105Deprecated: Implicit conversion from float-string "6.5" to int loses precision in %s on line %d
106int(0)
107
108Deprecated: Implicit conversion from float-string "2.5" to int loses precision in %s on line %d
109int(1)
110Function calls:
111
112Deprecated: Implicit conversion from float-string "1.5" to int loses precision in %s on line %d
113int(1)
114
115Deprecated: Implicit conversion from float-string "60.5" to int loses precision in %s on line %d
116string(1) "<"
117Function returns:
118
119Deprecated: Implicit conversion from float-string "3.5" to int loses precision in %s on line %d
120int(3)
121Typed property assignment:
122
123Deprecated: Implicit conversion from float-string "1.5" to int loses precision in %s on line %d
124int(1)
125