Skip to content

Commit f5c8753

Browse files
committed
Improve docblock
1 parent 2dc5d4c commit f5c8753

File tree

4 files changed

+18
-14
lines changed

4 files changed

+18
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ All Notable changes to `bakame/http-strucured-fields` will be documented in this
1010
- The `ParameterAccess` interface.
1111
- The `InvaludArgument` exception.
1212
- `OrderedList`, `InnerList` now implements the `MemberList` interface.
13-
- `Parameters` and `Dictionnary` now implements the PHP `MemberOrderedMap` interface.
13+
- `Parameters` and `Dictionnary` now implements the PHP `OrderedMap` interface.
1414
- `Token::value` is a readonly property.
1515
- `Item::value` method returns the decoded value of an Item (returns value can be `float|int|string|bool`).
1616
- `Item::fromToken`, `Item::fromDecodedByteSequence` , `Item::fromEncodedByteSequence` to ease specific string initiation

src/OrderedList.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use function is_array;
1616

1717
/**
18-
* @implements MemberList<int, Item|InnerList<int, Item>>
18+
* @implements MemberList<int, Item|MemberList<int, Item>>
1919
*/
2020
final class OrderedList implements MemberList
2121
{
@@ -27,13 +27,18 @@ private function __construct(Item|InnerList ...$members)
2727
$this->members = array_values($members);
2828
}
2929

30-
public static function from(InnerList|Item|ByteSequence|Token|bool|int|float|string ...$members): self
30+
/**
31+
* @param MemberList<int, Item>|Item|ByteSequence|Token|bool|int|float|string ...$members
32+
*
33+
* @return static
34+
*/
35+
public static function from(MemberList|Item|ByteSequence|Token|bool|int|float|string ...$members): self
3136
{
3237
return self::fromList($members);
3338
}
3439

3540
/**
36-
* @param iterable<InnerList|Item|ByteSequence|Token|bool|int|float|string> $members
41+
* @param iterable<MemberList<int, Item>|Item|ByteSequence|Token|bool|int|float|string> $members
3742
*/
3843
public static function fromList(iterable $members = []): self
3944
{
@@ -102,7 +107,7 @@ public function hasMembers(): bool
102107
}
103108

104109
/**
105-
* @return Iterator<int, Item|InnerList<int, Item>>
110+
* @return Iterator<int, Item|MemberList<int, Item>>
106111
*/
107112
public function getIterator(): Iterator
108113
{
@@ -181,7 +186,7 @@ public function get(string|int $offset): Item|InnerList
181186
/**
182187
* Inserts members at the beginning of the list.
183188
*/
184-
public function unshift(StructuredField|ByteSequence|Token|bool|int|float|string ...$members): self
189+
public function unshift(MemberList|StructuredField|ByteSequence|Token|bool|int|float|string ...$members): self
185190
{
186191
$this->members = [...array_map(self::filterMember(...), array_values($members)), ...$this->members];
187192

@@ -191,7 +196,7 @@ public function unshift(StructuredField|ByteSequence|Token|bool|int|float|string
191196
/**
192197
* Inserts members at the end of the list.
193198
*/
194-
public function push(StructuredField|ByteSequence|Token|bool|int|float|string ...$members): self
199+
public function push(MemberList|StructuredField|ByteSequence|Token|bool|int|float|string ...$members): self
195200
{
196201
$this->members = [...$this->members, ...array_map(self::filterMember(...), array_values($members))];
197202

@@ -203,7 +208,7 @@ public function push(StructuredField|ByteSequence|Token|bool|int|float|string ..
203208
*
204209
* @throws InvalidOffset If the index does not exist
205210
*/
206-
public function insert(int $index, StructuredField|ByteSequence|Token|bool|int|float|string ...$members): self
211+
public function insert(int $index, MemberList|StructuredField|ByteSequence|Token|bool|int|float|string ...$members): self
207212
{
208213
$offset = $this->filterIndex($index);
209214
match (true) {
@@ -281,12 +286,12 @@ public function offsetUnset($offset): void
281286

282287
/**
283288
* @param int|null $offset
284-
* @param InnerList<int, Item>|Item|ByteSequence|Token|bool|int|float|string $value the member to add
289+
* @param MemberList<int, Item>|Item|ByteSequence|Token|bool|int|float|string $value the member to add
285290
*
286291
* @see ::push
287292
* @see ::replace
288293
*/
289-
public function offsetSet(mixed $offset, $value): void
294+
public function offsetSet(mixed $offset, mixed $value): void
290295
{
291296
if (null !== $offset) {
292297
$this->replace($offset, $value);

src/OrderedListTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public function test_it_can_generate_the_same_value(): void
122122
public function it_implements_the_array_access_interface(): void
123123
{
124124
$sequence = OrderedList::fromList();
125-
$sequence[] = InnerList::from(42, 69); // @phpstan-ignore-line
125+
$sequence[] = InnerList::from(42, 69);
126126

127127
self::assertTrue(isset($sequence[0]));
128128
self::assertInstanceOf(InnerList::class, $sequence[0]);

src/ParametersTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace Bakame\Http\StructuredFields;
66

7-
use TypeError;
87
use function iterator_to_array;
98

109
/**
@@ -350,8 +349,8 @@ public function it_fails_to_fetch_an_value_using_an_integer(): void
350349
/** @test */
351350
public function it_throws_if_the_structured_field_is_not_supported(): void
352351
{
353-
$this->expectException(TypeError::class);
352+
$this->expectException(InvalidArgument::class);
354353

355-
Parameters::fromPairs(['foo', InnerList::from(42)]); // @phpstan-ignore-line
354+
Parameters::fromPairs([['foo', InnerList::from(42)]]); // @phpstan-ignore-line
356355
}
357356
}

0 commit comments

Comments
 (0)