File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -368,9 +368,11 @@ function windows_os()
368
368
/**
369
369
* Return the given value, optionally passed through the given callback.
370
370
*
371
- * @param mixed $value
372
- * @param callable|null $callback
373
- * @return mixed
371
+ * @template TValue
372
+ *
373
+ * @param TValue $value
374
+ * @param (callable(TValue): TValue)|null $callback
375
+ * @return TValue
374
376
*/
375
377
function with ($ value , callable $ callback = null )
376
378
{
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use function PHPStan \Testing \assertType ;
4
+
5
+ assertType ('User ' , with (new User ()));
6
+ assertType ('bool ' , with (new User ())->save ());
7
+ assertType ('User ' , with (new User (), function (User $ user ) {
8
+ return $ user ;
9
+ }));
10
+
11
+ assertType ('int|User ' , with (new User (), function ($ user ) {
12
+ assertType ('int|User ' , $ user );
13
+
14
+ return 10 ;
15
+ }));
You can’t perform that action at this time.
0 commit comments