Skip to content

Commit cb0a806

Browse files
committed
added failling tests
1 parent dd8c05b commit cb0a806

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

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

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,50 @@ 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+
if (assertIfTemplated($v, true)) {
49+
assertType('true', $v);
50+
}
51+
52+
$v = getMixed();
53+
if ($f1($v, true)) {
54+
assertType('true', $v);
55+
}
56+
57+
$v = getMixed();
58+
if ($f2($v, true)) {
59+
assertType('true', $v);
60+
}
61+
62+
$v = getMixed();
63+
if (assertIfTemplated($v, false)) {
64+
assertType('false', $v);
65+
}
66+
67+
$v = getMixed();
68+
if ($f1($v, false)) {
69+
assertType('false', $v);
70+
}
71+
72+
$v = getMixed();
73+
if ($f2($v, false)) {
74+
assertType('false', $v);
75+
}
76+
}
77+
78+
function getMixed(): mixed {}

0 commit comments

Comments
 (0)