File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -403,8 +403,12 @@ public function items()
403
403
/**
404
404
* Transform each item in the slice of items using a callback.
405
405
*
406
- * @param callable $callback
407
- * @return $this
406
+ * @template TThroughValue
407
+ *
408
+ * @param callable(TValue, TKey): TThroughValue $callback
409
+ * @return $this<TKey, TThroughValue>
410
+ *
411
+ * @phpstan-this-out static<TKey, TThroughValue>
408
412
*/
409
413
public function through (callable $ callback )
410
414
{
Original file line number Diff line number Diff line change 49
49
foreach ($ cursorPaginator as $ post ) {
50
50
assertType ('Post ' , $ post );
51
51
}
52
+
53
+ $ throughPaginator = clone $ cursorPaginator ;
54
+ $ throughPaginator ->through (function ($ post , $ key ): array {
55
+ assertType ('int ' , $ key );
56
+ assertType ('Post ' , $ post );
57
+
58
+ return [
59
+ 'id ' => $ key ,
60
+ 'post ' => $ post ,
61
+ ];
62
+ });
63
+
64
+ assertType ('Illuminate\Pagination\CursorPaginator<int, array{id: int, post: Post}> ' , $ throughPaginator );
You can’t perform that action at this time.
0 commit comments