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()
403403 /**
404404 * Transform each item in the slice of items using a callback.
405405 *
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>
408412 */
409413 public function through (callable $ callback )
410414 {
Original file line number Diff line number Diff line change 4949foreach ($ cursorPaginator as $ post ) {
5050 assertType ('Post ' , $ post );
5151}
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