14
14
use function is_array ;
15
15
16
16
/**
17
- * @phpstan-type DataType ByteSequence|Token|bool|int|float|string
18
- * @implements MemberList<int, Item|MemberList<int, Item>>
17
+ * @implements MemberList<int, Item|InnerList<int, Item>>
19
18
*/
20
19
final class OrderedList implements MemberList
21
20
{
@@ -28,17 +27,17 @@ private function __construct(Item|InnerList ...$members)
28
27
}
29
28
30
29
/**
31
- * @param MemberList <int, Item>|Item|DataType ...$members
30
+ * @param InnerList <int, Item>|Item|DataType ...$members
32
31
*
33
32
* @return static
34
33
*/
35
- public static function from (MemberList |Item |ByteSequence |Token |bool |int |float |string ...$ members ): self
34
+ public static function from (InnerList |Item |ByteSequence |Token |bool |int |float |string ...$ members ): self
36
35
{
37
36
return self ::fromList ($ members );
38
37
}
39
38
40
39
/**
41
- * @param iterable<MemberList <int, Item>|Item|DataType> $members
40
+ * @param iterable<InnerList <int, Item>|Item|DataType> $members
42
41
*/
43
42
public static function fromList (iterable $ members = []): self
44
43
{
@@ -107,7 +106,7 @@ public function hasMembers(): bool
107
106
}
108
107
109
108
/**
110
- * @return Iterator<int, Item|MemberList <int, Item>>
109
+ * @return Iterator<int, Item|InnerList <int, Item>>
111
110
*/
112
111
public function getIterator (): Iterator
113
112
{
@@ -147,8 +146,10 @@ public function get(string|int $offset): Item|InnerList
147
146
148
147
/**
149
148
* Inserts members at the beginning of the list.
149
+ *
150
+ * @param InnerList<int, Item>|Item|DataType ...$members
150
151
*/
151
- public function unshift (MemberList | StructuredField |ByteSequence |Token |bool |int |float |string ...$ members ): self
152
+ public function unshift (StructuredField |ByteSequence |Token |bool |int |float |string ...$ members ): self
152
153
{
153
154
$ this ->members = [...array_map (self ::filterMember (...), array_values ($ members )), ...$ this ->members ];
154
155
@@ -157,8 +158,10 @@ public function unshift(MemberList|StructuredField|ByteSequence|Token|bool|int|f
157
158
158
159
/**
159
160
* Inserts members at the end of the list.
161
+ *
162
+ * @param InnerList<int, Item>|Item|DataType ...$members
160
163
*/
161
- public function push (MemberList | StructuredField |ByteSequence |Token |bool |int |float |string ...$ members ): self
164
+ public function push (StructuredField |ByteSequence |Token |bool |int |float |string ...$ members ): self
162
165
{
163
166
$ this ->members = [...$ this ->members , ...array_map (self ::filterMember (...), array_values ($ members ))];
164
167
@@ -168,9 +171,11 @@ public function push(MemberList|StructuredField|ByteSequence|Token|bool|int|floa
168
171
/**
169
172
* Inserts members starting at the given index.
170
173
*
174
+ * @param InnerList<int, Item>|Item|DataType $members
175
+ *
171
176
* @throws InvalidOffset If the index does not exist
172
177
*/
173
- public function insert (int $ index , MemberList | StructuredField |ByteSequence |Token |bool |int |float |string ...$ members ): self
178
+ public function insert (int $ index , StructuredField |ByteSequence |Token |bool |int |float |string ...$ members ): self
174
179
{
175
180
$ offset = $ this ->filterIndex ($ index );
176
181
match (true ) {
@@ -186,6 +191,8 @@ public function insert(int $index, MemberList|StructuredField|ByteSequence|Token
186
191
/**
187
192
* Replaces the member associated with the index.
188
193
*
194
+ * @param InnerList<int, Item>|Item|DataType $member
195
+ *
189
196
* @throws InvalidOffset If the index does not exist
190
197
*/
191
198
public function replace (int $ index , StructuredField |ByteSequence |Token |bool |int |float |string $ member ): self
@@ -248,7 +255,7 @@ public function offsetUnset($offset): void
248
255
249
256
/**
250
257
* @param int|null $offset
251
- * @param MemberList <int, Item>|Item|DataType $value the member to add
258
+ * @param InnerList <int, Item>|Item|DataType $value the member to add
252
259
*
253
260
* @see ::push
254
261
* @see ::replace
0 commit comments