1--TEST-- 2Implicit float to int conversions should not warn for literals if float has a fractional part equal to 0 3--FILE-- 4<?php 5 6echo 'Bitwise ops:' . \PHP_EOL; 7$var = ~1.0; 8var_dump($var); 9$var = 1.0|3; 10var_dump($var); 11$var = 1.0&3; 12var_dump($var); 13$var = 1.0^3; 14var_dump($var); 15$var = 1.0 << 3; 16var_dump($var); 17$var = 1.0 >> 3; 18var_dump($var); 19$var = 3 << 1.0; 20var_dump($var); 21$var = 3 >> 1.0; 22var_dump($var); 23 24echo 'Modulo:' . \PHP_EOL; 25$var = 6.0 % 2; 26var_dump($var); 27$var = 9 % 2.0; 28var_dump($var); 29 30echo 'Offset access:' . \PHP_EOL; 31echo 'Arrays:' . \PHP_EOL; 32$array = ['a', 'b', 'c']; 33var_dump($array[1.0]); 34$array[2.0] = 'z'; 35var_dump($array); 36 37/* Strings are handled differently and always warn on non integer keys */ 38 39echo 'Function calls:' . \PHP_EOL; 40function foo(int $a) { 41 return $a; 42} 43var_dump(foo(1.0)); 44 45var_dump(chr(60.0)); 46 47echo 'Function returns:' . \PHP_EOL; 48function bar(): int { 49 return 3.0; 50} 51var_dump(bar()); 52 53echo 'Typed property assignment:' . \PHP_EOL; 54class Test { 55 public int $a; 56} 57 58$instance = new Test(); 59$instance->a = 1.0; 60var_dump($instance->a); 61 62?> 63--EXPECT-- 64Bitwise ops: 65int(-2) 66int(3) 67int(1) 68int(2) 69int(8) 70int(0) 71int(6) 72int(1) 73Modulo: 74int(0) 75int(1) 76Offset access: 77Arrays: 78string(1) "b" 79array(3) { 80 [0]=> 81 string(1) "a" 82 [1]=> 83 string(1) "b" 84 [2]=> 85 string(1) "z" 86} 87Function calls: 88int(1) 89string(1) "<" 90Function returns: 91int(3) 92Typed property assignment: 93int(1) 94