File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
tests/PHPStan/Analyser/nsrt Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 22
33namespace PipeOperatorTypes ;
44
5+ use stdClass ;
56use function PHPStan \Testing \assertType ;
67
78class Foo
@@ -223,4 +224,26 @@ public function testConditional(): void
223224 assertType ('int ' , 'foo ' |> fn ($ x ) => $ this ->doConditional ($ x ));
224225 }
225226
227+ /**
228+ * @template T
229+ * @param T $input
230+ * @return T
231+ */
232+ public function doGenerics ($ input )
233+ {
234+ return $ t ;
235+ }
236+
237+ public function testGenerics (): void
238+ {
239+ assertType (stdClass::class, new stdClass () |> $ this ->doGenerics (...));
240+ assertType (stdClass::class, new stdClass () |> $ this ->doGenerics (...));
241+
242+ assertType (stdClass::class, new stdClass () |> fn ($ x ) => $ this ->doGenerics ($ x ));
243+ assertType (stdClass::class, new stdClass () |> fn ($ x ) => $ this ->doGenerics ($ x ));
244+
245+ assertType ('null ' , null |> $ this ->doConditional (...) |> $ this ->doGenerics (...));
246+ assertType ('int ' , 'foo ' |> $ this ->doConditional (...) |> $ this ->doGenerics (...));
247+ }
248+
226249}
You can’t perform that action at this time.
0 commit comments