Skip to content

Commit 7467880

Browse files
committed
added failling tests
1 parent dd8c05b commit 7467880

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,44 @@ function f(mixed $v): void {
2929
assertType('int<1, max>', $v);
3030
}
3131
}
32+
33+
34+
/**
35+
* @template T of bool
36+
* @param T $if
37+
* @phpstan-assert (T is true ? true : false) $condition
38+
*/
39+
function assertIfTemplated(mixed $condition, bool $if)
40+
{
41+
}
42+
43+
function doTemplated(): void {
44+
$f1 = assertIfTemplated(...);
45+
$f2 = 'Bug14249\assertIfTemplated';
46+
47+
$v = getMixed();
48+
assertIfTemplated($v, true);
49+
assertType('true', $v);
50+
51+
$v = getMixed();
52+
$f1($v, true);
53+
assertType('true', $v);
54+
55+
$v = getMixed();
56+
$f2($v, true);
57+
assertType('true', $v);
58+
59+
$v = getMixed();
60+
assertIfTemplated($v, false);
61+
assertType('false', $v);
62+
63+
$v = getMixed();
64+
$f1($v, false);
65+
assertType('false', $v);
66+
67+
$v = getMixed();
68+
$f2($v, false);
69+
assertType('false', $v);
70+
}
71+
72+
function getMixed(): mixed {}

0 commit comments

Comments
 (0)