Skip to content

Commit 6611766

Browse files
committed
Improve docblock
1 parent 6b201b1 commit 6611766

10 files changed

+32
-20
lines changed

src/ByteSequenceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010
final class ByteSequenceTest extends StructuredFieldTest
1111
{
12-
/** @var array|string[] */
12+
/** @var array<string> */
1313
protected array $paths = [
1414
__DIR__.'/../vendor/httpwg/structured-field-tests/binary.json',
1515
];

src/Dictionary.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@
1919
* @see https://www.rfc-editor.org/rfc/rfc8941.html#section-3.2
2020
*
2121
* @implements MemberOrderedMap<string, Value|InnerList<int, Value>>
22-
* @implements ArrayAccess<string, Value|InnerList<int, Value>>
2322
* @phpstan-import-type DataType from Item
2423
*/
25-
final class Dictionary implements MemberOrderedMap, ArrayAccess
24+
final class Dictionary implements MemberOrderedMap
2625
{
2726
/** @var array<string, Value|InnerList<int, Value>> */
2827
private array $members = [];

src/DictionaryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
final class DictionaryTest extends StructuredFieldTest
1111
{
12-
/** @var array|string[] */
12+
/** @var array<string> */
1313
protected array $paths = [
1414
__DIR__.'/../vendor/httpwg/structured-field-tests/dictionary.json',
1515
];

src/InnerList.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@
1616

1717
/**
1818
* @see https://www.rfc-editor.org/rfc/rfc8941.html#section-3.1.1
19-
* @implements ArrayAccess<int, Value>
2019
* @implements MemberList<int, Value>
2120
* @phpstan-import-type DataType from Item
2221
*/
23-
final class InnerList implements ArrayAccess, MemberList, ParameterAccess
22+
final class InnerList implements MemberList, ParameterAccess
2423
{
2524
/** @var list<Value> */
2625
private array $members;

src/ItemTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515
final class ItemTest extends StructuredFieldTest
1616
{
17-
/** @var array|string[] */
17+
/** @var array<string> */
1818
protected array $paths = [
1919
__DIR__.'/../vendor/httpwg/structured-field-tests/boolean.json',
2020
__DIR__.'/../vendor/httpwg/structured-field-tests/number.json',

src/MemberContainer.php

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

55
namespace Bakame\Http\StructuredFields;
66

7+
use ArrayAccess;
78
use Countable;
8-
use Iterator;
99
use IteratorAggregate;
1010

1111
/**
1212
* @template TKey
1313
* @template TValue of StructuredField
14+
* @template-extends ArrayAccess<TKey, TValue>
1415
* @template-extends IteratorAggregate<TKey, TValue>
1516
*/
16-
interface MemberContainer extends Countable, IteratorAggregate, StructuredField
17+
interface MemberContainer extends ArrayAccess, Countable, IteratorAggregate, StructuredField
1718
{
1819
/**
1920
* Tells whether the instance contains no members.
@@ -25,15 +26,13 @@ public function hasNoMembers(): bool;
2526
*/
2627
public function hasMembers(): bool;
2728

28-
/**
29-
* @return Iterator<TKey, TValue>
30-
*/
31-
public function getIterator(): Iterator;
32-
3329
/**
3430
* @return TValue
3531
*/
3632
public function get(string|int $offset): StructuredField;
3733

34+
/**
35+
* Tells whether the instance contain a members at the specified offset.
36+
*/
3837
public function has(string|int $offset): bool;
3938
}

src/MemberList.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,45 @@ interface MemberList extends MemberContainer
1313
{
1414
/**
1515
* Inserts members at the beginning of the list.
16+
*
17+
* This method MUST retain the state of the current instance, and return
18+
* an instance that contains the specified changes.
1619
*/
1720
public function unshift(StructuredField ...$members): static;
1821

1922
/**
2023
* Inserts members at the end of the list.
24+
*
25+
* This method MUST retain the state of the current instance, and return
26+
* an instance that contains the specified changes.
2127
*/
2228
public function push(StructuredField ...$members): static;
2329

2430
/**
2531
* Inserts members at the index.
2632
*
33+
* This method MUST retain the state of the current instance, and return
34+
* an instance that contains the specified changes.
35+
*
2736
* @throws InvalidOffset If the index does not exist
2837
*/
2938
public function insert(int $index, StructuredField ...$members): static;
3039

3140
/**
3241
* Replaces the member associated with the index.
42+
*
43+
* This method MUST retain the state of the current instance, and return
44+
* an instance that contains the specified changes.
45+
*
46+
* @throws InvalidOffset If the index does not exist
3347
*/
3448
public function replace(int $index, StructuredField $member): static;
3549

3650
/**
37-
* Deletes members associated with the given indexes.
51+
* Deletes members associated with the list of submitted keys.
52+
*
53+
* This method MUST retain the state of the current instance, and return
54+
* an instance that contains the specified changes.
3855
*/
3956
public function remove(int ...$indexes): static;
4057
}

src/OrderedList.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@
1717
use function is_array;
1818

1919
/**
20-
* @implements ArrayAccess<int, Value|InnerList<int, Value>>
2120
* @implements MemberList<int, Value|InnerList<int, Value>>
2221
* @phpstan-import-type DataType from Item
2322
*/
24-
final class OrderedList implements ArrayAccess, MemberList
23+
final class OrderedList implements MemberList
2524
{
2625
/** @var list<Value|InnerList<int, Value>> */
2726
private array $members;

src/Parameters.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@
1717

1818
/**
1919
* @see https://www.rfc-editor.org/rfc/rfc8941.html#section-3.1.2
20-
* @implements ArrayAccess<string, Value>
2120
* @implements MemberOrderedMap<string, Value>
2221
* @phpstan-import-type DataType from Item
2322
*/
24-
final class Parameters implements ArrayAccess, MemberOrderedMap
23+
final class Parameters implements MemberOrderedMap
2524
{
2625
/** @var array<string, Value> */
2726
private array $members = [];

src/ParserTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
final class ParserTest extends StructuredFieldTest
1010
{
11-
/** @var array|string[] */
11+
/** @var array<string> */
1212
protected array $paths = [
1313
__DIR__.'/../vendor/httpwg/structured-field-tests/examples.json',
1414
__DIR__.'/../vendor/httpwg/structured-field-tests/key-generated.json',

0 commit comments

Comments
 (0)