29
29
use Cake \Collection \CollectionTrait ;
30
30
use Cake \Core \InstanceConfigTrait ;
31
31
use Cake \Datasource \ResultSetInterface ;
32
- use Cake \ORM \Query ;
32
+ use Cake \ORM \Query \SelectQuery ;
33
+ use ReturnTypeWillChange ;
33
34
use RuntimeException ;
34
35
35
36
class ResultSet implements ResultSetInterface
@@ -42,70 +43,70 @@ class ResultSet implements ResultSetInterface
42
43
*
43
44
* @var mixed
44
45
*/
45
- protected $ current ;
46
+ protected mixed $ current ;
46
47
47
48
/**
48
49
* Query instance.
49
50
*
50
- * @var \Cake\ORM\Query
51
+ * @var \Cake\ORM\Query\SelectQuery
51
52
*/
52
- protected $ query ;
53
+ protected SelectQuery $ query ;
53
54
54
55
/**
55
56
* Current chunk size.
56
57
*
57
58
* @var int
58
59
*/
59
- protected $ chunkSize = 0 ;
60
+ protected int $ chunkSize = 0 ;
60
61
61
62
/**
62
63
* Current chunk index.
63
64
*
64
65
* @var int
65
66
*/
66
- protected $ chunkIndex = 0 ;
67
+ protected int $ chunkIndex = 0 ;
67
68
68
69
/**
69
70
* Current chunk content.
70
71
*
71
- * @var array
72
+ * @var array<int, mixed>
72
73
*/
73
- protected $ chunk ;
74
+ protected array $ chunk ;
74
75
75
76
/**
76
77
* Current element index.
77
78
*
78
79
* @var int
79
80
*/
80
- protected $ index = 0 ;
81
+ protected int $ index = 0 ;
81
82
82
83
/**
83
84
* Current page.
84
85
*
85
86
* @var int
86
87
*/
87
- protected $ page = 0 ;
88
+ protected int $ page = 0 ;
88
89
89
90
/**
90
91
* Original query offset.
91
92
*
92
- * @var int
93
+ * @var ? int
93
94
*/
94
- protected $ offset ;
95
+ protected ? int $ offset ;
95
96
96
97
/**
97
98
* Original query limit.
98
99
*
99
- * @var int
100
+ * @var ? int
100
101
*/
101
- protected $ limit ;
102
+ protected ? int $ limit ;
102
103
103
104
/**
104
105
* Total count.
105
106
*
106
107
* @var int
107
108
*/
108
- protected $ count ;
109
+ protected int $ count ;
109
110
110
111
/**
111
112
* Default config.
@@ -114,18 +115,18 @@ class ResultSet implements ResultSetInterface
114
115
*
115
116
* @var array
116
117
*/
117
- protected $ _defaultConfig = [
118
+ protected array $ _defaultConfig = [
118
119
'size ' => 1000 ,
119
120
];
120
121
121
122
/**
122
123
* Constructor.
123
124
*
124
- * @param \Cake\ORM\Query $query Query object.
125
+ * @param \Cake\ORM\Query\SelectQuery $query Query object.
125
126
* @param array $config Configuration.
126
127
* @throws \RuntimeException When query is not supported.
127
128
*/
128
- public function __construct (Query $ query , array $ config = [])
129
+ public function __construct (SelectQuery $ query , array $ config = [])
129
130
{
130
131
$ type = $ query ->type ();
131
132
if ($ type !== 'select ' ) {
@@ -144,17 +145,17 @@ public function __construct(Query $query, array $config = [])
144
145
/**
145
146
* @inheritDoc
146
147
*/
147
- #[\ ReturnTypeWillChange]
148
- public function current ()
148
+ #[ReturnTypeWillChange]
149
+ public function current (): mixed
149
150
{
150
151
return $ this ->current ;
151
152
}
152
153
153
154
/**
154
155
* @inheritDoc
155
156
*/
156
- #[\ ReturnTypeWillChange]
157
- public function key ()
157
+ #[ReturnTypeWillChange]
158
+ public function key (): mixed
158
159
{
159
160
return $ this ->index ;
160
161
}
@@ -215,7 +216,7 @@ public function valid(): bool
215
216
*
216
217
* @return void
217
218
*/
218
- protected function fetchChunk ()
219
+ protected function fetchChunk (): void
219
220
{
220
221
$ size = $ this ->getConfig ('size ' );
221
222
@@ -251,12 +252,12 @@ public function count(): int
251
252
*
252
253
* Serialization is not supported (yet). *
253
254
*/
254
- public function serialize ()
255
+ public function serialize (): never
255
256
{
256
257
throw new RuntimeException ('You cannot serialize this result set. ' );
257
258
}
258
259
259
- public function __serialize (): array
260
+ public function __serialize (): never
260
261
{
261
262
throw new RuntimeException ('You cannot serialize this result set. ' );
262
263
}
@@ -266,12 +267,12 @@ public function __serialize(): array
266
267
*
267
268
* Serialization is not supported (yet). *
268
269
*/
269
- public function unserialize ($ serialized )
270
+ public function unserialize (string $ serialized ): never
270
271
{
271
272
throw new RuntimeException ('You cannot unserialize this result set. ' );
272
273
}
273
274
274
- public function __unserialize (array $ data ): void
275
+ public function __unserialize (array $ data ): never
275
276
{
276
277
throw new RuntimeException ('You cannot unserialize this result set. ' );
277
278
}
0 commit comments