20
20
* @extends Traversable<TKey,TValue>
21
21
* @extends Arrayable<TKey,TValue|mixed[]>
22
22
*/
23
- interface CollectionInterface extends
23
+ interface DictionaryInterface extends
24
24
ArrayAccess,
25
25
Countable,
26
26
JsonSerializable,
@@ -103,14 +103,6 @@ public function get($key);
103
103
*/
104
104
public function unset ($ key );
105
105
106
- /**
107
- * Add an item
108
- *
109
- * @param TValue $value
110
- * @return static<TKey|int,TValue>
111
- */
112
- public function add ($ value );
113
-
114
106
/**
115
107
* Merge the collection with the given items
116
108
*
@@ -138,18 +130,16 @@ public function reverse();
138
130
*
139
131
* The callback's return values are discarded.
140
132
*
141
- * @template TMode of int-mask-of<CollectionInterface::*>
142
- *
143
133
* @param (callable(TValue, TValue|null $next, TValue|null $prev): mixed)|(callable(TKey, TKey|null $next, TKey|null $prev): mixed)|(callable(array{TKey,TValue}, array{TKey,TValue}|null $next, array{TKey,TValue}|null $prev): mixed) $callback
144
134
* @phpstan-param (
145
- * TMode is 3|11|19
135
+ * $mode is 3|11|19
146
136
* ? (callable(array{TKey,TValue}, array{TKey,TValue}|null $next, array{TKey,TValue}|null $prev): mixed)
147
- * : (TMode is 2|10|18
137
+ * : ($mode is 2|10|18
148
138
* ? (callable(TKey, TKey|null $next, TKey|null $prev): mixed)
149
139
* : (callable(TValue, TValue|null $next, TValue|null $prev): mixed)
150
140
* )
151
141
* ) $callback
152
- * @param TMode $mode
142
+ * @param int-mask-of<CollectionInterface::*> $mode
153
143
* @return $this
154
144
*/
155
145
public function forEach (callable $ callback , int $ mode = CollectionInterface::CALLBACK_USE_VALUE );
@@ -158,38 +148,35 @@ public function forEach(callable $callback, int $mode = CollectionInterface::CAL
158
148
* Pass each item in the collection to a callback and populate a new
159
149
* collection with its return values
160
150
*
161
- * @template TMode of int-mask-of<CollectionInterface::*>
162
151
* @template TReturn of TValue
163
152
*
164
153
* @param (callable(TValue, TValue|null $next, TValue|null $prev): TReturn)|(callable(TKey, TKey|null $next, TKey|null $prev): TReturn)|(callable(array{TKey,TValue}, array{TKey,TValue}|null $next, array{TKey,TValue}|null $prev): TReturn) $callback
165
154
* @phpstan-param (
166
- * TMode is 3|11|19
155
+ * $mode is 3|11|19
167
156
* ? (callable(array{TKey,TValue}, array{TKey,TValue}|null $next, array{TKey,TValue}|null $prev): TReturn)
168
- * : (TMode is 2|10|18
157
+ * : ($mode is 2|10|18
169
158
* ? (callable(TKey, TKey|null $next, TKey|null $prev): TReturn)
170
159
* : (callable(TValue, TValue|null $next, TValue|null $prev): TReturn)
171
160
* )
172
161
* ) $callback
173
- * @param TMode $mode
162
+ * @param int-mask-of<CollectionInterface::*> $mode
174
163
* @return static<TKey,TReturn>
175
164
*/
176
165
public function map (callable $ callback , int $ mode = CollectionInterface::CALLBACK_USE_VALUE );
177
166
178
167
/**
179
168
* Reduce the collection to items that satisfy a callback
180
169
*
181
- * @template TMode of int-mask-of<CollectionInterface::*>
182
- *
183
170
* @param (callable(TValue, TValue|null $next, TValue|null $prev): bool)|(callable(TKey, TKey|null $next, TKey|null $prev): bool)|(callable(array{TKey,TValue}, array{TKey,TValue}|null $next, array{TKey,TValue}|null $prev): bool) $callback
184
171
* @phpstan-param (
185
- * TMode is 3|11|19
172
+ * $mode is 3|11|19
186
173
* ? (callable(array{TKey,TValue}, array{TKey,TValue}|null $next, array{TKey,TValue}|null $prev): bool)
187
- * : (TMode is 2|10|18
174
+ * : ($mode is 2|10|18
188
175
* ? (callable(TKey, TKey|null $next, TKey|null $prev): bool)
189
176
* : (callable(TValue, TValue|null $next, TValue|null $prev): bool)
190
177
* )
191
178
* ) $callback
192
- * @param TMode $mode
179
+ * @param int-mask-of<CollectionInterface::*> $mode
193
180
* @return static
194
181
*/
195
182
public function filter (callable $ callback , int $ mode = CollectionInterface::CALLBACK_USE_VALUE );
@@ -198,19 +185,17 @@ public function filter(callable $callback, int $mode = CollectionInterface::CALL
198
185
* Get the first item that satisfies a callback, or null if there is no such
199
186
* item in the collection
200
187
*
201
- * @template TMode of int-mask-of<CollectionInterface::*>
202
- *
203
188
* @param (callable(TValue, TValue|null $next, TValue|null $prev): bool)|(callable(TKey, TKey|null $next, TKey|null $prev): bool)|(callable(array{TKey,TValue}, array{TKey,TValue}|null $next, array{TKey,TValue}|null $prev): bool) $callback
204
189
* @phpstan-param (
205
- * TMode is 3|11|19
190
+ * $mode is 3|11|19
206
191
* ? (callable(array{TKey,TValue}, array{TKey,TValue}|null $next, array{TKey,TValue}|null $prev): bool)
207
- * : (TMode is 2|10|18
192
+ * : ($mode is 2|10|18
208
193
* ? (callable(TKey, TKey|null $next, TKey|null $prev): bool)
209
194
* : (callable(TValue, TValue|null $next, TValue|null $prev): bool)
210
195
* )
211
196
* ) $callback
212
- * @param TMode $mode
213
- * @return (TMode is 16|17|18|19 ? TKey : TValue)|null
197
+ * @param int-mask-of<CollectionInterface::*> $mode
198
+ * @return ($mode is 16|17|18|19 ? TKey : TValue)|null
214
199
*/
215
200
public function find (callable $ callback , int $ mode = CollectionInterface::CALLBACK_USE_VALUE | CollectionInterface::FIND_VALUE );
216
201
@@ -313,14 +298,6 @@ public function last();
313
298
*/
314
299
public function nth (int $ n );
315
300
316
- /**
317
- * Push items onto the end of the collection
318
- *
319
- * @param TValue ...$items
320
- * @return static<TKey|int,TValue>
321
- */
322
- public function push (...$ items );
323
-
324
301
/**
325
302
* Pop an item off the end of the collection
326
303
*
@@ -338,14 +315,4 @@ public function pop(&$last = null);
338
315
* @return static
339
316
*/
340
317
public function shift (&$ first = null );
341
-
342
- /**
343
- * Add items to the beginning of the collection
344
- *
345
- * Items are added in one operation and stay in the given order.
346
- *
347
- * @param TValue ...$items
348
- * @return static<TKey|int,TValue>
349
- */
350
- public function unshift (...$ items );
351
318
}
0 commit comments