File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed
tests/PHPStan/Analyser/nsrt Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff 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 {}
You can’t perform that action at this time.
0 commit comments