1--TEST--
2Implicit float to int conversions should not warn for variables if float has a fractional part equal to 0
3--FILE--
4<?php
5
6echo 'Bitwise ops:' . \PHP_EOL;
7
8$float = 1.0;
9
10$var = ~$float;
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 >> 3;
26var_dump($var);
27
28$var = $float;
29$var <<= 3;
30var_dump($var);
31
32$var = $float;
33$var >>= 3;
34var_dump($var);
35
36$var = 3 << $float;
37var_dump($var);
38
39$var = 3 >> $float;
40var_dump($var);
41
42echo 'Modulo:' . \PHP_EOL;
43$modFloat = 6.0;
44$var = $modFloat % 2;
45var_dump($var);
46
47$modFloat = 2.0;
48$var = 9 % $modFloat;
49var_dump($var);
50
51echo 'Offset access:' . \PHP_EOL;
52$offsetAccess = 2.0;
53echo 'Arrays:' . \PHP_EOL;
54$array = ['a', 'b', 'c'];
55var_dump($array[$float]);
56$array[$offsetAccess] = 'z';
57var_dump($array);
58
59echo 'Function calls:' . \PHP_EOL;
60function foo(int $a) {
61    return $a;
62}
63var_dump(foo($float));
64
65$cp = 60.0;
66var_dump(chr($cp));
67
68echo 'Function returns:' . \PHP_EOL;
69function bar(): int {
70    $var = 3.0;
71    return $var;
72}
73var_dump(bar());
74
75echo 'Typed property assignment:' . \PHP_EOL;
76class Test {
77    public int $a;
78}
79
80$instance = new Test();
81$instance->a = $float;
82var_dump($instance->a);
83
84?>
85--EXPECT--
86Bitwise ops:
87int(-2)
88int(3)
89int(1)
90int(2)
91int(8)
92int(0)
93int(8)
94int(0)
95int(6)
96int(1)
97Modulo:
98int(0)
99int(1)
100Offset access:
101Arrays:
102string(1) "b"
103array(3) {
104  [0]=>
105  string(1) "a"
106  [1]=>
107  string(1) "b"
108  [2]=>
109  string(1) "z"
110}
111Function calls:
112int(1)
113string(1) "<"
114Function returns:
115int(3)
116Typed property assignment:
117int(1)
118