Skip to content

Commit 942f48a

Browse files
committed
added failling tests
1 parent dd8c05b commit 942f48a

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

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

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,75 @@ 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+
<<<<<<< Updated upstream
49+
if (assertIfTemplated($v, true)) {
50+
assertType('true', $v);
51+
}
52+
53+
$v = getMixed();
54+
if ($f1($v, true)) {
55+
assertType('true', $v);
56+
}
57+
58+
$v = getMixed();
59+
if ($f2($v, true)) {
60+
assertType('true', $v);
61+
}
62+
63+
$v = getMixed();
64+
if (assertIfTemplated($v, false)) {
65+
assertType('false', $v);
66+
}
67+
68+
$v = getMixed();
69+
if ($f1($v, false)) {
70+
assertType('false', $v);
71+
}
72+
73+
$v = getMixed();
74+
if ($f2($v, false)) {
75+
assertType('false', $v);
76+
}
77+
=======
78+
assertIfTemplated($v, true);
79+
assertType('true', $v);
80+
81+
$v = getMixed();
82+
$f1($v, true);
83+
assertType('true', $v);
84+
85+
$v = getMixed();
86+
$f2($v, true);
87+
assertType('true', $v);
88+
89+
$v = getMixed();
90+
assertIfTemplated($v, false);
91+
assertType('false', $v);
92+
93+
$v = getMixed();
94+
$f1($v, false);
95+
assertType('false', $v);
96+
97+
$v = getMixed();
98+
$f2($v, false);
99+
assertType('false', $v);
100+
>>>>>>> Stashed changes
101+
}
102+
103+
function getMixed(): mixed {}

0 commit comments

Comments
 (0)