15
15
use function is_array ;
16
16
17
17
/**
18
- * @implements MemberOrderedMap<string, Item |InnerList<int, Item >>
18
+ * @implements MemberOrderedMap<string, Value |InnerList<int, Value >>
19
19
* @phpstan-import-type DataType from Item
20
20
*/
21
21
final class Dictionary implements MemberOrderedMap
22
22
{
23
- /** @var array<string, Item |InnerList<int, Item >> */
23
+ /** @var array<string, Value |InnerList<int, Value >> */
24
24
private array $ members = [];
25
25
26
26
/**
27
- * @param iterable<string, InnerList<int, Item>|Item |DataType> $members
27
+ * @param iterable<string, InnerList<int, Value>|Value |DataType> $members
28
28
*/
29
29
private function __construct (iterable $ members = [])
30
30
{
@@ -47,7 +47,7 @@ public static function create(): self
47
47
* its keys represent the dictionary entry key
48
48
* its values represent the dictionary entry value
49
49
*
50
- * @param iterable<string, InnerList<int, Item>|Item |DataType> $members
50
+ * @param iterable<string, InnerList<int, Value>|Value |DataType> $members
51
51
*/
52
52
public static function fromAssociative (iterable $ members ): self
53
53
{
@@ -61,7 +61,7 @@ public static function fromAssociative(iterable $members): self
61
61
* the first member represents the instance entry key
62
62
* the second member represents the instance entry value
63
63
*
64
- * @param MemberOrderedMap<string, Item |InnerList<int, Item >>|iterable<array{0:string, 1:InnerList<int, Item>|Item |DataType}> $pairs
64
+ * @param MemberOrderedMap<string, Value |InnerList<int, Value >>|iterable<array{0:string, 1:InnerList<int, Value>|Value |DataType}> $pairs
65
65
*/
66
66
public static function fromPairs (MemberOrderedMap |iterable $ pairs ): self
67
67
{
@@ -94,8 +94,8 @@ public static function fromHttpValue(Stringable|string $httpValue): self
94
94
95
95
public function toHttpValue (): string
96
96
{
97
- $ formatter = static fn (Item |InnerList $ member , string $ key ): string => match (true ) {
98
- $ member instanceof Item && true === $ member ->value () => $ key .$ member ->parameters ()->toHttpValue (),
97
+ $ formatter = static fn (Value |InnerList $ member , string $ key ): string => match (true ) {
98
+ $ member instanceof Value && true === $ member ->value () => $ key .$ member ->parameters ()->toHttpValue (),
99
99
default => $ key .'= ' .$ member ->toHttpValue (),
100
100
};
101
101
@@ -118,15 +118,15 @@ public function hasMembers(): bool
118
118
}
119
119
120
120
/**
121
- * @return Iterator<string, Item |InnerList<int, Item >>
121
+ * @return Iterator<string, Value |InnerList<int, Value >>
122
122
*/
123
123
public function getIterator (): Iterator
124
124
{
125
125
yield from $ this ->members ;
126
126
}
127
127
128
128
/**
129
- * @return Iterator<array{0:string, 1:Item |InnerList<int, Item >}>
129
+ * @return Iterator<array{0:string, 1:Value |InnerList<int, Value >}>
130
130
*/
131
131
public function toPairs (): Iterator
132
132
{
@@ -152,7 +152,7 @@ public function has(string|int $offset): bool
152
152
* @throws SyntaxError If the key is invalid
153
153
* @throws InvalidOffset If the key is not found
154
154
*/
155
- public function get (string |int $ offset ): Item |InnerList
155
+ public function get (string |int $ offset ): Value |InnerList
156
156
{
157
157
if (is_int ($ offset ) || !array_key_exists ($ offset , $ this ->members )) {
158
158
throw InvalidOffset::dueToKeyNotFound ($ offset );
@@ -189,7 +189,7 @@ private function filterIndex(int $index): int
189
189
/**
190
190
* @throws InvalidOffset If the key is not found
191
191
*
192
- * @return array{0:string, 1:Item |InnerList<int, Item >}
192
+ * @return array{0:string, 1:Value |InnerList<int, Value >}
193
193
*/
194
194
public function pair (int $ index ): array
195
195
{
@@ -216,11 +216,11 @@ public function set(string $key, StructuredField|Token|ByteSequence|DateTimeInte
216
216
return $ this ;
217
217
}
218
218
219
- private static function filterMember (StructuredField |Token |ByteSequence |DateTimeInterface |Stringable |string |int |float |bool $ member ): InnerList |Item
219
+ private static function filterMember (StructuredField |Token |ByteSequence |DateTimeInterface |Stringable |string |int |float |bool $ member ): InnerList |Value
220
220
{
221
221
return match (true ) {
222
- $ member instanceof InnerList, $ member instanceof Item => $ member ,
223
- $ member instanceof StructuredField => throw new InvalidArgument ('Expecting a " ' .Item ::class.'" or a " ' .InnerList::class.'" instance; received a " ' .$ member ::class.'" instead. ' ),
222
+ $ member instanceof InnerList, $ member instanceof Value => $ member ,
223
+ $ member instanceof StructuredField => throw new InvalidArgument ('Expecting a " ' .Value ::class.'" or a " ' .InnerList::class.'" instance; received a " ' .$ member ::class.'" instead. ' ),
224
224
default => Item::from ($ member ),
225
225
};
226
226
}
@@ -258,7 +258,7 @@ public function prepend(string $key, StructuredField|Token|ByteSequence|DateTime
258
258
}
259
259
260
260
/**
261
- * @param iterable<string, InnerList<int, Item>|Item |DataType> ...$others
261
+ * @param iterable<string, InnerList<int, Value>|Value |DataType> ...$others
262
262
*/
263
263
public function mergeAssociative (iterable ...$ others ): self
264
264
{
@@ -270,7 +270,7 @@ public function mergeAssociative(iterable ...$others): self
270
270
}
271
271
272
272
/**
273
- * @param MemberOrderedMap<string, Item |InnerList<int, Item >>|iterable<array{0:string, 1:InnerList<int, Item>|Item |DataType}> ...$others
273
+ * @param MemberOrderedMap<string, Value |InnerList<int, Value >>|iterable<array{0:string, 1:InnerList<int, Value>|Value |DataType}> ...$others
274
274
*/
275
275
public function mergePairs (MemberOrderedMap |iterable ...$ others ): self
276
276
{
@@ -292,9 +292,9 @@ public function offsetExists(mixed $offset): bool
292
292
/**
293
293
* @param string $offset
294
294
*
295
- * @return Item |InnerList<int, Item >
295
+ * @return Value |InnerList<int, Value >
296
296
*/
297
- public function offsetGet (mixed $ offset ): InnerList |Item
297
+ public function offsetGet (mixed $ offset ): InnerList |Value
298
298
{
299
299
return $ this ->get ($ offset );
300
300
}
@@ -308,7 +308,7 @@ public function offsetUnset(mixed $offset): void
308
308
}
309
309
310
310
/**
311
- * @param InnerList<int, Item>|Item |DataType $value
311
+ * @param InnerList<int, Value>|Value |DataType $value
312
312
*/
313
313
public function offsetSet (mixed $ offset , mixed $ value ): void
314
314
{
0 commit comments