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