@@ -38,7 +38,10 @@ public static function __set_state(array $properties): self
38
38
* its keys represent the dictionary entry key
39
39
* its values represent the dictionary entry value
40
40
*
41
- * @param iterable<string, InnerList|Item|ByteSequence|Token|bool|int|float|string> $members
41
+ * @param iterable<string, InnerList|Item|ByteSequence|Token|array{
42
+ * 0:array<Item|ByteSequence|Token|bool|int|float|string>,
43
+ * 1:array<string,Item|ByteSequence|Token|bool|int|float|string>
44
+ * }|bool|int|float|string> $members
42
45
*/
43
46
public static function fromAssociative (iterable $ members = []): self
44
47
{
@@ -57,7 +60,10 @@ public static function fromAssociative(iterable $members = []): self
57
60
* the first member represents the instance entry key
58
61
* the second member represents the instance entry value
59
62
*
60
- * @param iterable<array{0:string, 1:InnerList|Item|ByteSequence|Token|bool|int|float|string}> $pairs
63
+ * @param iterable<array{0:string, 1:InnerList|Item|ByteSequence|Token|array{
64
+ * 0:array<Item|ByteSequence|Token|bool|int|float|string>,
65
+ * 1:array<string,Item|ByteSequence|Token|bool|int|float|string>
66
+ * }|bool|int|float|string}> $pairs
61
67
*/
62
68
public static function fromPairs (iterable $ pairs = []): self
63
69
{
@@ -128,6 +134,8 @@ public function toPairs(): Iterator
128
134
}
129
135
130
136
/**
137
+ * Returns an ordered list of the instance keys.
138
+ *
131
139
* @return array<string>
132
140
*/
133
141
public function keys (): array
@@ -186,7 +194,6 @@ private function filterIndex(int $index): int|null
186
194
* Returns the item or the inner-list and its key as attached to the given
187
195
* collection according to their index position otherwise throw.
188
196
*
189
- * @throws SyntaxError If the key is invalid
190
197
* @throws InvalidOffset If the key is not found
191
198
*
192
199
* @return array{0:string, 1:Item|InnerList}
@@ -211,8 +218,13 @@ public function pair(int $index): array
211
218
212
219
/**
213
220
* Add a member at the end of the instance if the key is new otherwise update the value associated with the key.
221
+ *
222
+ * @param InnerList|Item|ByteSequence|Token|array{
223
+ * 0:array<Item|ByteSequence|Token|bool|int|float|string>,
224
+ * 1:array<string,Item|ByteSequence|Token|bool|int|float|string>
225
+ * }|bool|int|float|string $member
214
226
*/
215
- public function set (string $ key , InnerList |Item |ByteSequence |Token |bool |int |float |string $ member ): void
227
+ public function set (string $ key , InnerList |Item |ByteSequence |Token |array | bool |int |float |string $ member ): void
216
228
{
217
229
self ::validateKey ($ key );
218
230
@@ -230,12 +242,16 @@ private static function validateKey(string $key): void
230
242
}
231
243
232
244
/**
233
- * Format the member type.
245
+ * @param InnerList|Item|ByteSequence|Token|array{
246
+ * 0:array<Item|ByteSequence|Token|bool|int|float|string>,
247
+ * 1:array<string,Item|ByteSequence|Token|bool|int|float|string>
248
+ * }|bool|int|float|string $member
234
249
*/
235
- private static function filterMember (InnerList |Item |ByteSequence |Token |bool |int |float |string $ member ): InnerList |Item
250
+ private static function filterMember (InnerList |Item |ByteSequence |Token |array | bool |int |float |string $ member ): InnerList |Item
236
251
{
237
252
return match (true ) {
238
253
$ member instanceof InnerList, $ member instanceof Item => $ member ,
254
+ is_iterable ($ member ) => InnerList::fromList (...$ member ),
239
255
default => Item::from ($ member ),
240
256
};
241
257
}
@@ -260,8 +276,13 @@ public function clear(): void
260
276
261
277
/**
262
278
* Add a member at the end of the instance if the key is new delete any previous reference to the key.
279
+ *
280
+ * @param InnerList|Item|ByteSequence|Token|array{
281
+ * 0:array<Item|ByteSequence|Token|bool|int|float|string>,
282
+ * 1:array<string,Item|ByteSequence|Token|bool|int|float|string>
283
+ * }|bool|int|float|string $member
263
284
*/
264
- public function append (string $ key , InnerList |Item |ByteSequence |Token |bool |int |float |string $ member ): void
285
+ public function append (string $ key , InnerList |Item |ByteSequence |Token |array | bool |int |float |string $ member ): void
265
286
{
266
287
self ::validateKey ($ key );
267
288
@@ -272,8 +293,13 @@ public function append(string $key, InnerList|Item|ByteSequence|Token|bool|int|f
272
293
273
294
/**
274
295
* Add a member at the beginning of the instance if the key is new delete any previous reference to the key.
296
+ *
297
+ * @param InnerList|Item|ByteSequence|Token|array{
298
+ * 0:array<Item|ByteSequence|Token|bool|int|float|string>,
299
+ * 1:array<string,Item|ByteSequence|Token|bool|int|float|string>
300
+ * }|bool|int|float|string $member
275
301
*/
276
- public function prepend (string $ key , InnerList |Item |ByteSequence |Token |bool |int |float |string $ member ): void
302
+ public function prepend (string $ key , InnerList |Item |ByteSequence |Token |array | bool |int |float |string $ member ): void
277
303
{
278
304
self ::validateKey ($ key );
279
305
@@ -285,7 +311,10 @@ public function prepend(string $key, InnerList|Item|ByteSequence|Token|bool|int|
285
311
/**
286
312
* Merge multiple instances.
287
313
*
288
- * @param iterable<array-key, InnerList|Item|Token|ByteSequence|float|int|bool|string> ...$others
314
+ * @param iterable<array-key, InnerList|Item|ByteSequence|Token|array{
315
+ * 0:array<Item|ByteSequence|Token|bool|int|float|string>,
316
+ * 1:array<string,Item|ByteSequence|Token|bool|int|float|string>
317
+ * }|bool|int|float|string> ...$others
289
318
*/
290
319
public function merge (iterable ...$ others ): void
291
320
{
0 commit comments