6
6
7
7
use ArrayAccess ;
8
8
use Closure ;
9
+ use Countable ;
9
10
use DateTimeImmutable ;
10
11
use DateTimeInterface ;
11
12
use Iterator ;
13
+ use IteratorAggregate ;
12
14
use Stringable ;
13
15
14
16
use function array_filter ;
30
32
* @phpstan-import-type SfItemInput from StructuredField
31
33
* @phpstan-import-type SfInnerListPair from StructuredField
32
34
*
33
- * @implements MemberList<int, Item>
35
+ * @implements ArrayAccess<int, Item>
36
+ * @implements IteratorAggregate<int, Item>
34
37
*/
35
- final class InnerList implements MemberList, ParameterAccess
38
+ final class InnerList implements ArrayAccess, Countable, IteratorAggregate, ParameterAccess, StructuredField
36
39
{
37
40
/** @var list<Item> */
38
41
private readonly array $ members ;
@@ -80,7 +83,7 @@ public static function fromHttpValue(Stringable|string $httpValue, ?Ietf $rfc =
80
83
* Returns a new instance with an iter.
81
84
*
82
85
* @param iterable<SfItemInput> $value
83
- * @param MemberOrderedMap<string, Item> |iterable<string, SfItemInput> $parameters
86
+ * @param Parameters |iterable<string, SfItemInput> $parameters
84
87
*/
85
88
public static function fromAssociative (iterable $ value , iterable $ parameters ): static
86
89
{
@@ -94,7 +97,7 @@ public static function fromAssociative(iterable $value, iterable $parameters): s
94
97
/**
95
98
* @param array{
96
99
* 0:iterable<SfItemInput>,
97
- * 1:MemberOrderedMap<string, Item> |iterable<array{0:string, 1:SfItemInput}>
100
+ * 1:Parameters |iterable<array{0:string, 1:SfItemInput}>
98
101
* } $pair
99
102
*/
100
103
public static function fromPair (array $ pair ): static
@@ -149,7 +152,7 @@ public function __toString(): string
149
152
}
150
153
151
154
/**
152
- * @return array{0:list<Item>, 1:MemberOrderedMap<string, Item> }
155
+ * @return array{0:list<Item>, 1:Parameters }
153
156
*/
154
157
public function toPair (): array
155
158
{
@@ -259,6 +262,11 @@ public function last(): ?StructuredField
259
262
return $ this ->members [$ this ->filterIndex (-1 )] ?? null ;
260
263
}
261
264
265
+ public function sortParameters (Closure $ callback ): static
266
+ {
267
+ return $ this ->withParameters ($ this ->parameters ()->sort ($ callback ));
268
+ }
269
+
262
270
/**
263
271
* Inserts members at the beginning of the list.
264
272
*/
@@ -512,13 +520,8 @@ public function withoutAnyParameter(): static
512
520
return $ this ->withParameters (Parameters::new ());
513
521
}
514
522
515
- /**
516
- * @deprecated since version 1.1
517
- * @see ParameterAccess::withoutParameterByKeys()
518
- * @codeCoverageIgnore
519
- */
520
- public function withoutParameter (string ...$ keys ): static
523
+ public function filterParameters (Closure $ callback ): static
521
524
{
522
- return $ this ->withoutParameterByKeys (... $ keys );
525
+ return $ this ->withParameters ( $ this -> parameters ()-> filter ( $ callback ) );
523
526
}
524
527
}
0 commit comments