Skip to content

Commit 98e5212

Browse files
committed
Add various missing types
1 parent d90d60d commit 98e5212

File tree

9 files changed

+228
-15
lines changed

9 files changed

+228
-15
lines changed

src/ASTConverter/ASTConverter.php

Lines changed: 145 additions & 15 deletions
Large diffs are not rendered by default.

test_files/src/0299_binary_op.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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+
}

test_files/src/continue.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
while (1) {
3+
if ($x) {
4+
continue;
5+
} elseif ($y) {
6+
break;
7+
} elseif (4) {
8+
continue 1;
9+
} else {
10+
break 1;
11+
}
12+
}

test_files/src/inheritance.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
class A extends MyNS\B implements ArrayAccess, Traversable, MyNS\MyInterface{
3+
}

test_files/src/isset.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php isset($x);
2+
isset($a, $b['a']);
3+
isset($a, $b, $c, $d);

test_files/src/not.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
!0;
3+
!$x;
4+
-$x;
5+
+$x;
6+
~$x;

test_files/src/script.php

100755100644
File mode changed.

test_files/src/switch.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php
2+
switch($x) {}
3+
switch($x) {case 2: default:}
4+
switch($x) {case 2: $y = 3;}

test_files/src/throw.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?php
2+
throw new \RuntimeException("An exception");

0 commit comments

Comments
 (0)