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