|
| 1 | +<?php declare(strict_types=1); |
| 2 | + |
| 3 | +function expect_string_298(string $x) {} |
| 4 | +function expect_int_298(int $x) {} |
| 5 | + |
| 6 | +function test298() { |
| 7 | + expect_string_298("0" + "1"); // warn |
| 8 | + expect_string_298("0" | "1"); // warn |
| 9 | + expect_string_298("0" ^ "\x01"); // Becomes a string |
| 10 | + expect_int_298("0" ^ "\x01"); // warn, Becomes a string |
| 11 | + expect_string_298(1 ^ 2); // warn |
| 12 | + expect_string_298(1 xor 2); // warn |
| 13 | + expect_int_298("0" || "1"); // warn |
| 14 | + expect_int_298("0" or "1"); // warn |
| 15 | + expect_int_298("0" . "1"); // warn |
| 16 | + expect_string_298(4 / 2); // warn |
| 17 | + expect_string_298(4 == 2); // warn |
| 18 | + expect_string_298(4 === 2); // warn |
| 19 | + expect_string_298(4 != 2); // warn |
| 20 | + expect_string_298(4 !== 2); // warn |
| 21 | + expect_string_298(4 < 2); // warn |
| 22 | + expect_string_298(4 <= 2); // warn |
| 23 | + expect_string_298(4 * 7); // warn |
| 24 | + expect_string_298(4 % 7); // warn |
| 25 | + expect_string_298(4 ** 7); // warn, pow |
| 26 | + expect_string_298(4 << 1); // warn |
| 27 | + expect_string_298(4 >> 1); // warn |
| 28 | + expect_string_298(4 <=> 2); // warn |
| 29 | + expect_int_298(4 <=> 2); // good |
| 30 | + expect_string_298(4 - 2); // warn |
| 31 | + expect_string_298(4 & 7); // warn |
| 32 | + expect_string_298(4 | 7); // warn |
| 33 | + expect_string_298(4 ?? 7); // warn |
| 34 | + expect_string_298(4 > 7); // warn |
| 35 | + expect_string_298(4 >= 7); // warn |
| 36 | + |
| 37 | + $strVar = 'x'; |
| 38 | + $intVar = 42; |
| 39 | + expect_int_298($strVar .= 'suffix'); |
| 40 | + expect_string_298($intVar ^= 2); // warn, this is an int |
| 41 | + expect_int_298($strVar ^= "\x01\x02"); // warn, this is a string |
| 42 | + expect_string_298($intVar |= 1); |
| 43 | + expect_string_298($intVar ^= 2); |
| 44 | + expect_string_298($intVar &= 0xffff); |
| 45 | + expect_string_298($intVar /= 2); |
| 46 | + expect_string_298($intVar *= 2); |
| 47 | + expect_string_298($intVar **= 2); |
| 48 | + expect_string_298($intVar %= 5); |
| 49 | + expect_string_298($intVar += 2); |
| 50 | + expect_string_298($intVar -= 5); |
| 51 | + expect_string_298($intVar <<= 1); |
| 52 | + expect_string_298($intVar >>= 1); |
| 53 | +} |
0 commit comments