18
18
use InvalidArgumentException ;
19
19
use RuntimeException ;
20
20
21
+ /**
22
+ * @template TValue
23
+ *
24
+ * @mixin \Illuminate\Database\Eloquent\Builder
25
+ * @mixin \Illuminate\Database\Query\Builder
26
+ */
21
27
trait BuildsQueries
22
28
{
23
29
use Conditionable;
@@ -26,7 +32,7 @@ trait BuildsQueries
26
32
* Chunk the results of the query.
27
33
*
28
34
* @param int $count
29
- * @param callable $callback
35
+ * @param callable(\Illuminate\Support\Collection<int, TValue>, int): mixed $callback
30
36
* @return bool
31
37
*/
32
38
public function chunk ($ count , callable $ callback )
@@ -65,9 +71,11 @@ public function chunk($count, callable $callback)
65
71
/**
66
72
* Run a map over each item while chunking.
67
73
*
68
- * @param callable $callback
74
+ * @template TReturn
75
+ *
76
+ * @param callable(TValue): TReturn $callback
69
77
* @param int $count
70
- * @return \Illuminate\Support\Collection
78
+ * @return \Illuminate\Support\Collection<int, TReturn>
71
79
*/
72
80
public function chunkMap (callable $ callback , $ count = 1000 )
73
81
{
@@ -85,7 +93,7 @@ public function chunkMap(callable $callback, $count = 1000)
85
93
/**
86
94
* Execute a callback over each item while chunking.
87
95
*
88
- * @param callable $callback
96
+ * @param callable(TValue, int): mixed $callback
89
97
* @param int $count
90
98
* @return bool
91
99
*
@@ -106,7 +114,7 @@ public function each(callable $callback, $count = 1000)
106
114
* Chunk the results of a query by comparing IDs.
107
115
*
108
116
* @param int $count
109
- * @param callable $callback
117
+ * @param callable(\Illuminate\Support\Collection<int, TValue>, int): mixed $callback
110
118
* @param string|null $column
111
119
* @param string|null $alias
112
120
* @return bool
@@ -120,7 +128,7 @@ public function chunkById($count, callable $callback, $column = null, $alias = n
120
128
* Chunk the results of a query by comparing IDs in descending order.
121
129
*
122
130
* @param int $count
123
- * @param callable $callback
131
+ * @param callable(\Illuminate\Support\Collection<int, TValue>, int): mixed $callback
124
132
* @param string|null $column
125
133
* @param string|null $alias
126
134
* @return bool
@@ -134,7 +142,7 @@ public function chunkByIdDesc($count, callable $callback, $column = null, $alias
134
142
* Chunk the results of a query by comparing IDs in a given order.
135
143
*
136
144
* @param int $count
137
- * @param callable $callback
145
+ * @param callable(\Illuminate\Support\Collection<int, TValue>, int): mixed $callback
138
146
* @param string|null $column
139
147
* @param string|null $alias
140
148
* @param bool $descending
@@ -194,7 +202,7 @@ public function orderedChunkById($count, callable $callback, $column = null, $al
194
202
/**
195
203
* Execute a callback over each item while chunking by ID.
196
204
*
197
- * @param callable $callback
205
+ * @param callable(TValue, int): mixed $callback
198
206
* @param int $count
199
207
* @param string|null $column
200
208
* @param string|null $alias
@@ -328,7 +336,7 @@ protected function orderedLazyById($chunkSize = 1000, $column = null, $alias = n
328
336
* Execute the query and get the first result.
329
337
*
330
338
* @param array|string $columns
331
- * @return \Illuminate\Database\Eloquent\Model|object|static |null
339
+ * @return TValue |null
332
340
*/
333
341
public function first ($ columns = ['* ' ])
334
342
{
@@ -339,7 +347,7 @@ public function first($columns = ['*'])
339
347
* Execute the query and get the first result if it's the sole matching record.
340
348
*
341
349
* @param array|string $columns
342
- * @return \Illuminate\Database\Eloquent\Model|object|static|null
350
+ * @return TValue
343
351
*
344
352
* @throws \Illuminate\Database\RecordsNotFoundException
345
353
* @throws \Illuminate\Database\MultipleRecordsFoundException
@@ -463,7 +471,7 @@ protected function paginateUsingCursor($perPage, $columns = ['*'], $cursorName =
463
471
/**
464
472
* Get the original column name of the given column, without any aliasing.
465
473
*
466
- * @param \Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder $builder
474
+ * @param \Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder<*> $builder
467
475
* @param string $parameter
468
476
* @return string
469
477
*/
0 commit comments