Skip to content

Commit 8134a13

Browse files
committed
more tests
1 parent aa8d2a5 commit 8134a13

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

tests/PHPStan/Analyser/nsrt/bug-5051.php

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,46 @@ public function test(?object $data): void
2121

2222
if ($update) {
2323
assertType('object', $data);
24+
assertType("'baz'", $foo);
25+
} else {
26+
assertType('null', $data);
27+
assertType("'bar'", $foo);
2428
}
29+
assertType('object|null', $data);
30+
assertType("'bar'|'baz'", $foo);
2531
}
2632

27-
public function testWithBooleans(?object $data): void
33+
/**
34+
* @param 1|2|3|10 $data
35+
*/
36+
public function testWithBooleans($data): void
2837
{
29-
if ($data === null) {
38+
$foo = 1;
39+
if ($data === 1 || $data === 2) {
3040
$update = false;
3141
$foo = false;
42+
} elseif ($data === 3) {
43+
$update = false;
44+
$foo = true;
3245
} else {
3346
$update = true;
3447
$foo = true;
3548
}
3649

3750
if ($update) {
38-
assertType('object', $data);
51+
assertType('10', $data);
52+
assertType('bool', $foo);
53+
} else {
54+
assertType('1|2|3', $data);
55+
assertType('bool', $foo);
56+
}
57+
58+
if ($foo) {
59+
assertType('1|2|3|10', $data);
60+
assertType('bool', $update);
61+
} else {
62+
assertType('1|2|3|10', $data);
63+
assertType('bool', $update);
3964
}
4065
}
4166

tests/PHPStan/Analyser/nsrt/bug-5058.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public function doSomething(mixed $string): void
1616
$errors['string'] = 'fail';
1717
}
1818

19+
assertType('mixed', $string);
1920
if(empty($errors) === false){
2021
throw new Exception('Epic fail');
2122
}

0 commit comments

Comments
 (0)